SVGHMI: DnD UI : changed layout again, moved description in a vertical splitter, added scrollbar for preview and signature, fixed flickering description svghmi
authorEdouard Tisserant
Thu, 20 May 2021 12:16:51 +0200
branchsvghmi
changeset 3245 c441181247cf
parent 3244 1f365fa5d878
child 3246 0e8dbc2c390e
child 3247 7282b40374b0
SVGHMI: DnD UI : changed layout again, moved description in a vertical splitter, added scrollbar for preview and signature, fixed flickering description
svghmi/ui.py
--- a/svghmi/ui.py	Wed May 19 18:54:35 2021 +0200
+++ b/svghmi/ui.py	Thu May 20 12:16:51 2021 +0200
@@ -13,6 +13,7 @@
 from tempfile import NamedTemporaryFile
 
 import wx
+from wx.lib.scrolledpanel import ScrolledPanel
 
 from lxml import etree
 from lxml.etree import XSLTApplyError
@@ -167,7 +168,9 @@
         self.Config = wx.ConfigBase.Get()
         self.libdir = self.RecallLibDir()
 
-        self.picker_panel = wx.Panel(self)
+        self.picker_desc_splitter = wx.SplitterWindow(self, style=wx.SUNKEN_BORDER | wx.SP_3D)
+
+        self.picker_panel = wx.Panel(self.picker_desc_splitter)
         self.picker_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
         self.picker_sizer.AddGrowableCol(0)
         self.picker_sizer.AddGrowableRow(1)
@@ -186,19 +189,20 @@
 
 
 
-        self.main_panel = wx.Panel(self)
+        self.main_panel = ScrolledPanel(parent=self,
+                                                name='MiscellaneousPanel',
+                                                style=wx.TAB_TRAVERSAL)
 
         self.main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
         self.main_sizer.AddGrowableCol(0)
         self.main_sizer.AddGrowableRow(2)
 
         self.preview = wx.Panel(self.main_panel, size=(-1, _preview_height + _preview_margin*2))
-        self.desc = wx.TextCtrl(self.main_panel, size=wx.Size(-1, 160),
-                                   style=wx.TE_READONLY | wx.TE_MULTILINE)
+        self.staticmsg = wx.StaticText(self)
         self.signature_sizer = wx.BoxSizer(wx.VERTICAL)
         self.main_sizer.Add(self.preview, flag=wx.GROW)
+        self.main_sizer.Add(self.staticmsg, flag=wx.GROW)
         self.main_sizer.Add(self.signature_sizer, flag=wx.GROW)
-        self.main_sizer.Add(self.desc, flag=wx.GROW)
         self.main_sizer.Layout()
         self.main_panel.SetAutoLayout(True)
         self.main_panel.SetSizer(self.main_sizer)
@@ -206,7 +210,11 @@
         self.preview.Bind(wx.EVT_PAINT, self.OnPaint)
         self.preview.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
 
-        self.SplitVertically(self.main_panel, self.picker_panel, 300)
+        self.desc = wx.TextCtrl(self.picker_desc_splitter, size=wx.Size(-1, 160),
+                                   style=wx.TE_READONLY | wx.TE_MULTILINE)
+
+        self.picker_desc_splitter.SplitHorizontally(self.picker_panel, self.desc, 400)
+        self.SplitVertically(self.main_panel, self.picker_desc_splitter, 300)
 
         self.msg = _("Drag selected Widget from here to Inkscape")
         self.tempf = None 
@@ -218,13 +226,11 @@
         for editor in self.paths_editors:
             editor.Destroy()
         self.paths_editors = []
-        self.main_sizer.Layout()
 
     def AddPathToSignature(self, path):
         new_editor = PathEditor(self.main_panel, path)
         self.paths_editors.append(new_editor)
         self.signature_sizer.Add(new_editor, flag=wx.GROW)
-        self.main_sizer.Layout()
 
     def RecallLibDir(self):
         conf = self.Config.Read(_conf_key)
@@ -252,7 +258,6 @@
             w = self.bmp.GetWidth()
             dc.DrawBitmap(self.bmp, (sz.width - w)/2, _preview_margin)
 
-        self.desc.SetValue(self.msg)
 
 
     def OnSelectLibDir(self, event):
@@ -278,6 +283,8 @@
         self.DrawPreview()
         event.Skip()
 
+        self.staticmsg.SetLabel(self.msg)
+
     def GenThumbnail(self, svgpath, thumbpath):
         inkpath = get_inkscape_path()
         if inkpath is None:
@@ -363,6 +370,7 @@
 
     def AnalyseWidgetAndUpdateUI(self):
         self.msg = ""
+        self.ResetSignature()
 
         try:
             if self.selected_SVG is None:
@@ -384,16 +392,15 @@
             self.msg += "Widget analysis error: " + e.message
         else:
             
-            self.ResetSignature()
 
             print(etree.tostring(signature, pretty_print=True))
             widgets = signature.getroot()
             for defs in widgets.iter("defs"):
 
                 # Keep double newlines (to mark paragraphs)
-                self.msg += defs.find("type").text + ":\n" + "\n\n".join(map(
-                    lambda s:s.replace("\n"," ").replace("  ", " "), 
-                    defs.find("longdesc").text.split("\n\n")))
+                self.desc.SetValue(defs.find("type").text + ":\n" + "\n\n".join(map(
+                    lambda s:s.replace("\n"," ").replace("  ", " "),
+                    defs.find("longdesc").text.split("\n\n"))))
                 for arg in defs.iter("arg"):
                     print(arg.get("name"))
                     print(arg.get("accepts"))
@@ -411,6 +418,8 @@
                         str.strip, path.get("accepts", '')[1:-1].split(','))
                     print(path, path_value, path_accepts)
 
+        self.main_panel.SetupScrolling(scroll_x=False)
+
 
 
     def ValidateWidget(self):