They can send message to each other using the window.sight.message function. It will run "runJavaScript" a "message()" function from the every sights which run and their executes if it needs.

main
Balazs Birtalan 2023-10-26 19:47:39 +01:00
parent 4965e87980
commit 617bbe47cc
5 changed files with 40 additions and 5 deletions

View File

@ -97,8 +97,7 @@ class CallHandler(QObject):
@pyqtSlot() @pyqtSlot()
def move(self): def move(self):
base.data["move"] = True base.data["move"] = True
@pyqtSlot() @pyqtSlot()
def endmove(self): def endmove(self):
base.data["move"] = False base.data["move"] = False
@ -111,4 +110,13 @@ class CallHandler(QObject):
new_height = 250 new_height = 250
if(new_width<250): if(new_width<250):
new_width = 250 new_width = 250
self.sight.resize( new_width, new_height) self.sight.resize( new_width, new_height)
@pyqtSlot(str)
def message(self, label):
print("label - " + label)
for sight in base.sights.getSights().values():
sight.browser.page().runJavaScript("message('"+label+"')", self.ready)
def ready(self, returnValue):
print(returnValue)

View File

@ -148,6 +148,11 @@ function load(url, element)
xhttp.send(); xhttp.send();
} }
/*function message(label) {
alert("what")
return "message came"
}
*/
$(document).ready(function(){ $(document).ready(function(){
const scontent = document.querySelectorAll('[scontent]'); const scontent = document.querySelectorAll('[scontent]');
scontent.forEach((element) => { scontent.forEach((element) => {
@ -204,6 +209,7 @@ $(document).ready(function(){
$("#sminimize").empty(); $("#sminimize").empty();
$("#sminimize").prepend('<img src="img/minimize.png" height="20px" />'); $("#sminimize").prepend('<img src="img/minimize.png" height="20px" />');
} }
/*window.sight.getTitle(function(result) { /*window.sight.getTitle(function(result) {
setTitle(result); setTitle(result);
});*/ });*/

View File

@ -11,14 +11,25 @@
'width' : 300, 'width' : 300,
'height' : 300 'height' : 300
} }
</script> </script>
<script src="../../js/sight.js"></script> <script src="../../js/sight.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
/*addData("name", "Balazs", true); /*addData("name", "Balazs", true);
getData("name");*/ getData("name");*/
}); });
function message(label) {
if(label === "price_change") {
window.sight.message("changed_now")
return "I update my price - "+label
}
}
</script> </script>
</head> </head>
<body> <body>

View File

@ -9,7 +9,14 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
//getData("name", true); //getData("name", true);
window.sight.message("price_change")
}); });
function message(label) {
if(label === "changed_now") {
return "everything alright - " + label
}
}
</script> </script>
</head> </head>
<body> <body>

View File

@ -44,7 +44,10 @@ class SightFactory():
return True return True
print("This '"+str(id)+"' id isn't exist to show!") print("This '"+str(id)+"' id isn't exist to show!")
return False return False
def getSights(self):
return self.list
def get(self, id): def get(self, id):
if self.checkKey(id): if self.checkKey(id):
return self.list[id] return self.list[id]