From: Agnibho Mondal Date: Tue, 5 Sep 2023 17:01:30 +0000 (+0530) Subject: Bugfix: path X-Git-Tag: v0.2~11 X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=999d631f141ce886ee0d2feac903cd54cf0db24b;p=medscript.git Bugfix: path --- diff --git a/config.py b/config.py index 91468f7..b25a37d 100644 --- a/config.py +++ b/config.py @@ -5,9 +5,11 @@ # 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 . -import argparse, json, os +import argparse, json, os, sys -default_config_file=os.path.abspath(os.path.join("config", "config.json")) +default_config_file=os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "config", "config.json")) + +real_dir=os.path.dirname(os.path.realpath(sys.argv[0])) parser = argparse.ArgumentParser() parser.add_argument("filename", nargs="?") @@ -37,10 +39,13 @@ with open(config_file) as conf: config = default | read config["filename"]=args.filename -config["data_directory"]=os.path.abspath(config["data_directory"]) +config["data_directory"]=os.path.abspath(os.path.join(real_dir, config["data_directory"])) config["document_directory"]=os.path.join(config["data_directory"], config["document_directory"]) +config["preset_directory"]=os.path.join(config["data_directory"], config["preset_directory"]) config["template_directory"]=os.path.join(config["data_directory"], config["template_directory"]) config["template"]=os.path.join(config["template_directory"], config["template"]) +config["resource"]=os.path.abspath(os.path.join(real_dir, "resource")) +print(config["resource"]) if(args.prescriber is None): config["prescriber_directory"]=os.path.join(config["data_directory"], config["prescriber_directory"]) config["prescriber"]=os.path.join(config["prescriber_directory"], config["prescriber"]) diff --git a/window.py b/window.py index eb507b3..4a5585a 100644 --- a/window.py +++ b/window.py @@ -98,11 +98,11 @@ class MainWindow(QMainWindow): self.edit_prescriber.show() def cmd_about(self): - self.viewbox.open(os.path.join("resource", "about.html")) + self.viewbox.open(os.path.join(config["resource"], "about.html")) self.viewbox.show() def cmd_help(self): - self.viewbox.open(os.path.join("resource", "help.html")) + self.viewbox.open(os.path.join(config["resource"], "help.html")) self.viewbox.show() def insert_preset_note(self): @@ -283,12 +283,12 @@ class MainWindow(QMainWindow): self.setWindowTitle("MedScript") self.setGeometry(100, 100, 600, 400) - self.setWindowIcon(QIcon(os.path.join("resource", "icon_medscript.ico"))) + self.setWindowIcon(QIcon(os.path.join(config["resource"], "icon_medscript.ico"))) - icon_open=QIcon(os.path.join("resource", "icon_open.svg")) - icon_save=QIcon(os.path.join("resource", "icon_save.svg")) - icon_render=QIcon(os.path.join("resource", "icon_render.svg")) - icon_refresh=QIcon(os.path.join("resource", "icon_refresh.svg")) + icon_open=QIcon(os.path.join(config["resource"], "icon_open.svg")) + icon_save=QIcon(os.path.join(config["resource"], "icon_save.svg")) + icon_render=QIcon(os.path.join(config["resource"], "icon_render.svg")) + icon_refresh=QIcon(os.path.join(config["resource"], "icon_refresh.svg")) self.preset_note=Preset(os.path.join(config["preset_directory"], "note.csv")) self.preset_report=Preset(os.path.join(config["preset_directory"], "report.csv"))