wx fixes for controls python3
authorGP Orcullo <kinsamanka@gmail.com>
Fri, 28 Oct 2022 18:59:04 +0800
branchpython3
changeset 3764 d92c1a3dafa7
parent 3763 369c7569bf94
child 3765 88fe6fc9fd38
wx fixes for controls
controls/DebugVariablePanel/DebugVariableGraphicViewer.py
controls/DebugVariablePanel/DebugVariableTextViewer.py
controls/DebugVariablePanel/DebugVariableViewer.py
controls/VariablePanel.py
--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Fri Oct 28 18:54:33 2022 +0800
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Fri Oct 28 18:59:04 2022 +0800
@@ -489,11 +489,12 @@
         @param item: Item from which data to export, all items if None
         (default None)
         """
-        self.ParentWindow.CopyDataToClipboard(
-            [(item, [entry for entry in item.GetData()])
-             for item in (self.Items
-                          if item is None
-                          else [item])])
+        if item and item.GetData():
+            self.ParentWindow.CopyDataToClipboard(
+                [(item, [entry for entry in item.GetData()])
+                 for item in (self.Items
+                              if item is None
+                              else [item])])
 
     def OnZoomFitButton(self):
         """
@@ -590,7 +591,7 @@
 
             # Search for point that tick is the nearest from mouse X position
             # and set cursor tick to the tick of this point
-            if len(data) > 0:
+            if data and len(data) > 0:
                 cursor_tick = data[numpy.argmin(
                     numpy.abs(data[:, 0] - event.xdata)), 0]
 
--- a/controls/DebugVariablePanel/DebugVariableTextViewer.py	Fri Oct 28 18:54:33 2022 +0800
+++ b/controls/DebugVariablePanel/DebugVariableTextViewer.py	Fri Oct 28 18:59:04 2022 +0800
@@ -122,6 +122,8 @@
             return True
         return False
 
+        return True
+
     def OnLeave(self):
         """
         Function called when mouse is leave Drop Target
--- a/controls/DebugVariablePanel/DebugVariableViewer.py	Fri Oct 28 18:54:33 2022 +0800
+++ b/controls/DebugVariablePanel/DebugVariableViewer.py	Fri Oct 28 18:59:04 2022 +0800
@@ -150,7 +150,7 @@
         Function that unsubscribe and remove every item that store values of
         a variable that doesn't exist in PLC anymore
         """
-        for item in list(self.ItemsDict.values())[:]:
+        for item in self.ItemsDict.values():
             iec_path = item.GetVariable()
 
             # Check that variablepath exist in PLC
--- a/controls/VariablePanel.py	Fri Oct 28 18:54:33 2022 +0800
+++ b/controls/VariablePanel.py	Fri Oct 28 18:59:04 2022 +0800
@@ -424,6 +424,8 @@
 
         return True
 
+        return True
+
     def ShowMessage(self, message):
         message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR)
         message.ShowModal()