controls/DebugVariablePanel/DebugVariableViewer.py
branchpython3
changeset 3750 f62625418bff
parent 2456 7373e3048167
child 3764 d92c1a3dafa7
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    21 # You should have received a copy of the GNU General Public License
    21 # You should have received a copy of the GNU General Public License
    22 # along with this program; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 
    24 
    25 
    25 
    26 from __future__ import absolute_import
    26 
    27 from __future__ import division
    27 
    28 from collections import OrderedDict
    28 from collections import OrderedDict
    29 from functools import reduce
    29 from functools import reduce
    30 
    30 
    31 import wx
    31 import wx
    32 from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
    32 from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
    37 [HIGHLIGHT_NONE,
    37 [HIGHLIGHT_NONE,
    38  HIGHLIGHT_BEFORE,
    38  HIGHLIGHT_BEFORE,
    39  HIGHLIGHT_AFTER,
    39  HIGHLIGHT_AFTER,
    40  HIGHLIGHT_LEFT,
    40  HIGHLIGHT_LEFT,
    41  HIGHLIGHT_RIGHT,
    41  HIGHLIGHT_RIGHT,
    42  HIGHLIGHT_RESIZE] = range(6)
    42  HIGHLIGHT_RESIZE] = list(range(6))
    43 
    43 
    44 # Viewer highlight styles
    44 # Viewer highlight styles
    45 HIGHLIGHT = {
    45 HIGHLIGHT = {
    46 }
    46 }
    47 
    47 
    64         """
    64         """
    65         self.ParentWindow = window
    65         self.ParentWindow = window
    66         items = [] if items is None else items
    66         items = [] if items is None else items
    67         self.ItemsDict = OrderedDict([(item.GetVariable(), item)
    67         self.ItemsDict = OrderedDict([(item.GetVariable(), item)
    68                                       for item in items])
    68                                       for item in items])
    69         self.Items = self.ItemsDict.viewvalues()
    69         self.Items = self.ItemsDict.values()
    70 
    70 
    71         # Variable storing current highlight displayed in Viewer
    71         # Variable storing current highlight displayed in Viewer
    72         self.Highlight = HIGHLIGHT_NONE
    72         self.Highlight = HIGHLIGHT_NONE
    73         # List of buttons
    73         # List of buttons
    74         self.Buttons = []
    74         self.Buttons = []
   109     def GetItems(self):
   109     def GetItems(self):
   110         """
   110         """
   111         Return items displayed by Viewer
   111         Return items displayed by Viewer
   112         @return: List of items displayed in Viewer
   112         @return: List of items displayed in Viewer
   113         """
   113         """
   114         return self.ItemsDict.values()
   114         return list(self.ItemsDict.values())
   115 
   115 
   116     def AddItem(self, item):
   116     def AddItem(self, item):
   117         """
   117         """
   118         Add an item to the list of items displayed by Viewer
   118         Add an item to the list of items displayed by Viewer
   119         @param item: Item to add to the list
   119         @param item: Item to add to the list
   148     def SubscribeAllDataConsumers(self):
   148     def SubscribeAllDataConsumers(self):
   149         """
   149         """
   150         Function that unsubscribe and remove every item that store values of
   150         Function that unsubscribe and remove every item that store values of
   151         a variable that doesn't exist in PLC anymore
   151         a variable that doesn't exist in PLC anymore
   152         """
   152         """
   153         for item in self.ItemsDict.values()[:]:
   153         for item in list(self.ItemsDict.values())[:]:
   154             iec_path = item.GetVariable()
   154             iec_path = item.GetVariable()
   155 
   155 
   156             # Check that variablepath exist in PLC
   156             # Check that variablepath exist in PLC
   157             if self.ParentWindow.GetDataType(iec_path) is None:
   157             if self.ParentWindow.GetDataType(iec_path) is None:
   158                 # If not, unsubscribe and remove it
   158                 # If not, unsubscribe and remove it
   345 
   345 
   346     def OnForceButton(self):
   346     def OnForceButton(self):
   347         """
   347         """
   348         Function called when Force button is pressed
   348         Function called when Force button is pressed
   349         """
   349         """
   350         self.ForceValue(self.ItemsDict.values()[0])
   350         self.ForceValue(list(self.ItemsDict.values())[0])
   351 
   351 
   352     def OnReleaseButton(self):
   352     def OnReleaseButton(self):
   353         """
   353         """
   354         Function called when Release button is pressed
   354         Function called when Release button is pressed
   355         """
   355         """
   356         self.ReleaseValue(self.ItemsDict.values()[0])
   356         self.ReleaseValue(list(self.ItemsDict.values())[0])
   357 
   357 
   358     def OnMouseDragging(self, x, y):
   358     def OnMouseDragging(self, x, y):
   359         """
   359         """
   360         Function called when mouse is dragged over Viewer
   360         Function called when mouse is dragged over Viewer
   361         @param x: X coordinate of mouse pointer
   361         @param x: X coordinate of mouse pointer