From: Agnibho Mondal Date: Mon, 13 Nov 2023 21:02:14 +0000 (+0530) Subject: Prescription not passed to webapp X-Git-Tag: v0.5~4 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=c0fccbbcdfc6285f3603dd21498d48493de77380;p=medscript.git Prescription not passed to webapp --- diff --git a/README b/README index 2968a30..51b6b74 100644 --- a/README +++ b/README @@ -427,17 +427,16 @@ An example plugin, that modifies the name of the patient, may be as follows: 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 -------------------- diff --git a/plugin.py b/plugin.py index 8381f57..0238cf8 100644 --- a/plugin.py +++ b/plugin.py @@ -180,9 +180,8 @@ class JS(QObject): 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): @@ -193,11 +192,7 @@ class JS(QObject): 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):