SVGHMI: Add file type drag'n'drop to widget picker, for now drops widget's original SVG.
--- a/svghmi/ui.py Tue Mar 30 14:56:04 2021 +0200
+++ b/svghmi/ui.py Wed Mar 31 08:25:18 2021 +0200
@@ -150,6 +150,7 @@
sizer.Fit(self)
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 @@
self.ValidateWidget()
self.Refresh()
+ def OnLeftDown(self, evt):
+ if self.selected_SVG is not None:
+ # TODO replace with generated widget file
+ filename = self.selected_SVG
+ data = wx.FileDataObject()
+ data.AddFile(filename)
+ 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: