]> Softwares of Agnibho - medscript.git/commitdiff
Plugins may close web app window after finishing.
authorAgnibho Mondal <mondal@agnibho.com>
Tue, 14 Nov 2023 19:36:05 +0000 (01:06 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Tue, 14 Nov 2023 19:36:05 +0000 (01:06 +0530)
README
plugin.py

diff --git a/README b/README
index ccc901926fa3fdef052a7c32409a547ba54a063f..27cb539ad744a626e5edcca436d2448abd3891a2 100644 (file)
--- a/README
+++ b/README
@@ -439,7 +439,8 @@ The web app itself must include the `qtwebchannel.js` from PyQt6
 `js` to the web app. The web app may access the data from the plugin by using
 the `js.get()` function. The web app may return data to the plugin by calling
 the `run` function of the exposed `js` object with the return data as the
-argument.
+argument. The web app window may be closed by calling the `close` function of
+the `js` object.
 
 Template Development
 --------------------
index b127b0fe40bf2627ac784c200cf62b11efebb18b..fd596946c7bd25c10c9365e7d8b709a2e534bb91 100644 (file)
--- a/plugin.py
+++ b/plugin.py
@@ -181,10 +181,12 @@ class WebApp(QMainWindow):
         self.channel.registerObject("js", self.js)
         self.webview.page().setWebChannel(self.channel)
         self.js.done.connect(lambda: self.done.emit())
+        self.js.hide.connect(lambda: self.close())
 
 class JS(QObject):
 
     done=pyqtSignal()
+    hide=pyqtSignal()
 
     def __init__(self, module, prescription, data):
         super().__init__()
@@ -209,6 +211,10 @@ class JS(QObject):
     def get(self):
         return self.data
 
+    @pyqtSlot()
+    def close(self):
+        self.hide.emit()
+
 class Worker(QThread):
 
     pluginComplete=pyqtSignal(str, int)