Plugins may also contain a web app written in HTML/JavaScript. To use it the
plugin must contain a function called `web` which takes the prescription object
and returns a tuple containing the URL of the web app and a json string
-containing any data to be passed on to the web app. The `run` function of such a plugin must
-take two arguments, the prescription and the data returned from the web app.
+containing any data to be passed on to the web app. The `run` function of such
+a plugin must take two arguments, the prescription and the data returned from
+the web app.
The web app itself must include the `qtwebchannel.js` from PyQt6
(qrc:///qtwebchannel/qwebchannel.js). The webchannel exposes an object named
-`js` to the web app. The web app may access the prescription by using the
-`js.getPrescription()` and the data from the plugin by using the `js.getData()`
-function. The webapp may return data to the plugin by calling the `run`
-function of the exposed `js` object with two arguments, first being a json
-string containing the prescription object and the second being any data as
-string to be passed onto the plugin.
+`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.
Template Development
--------------------
self.prescription=prescription
self.data=data
- @pyqtSlot(str, str)
- def run(self, prescription, result):
- self.prescription.set_data_from_json(json.loads(prescription))
+ @pyqtSlot(str)
+ def run(self, result):
try:
message=self.module.run(self.prescription, result)
if(message):
logging.exception(e)
@pyqtSlot(result=str)
- def getPrescription(self):
- return self.prescription.get_json()
-
- @pyqtSlot(result=str)
- def getData(self):
+ def get(self):
return self.data
class Worker(QThread):