etherlab/ConfigEditor.py
changeset 2459 21164625b393
parent 2450 5024c19ca8f0
child 2643 b98d9e08231f
--- a/etherlab/ConfigEditor.py	Fri Nov 23 11:01:20 2018 +0100
+++ b/etherlab/ConfigEditor.py	Fri Nov 23 12:13:24 2018 +0100
@@ -10,9 +10,9 @@
 # See COPYING file for copyrights details.
 
 from __future__ import absolute_import
+from __future__ import division
 import os
 import re
-from types import TupleType
 
 import wx
 import wx.grid
@@ -71,7 +71,7 @@
 
 ETHERCAT_INDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,4})$")
 ETHERCAT_SUBINDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,2})$")
-LOCATION_MODEL = re.compile("(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$")
+LOCATION_MODEL = re.compile(r"(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$")
 
 
 class NodeVariablesSizer(wx.FlexGridSizer):
@@ -324,12 +324,12 @@
         xstart, ystart = self.EtherCATManagementEditor.GetViewStart()
         window_size = self.EtherCATManagementEditor.GetClientSize()
         maxx, maxy = self.EtherCATManagementEditor.GetMinSize()
-        posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT))
-        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
+        posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT))
+        posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT))
         self.EtherCATManagementEditor.Scroll(posx, posy)
         self.EtherCATManagementEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
-                                                    maxx / SCROLLBAR_UNIT,
-                                                    maxy / SCROLLBAR_UNIT,
+                                                    maxx // SCROLLBAR_UNIT,
+                                                    maxy // SCROLLBAR_UNIT,
                                                     posx, posy)
         event.Skip()
     # -------------------------------------------------------------------------------------------------------
@@ -417,7 +417,7 @@
         except Exception:
             message = _("Invalid value \"%s\" for process variable") % data
             values = None
-        if not isinstance(values, TupleType):
+        if not isinstance(values, tuple):
             message = _("Invalid value \"%s\" for process variable") % data
             values = None
         if values is not None and col != wx.NOT_FOUND and row != wx.NOT_FOUND and 2 <= col <= 3:
@@ -479,7 +479,7 @@
         except Exception:
             message = _("Invalid value \"%s\" for startup command") % data
             values = None
-        if not isinstance(values, TupleType):
+        if not isinstance(values, tuple):
             message = _("Invalid value \"%s\" for startup command") % data
             values = None
         if values is not None:
@@ -1056,12 +1056,12 @@
         xstart, ystart = self.EthercatMasterEditor.GetViewStart()
         window_size = self.EthercatMasterEditor.GetClientSize()
         maxx, maxy = self.EthercatMasterEditorSizer.GetMinSize()
-        posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT))
-        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
+        posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT))
+        posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT))
         self.EthercatMasterEditor.Scroll(posx, posy)
         self.EthercatMasterEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
-                                                maxx / SCROLLBAR_UNIT,
-                                                maxy / SCROLLBAR_UNIT,
+                                                maxx // SCROLLBAR_UNIT,
+                                                maxy // SCROLLBAR_UNIT,
                                                 posx, posy)
         event.Skip()
 
@@ -1421,11 +1421,11 @@
         xstart, ystart = self.ModuleLibraryEditor.GetViewStart()
         window_size = self.ModuleLibraryEditor.GetClientSize()
         maxx, maxy = self.ModuleLibraryEditor.GetMinSize()
-        posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT))
-        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
+        posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT))
+        posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT))
         self.ModuleLibraryEditor.Scroll(posx, posy)
         self.ModuleLibraryEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
-                                               maxx / SCROLLBAR_UNIT,
-                                               maxy / SCROLLBAR_UNIT,
+                                               maxx // SCROLLBAR_UNIT,
+                                               maxy // SCROLLBAR_UNIT,
                                                posx, posy)
         event.Skip()