# 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 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="?")
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"])
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):
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"))