--- a/svghmi/i18n.py Wed Mar 31 15:28:09 2021 +0200
+++ b/svghmi/i18n.py Wed Mar 31 15:30:07 2021 +0200
@@ -68,11 +68,15 @@
with open(fname, 'w') as POT_file:
+def GetPoFiles(dirpath): + po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")] def ReadTranslations(dirpath):
""" Read all PO files from a directory and return a list of (langcode, translation_dict) tuples """
- po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")]
+ po_files = GetPoFiles(dirpath) for po_fname in po_files:
--- a/svghmi/svghmi.py Wed Mar 31 15:28:09 2021 +0200
+++ b/svghmi/svghmi.py Wed Mar 31 15:30:07 2021 +0200
@@ -28,7 +28,8 @@
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
from XSLTransform import XSLTransform
from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\
- MatchTranslations, TranslationToEtree, open_pofile
+ MatchTranslations, TranslationToEtree, open_pofile,\ from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES
from svghmi.ui import SVGHMI_UI
from svghmi.fonts import GetFontTypeAndFamilyName, GetCSSFontFaceFromFontFile
@@ -400,13 +401,17 @@
- def GetFonts(self, _context):
+ def GetFontsFiles(self): project_path = self.CTNPath()
fontdir = os.path.join(project_path, "fonts")
+ if os.path.isdir(fontdir): + return [os.path.join(fontdir,f) for f in sorted(os.listdir(fontdir))] + def GetFonts(self, _context): - for f in sorted(os.listdir(fontdir)):
- fontfile = os.path.join(fontdir,f)
+ for fontfile in self.GetFontsFiles(): if os.path.isfile(fontfile):
css_parts.append(GetCSSFontFaceFromFontFile(fontfile))
@@ -446,13 +451,18 @@
hmi_tree_root._hash(hasher)
- with open(svgfile, 'rb') as afile:
- buf = afile.read(65536)
+ filestocheck = [svgfile] + \ + GetPoFiles(self.CTNPath()) + \ + for filetocheck in filestocheck: + with open(filetocheck, 'rb') as afile: + buf = afile.read(65536) digest = hasher.hexdigest()
if os.path.exists(hash_path):
--- a/svghmi/ui.py Wed Mar 31 15:28:09 2021 +0200
+++ b/svghmi/ui.py Wed Mar 31 15:30:07 2021 +0200
@@ -150,6 +150,7 @@
self.Bind(wx.EVT_BUTTON, self.OnSelectLibDir, self.libbutton)
self.preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ self.preview.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnWidgetSelection, self.widgetpicker)
@@ -272,6 +273,16 @@
+ def OnLeftDown(self, evt): + if self.selected_SVG is not None: + # TODO replace with generated widget file + filename = self.selected_SVG + data = wx.FileDataObject() + dropSource = wx.DropSource(self) + dropSource.SetData(data) + dropSource.DoDragDrop(wx.Drag_AllowMove) def ValidateWidget(self):
if self.selected_SVG is not None:
if self.hmitree_node is not None: