# HG changeset patch # User Edouard Tisserant # Date 1626100195 -7200 # Node ID 16066300b2544192d238d76e17e8f494eb38c02f # Parent 08a5a019bed291c886f8e7ac183da8488a5bbdc1 SVGHMI: default library path, default page when starting a SVGHMI project, error page when no SVG present diff -r 08a5a019bed2 -r 16066300b254 svghmi/default.svg --- a/svghmi/default.svg Mon Jul 12 14:13:29 2021 +0200 +++ b/svghmi/default.svg Mon Jul 12 16:29:55 2021 +0200 @@ -2,6 +2,7 @@ - - - - image/svg+xml - - - - - - - + width="1280"> - This is description for page 0 - -all lines in the form "name: value" -are used as js object definition initializer - -role: "page" -name: "Home" - -after triple opening braces is global JavaScript code - -{{{ -/* JS style Comment */ -alert("Hello World"); -}}} - -after triple closing braces is back to description - - - path: "count" -format: "%4.4d"8888 + id="rect1016" + style="color:#000000;opacity:1;fill:#d6d6d6;fill-opacity:1" /> diff -r 08a5a019bed2 -r 16066300b254 svghmi/svghmi.py --- a/svghmi/svghmi.py Mon Jul 12 14:13:29 2021 +0200 +++ b/svghmi/svghmi.py Mon Jul 12 16:29:55 2021 +0200 @@ -535,7 +535,10 @@ else: target_file = open(target_path, 'wb') target_file.write(""" - + + +SVGHMI +

No SVG file provided

@@ -548,6 +551,8 @@ port = self.GetParamsAttributes("SVGHMI.Port")["value"] interface = self.GetParamsAttributes("SVGHMI.Interface")["value"] path = self.GetParamsAttributes("SVGHMI.Path")["value"].format(name=view_name) + if path and path[0]=='/': + path = path[1:] enable_watchdog = self.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"] url="http://"+interface+("" if port==80 else (":"+str(port)) ) + (("/"+path) if path else "" @@ -672,7 +677,9 @@ dialog.Destroy() if open_inkscape: if not os.path.isfile(svgfile): - svgfile = None + # make a copy of default svg from source + default = os.path.join(ScriptDirectory, "default.svg") + shutil.copyfile(default, svgfile) open_svg(svgfile) def _StartPOEdit(self, POFile): diff -r 08a5a019bed2 -r 16066300b254 svghmi/ui.py --- a/svghmi/ui.py Mon Jul 12 14:13:29 2021 +0200 +++ b/svghmi/ui.py Mon Jul 12 16:29:55 2021 +0200 @@ -290,6 +290,8 @@ self.Config = wx.ConfigBase.Get() self.libdir = self.RecallLibDir() + if self.libdir is None: + self.libdir = os.path.join(ScriptDirectory, "widgetlib") self.picker_desc_splitter = wx.SplitterWindow(self, style=wx.SUNKEN_BORDER | wx.SP_3D)