--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Fri Nov 23 11:01:20 2018 +0100
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Fri Nov 23 12:13:24 2018 +0100
@@ -24,7 +24,7 @@
from __future__ import absolute_import
-from types import TupleType
+from __future__ import division
from time import time as gettime
from cycler import cycler
@@ -36,6 +36,7 @@
from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
from matplotlib.backends.backend_agg import FigureCanvasAgg
from mpl_toolkits.mplot3d import Axes3D
+from six.moves import xrange
from editors.DebugViewer import REFRESH_PERIOD
from controls.DebugVariablePanel.DebugVariableViewer import *
@@ -156,7 +157,7 @@
# Check that data is valid regarding DebugVariablePanel
try:
values = eval(data)
- if not isinstance(values, TupleType):
+ if not isinstance(values, tuple):
raise ValueError
except Exception:
message = _("Invalid value \"%s\" for debug variable") % data
@@ -194,7 +195,7 @@
# Get Before which Viewer the variable has to be moved or added
# according to the position of mouse in Viewer.
- if y > height / 2:
+ if y > height // 2:
target_idx += 1
# Drag'n Drop is an internal is an internal move inside Debug
@@ -442,10 +443,10 @@
x = rect.x + (- w - offset
if direction == wx.LEFT
else rect.width + offset)
- y = rect.y + (rect.height - h) / 2
+ y = rect.y + (rect.height - h) // 2
offset += w
else:
- x = rect.x + (rect.width - w) / 2
+ x = rect.x + (rect.width - w) // 2
y = rect.y + (- h - offset
if direction == wx.TOP
else rect.height + offset)
@@ -800,7 +801,7 @@
self.ParentWindow.SetCanvasPosition(
self.StartCursorTick +
(self.MouseStartPos.x - event.x) *
- (end_tick - start_tick) / rect.width)
+ (end_tick - start_tick) // rect.width)
def OnCanvasScroll(self, event):
"""
@@ -818,7 +819,7 @@
tick = (start_tick + end_tick) / 2.
else:
tick = event.xdata
- self.ParentWindow.ChangeRange(int(-event.step) / 3, tick)
+ self.ParentWindow.ChangeRange(int(-event.step) // 3, tick)
# Vetoing event to prevent parent panel to be scrolled
self.ParentWindow.VetoScrollEvent = True
@@ -926,7 +927,7 @@
# Mouse is over Viewer figure and graph is not 3D
bbox = self.GetAxesBoundingBox()
if bbox.InsideXY(x, y) and not self.Is3DCanvas():
- rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height)
+ rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height)
# Mouse is over Viewer left part of figure
if rect.InsideXY(x, y):
self.SetHighlight(HIGHLIGHT_LEFT)
@@ -936,7 +937,7 @@
self.SetHighlight(HIGHLIGHT_RIGHT)
# Mouse is over upper part of Viewer
- elif y < height / 2:
+ elif y < height // 2:
# Viewer is upper one in Debug Variable Panel, show highlight
if self.ParentWindow.IsViewerFirst(self):
self.SetHighlight(HIGHLIGHT_BEFORE)
@@ -1324,11 +1325,11 @@
# Get value and forced flag for each variable displayed in graph
# If cursor tick is not defined get value and flag of last received
# or get value and flag of variable at cursor tick
- values, forced = apply(zip, [(
+ args = [(
item.GetValue(self.CursorTick)
if self.CursorTick is not None
- else (item.GetValue(), item.IsForced())
- ) for item in self.Items])
+ else (item.GetValue(), item.IsForced())) for item in self.Items]
+ values, forced = zip(*args)
# Get path of each variable displayed simplified using panel variable
# name mask
@@ -1399,11 +1400,11 @@
destGC.SetPen(HIGHLIGHT['DROP_PEN'])
destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])
- x_offset = (bbox.width / 2
+ x_offset = (bbox.width // 2
if self.Highlight == HIGHLIGHT_RIGHT
else 0)
destGC.DrawRectangle(bbox.x + x_offset, bbox.y,
- bbox.width / 2, bbox.height)
+ bbox.width // 2, bbox.height)
# Draw other Viewer common elements
self.DrawCommonElements(destGC, self.GetButtons())