def filesave(string path)
Get file to save. Only called before "run" function.
+Plugin may run in the background by defining a global variable `background`
+with the value `True`. This may be useful for long running tasks without
+freezing the program. This is only available for the "run" function.
+
The plugin may implement one or more functions mentioned above, it is not
necessary to implement all.
An example plugin, that modifies the name of the patient, may be as follows:
name="Change Name"
+ background=False
text=""
def run(prescription):
# MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
-import os, importlib
+import os, importlib, threading
from PyQt6.QtWidgets import QMessageBox, QInputDialog, QFileDialog
from glob import glob
from config import config
except Exception as e:
return(mod.__name__)
+ def background(self, function, prescription):
+ msg=function(prescription)
+ if(msg):
+ QMessageBox.information(None, "Information", msg)
+
def commands(self):
cmds=[]
for i in self.plugins:
module.fileopen(QFileDialog.getOpenFileName()[0])
if(hasattr(module, "filesave") and callable(module.filesave)):
module.filesave(QFileDialog.getSaveFileName()[0])
- msg=module.run(prescription)
- if(msg):
- QMessageBox.information(None, "Information", msg)
+ if(module.background):
+ QMessageBox.information(None, "Information", "Module "+module.__name__+" will run in background.")
+ threading.Thread(target=self.background, args=[module.run, prescription]).start()
+ else:
+ msg=module.run(prescription)
+ if(msg):
+ QMessageBox.information(None, "Information", msg)
except Exception as e:
print(e)