IDE: py3.10 related float/int fixes in debug plots
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 19 Oct 2023 22:52:27 +0200
changeset 3871 5d23a47937c4
parent 3870 be827d87b515
child 3872 5f73b439e78e
IDE: py3.10 related float/int fixes in debug plots
controls/DebugVariablePanel/DebugVariableGraphicViewer.py
controls/DebugVariablePanel/DebugVariableTextViewer.py
--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Wed Oct 18 19:36:20 2023 +0200
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Oct 19 22:52:27 2023 +0200
@@ -169,7 +169,7 @@
                 # If mouse is dropped in left part of graph canvas, graph
                 # wall be merged orthogonally
                 merge_rect = wx.Rect(rect.x, rect.y,
-                                     rect.width / 2., rect.height)
+                                     rect.width // 2, rect.height)
                 if merge_rect.Contains(x, y):
                     merge_type = GRAPH_ORTHOGONAL
 
@@ -613,6 +613,7 @@
                          [pair for pair in enumerate(self.Labels)]):
                 # Get label bounding box
                 (x0, y0), (x1, y1) = t.get_window_extent().get_points()
+                x0, y0, x1, y1 = map(int,(x0, y0, x1, y1))
                 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0)
                 # Check if mouse was over label
                 if rect.Contains(x, y):
@@ -724,6 +725,7 @@
                     directions):
                 # Check every label paired with corresponding item
                 (x0, y0), (x1, y1) = t.get_window_extent().get_points()
+                x0, y0, x1, y1 = map(int,(x0, y0, x1, y1))
                 rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0)
                 # Check if mouse was over label
                 if rect.Contains(event.x, height - event.y):
@@ -806,7 +808,7 @@
             # and mouse position
             if self.GraphType == GRAPH_ORTHOGONAL:
                 start_tick, end_tick = self.ParentWindow.GetRange()
-                tick = (start_tick + end_tick) / 2.
+                tick = (start_tick + end_tick) // 2.
             else:
                 tick = event.xdata
             self.ParentWindow.ChangeRange(int(-event.step) // 3, tick)
@@ -872,8 +874,8 @@
         # The minimum height take in account the height of all items, padding
         # inside figure and border around figure
         return wx.Size(200,
-                       CANVAS_BORDER[0] + CANVAS_BORDER[1] +
-                       2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items))
+                       int(CANVAS_BORDER[0] + CANVAS_BORDER[1] +
+                       2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) )
 
     def SetCanvasHeight(self, height):
         """
@@ -894,7 +896,7 @@
         # Calculate figure bounding box. Y coordinate is inverted in matplotlib
         # figure comparing to wx panel
         width, height = self.GetSize()
-        ax, ay, aw, ah = self.figure.gca().get_position().bounds
+        ax, ay, aw, ah = map(int, self.figure.gca().get_position().bounds)
         bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1,
                        aw * width + 2, ah * height + 1)
 
--- a/controls/DebugVariablePanel/DebugVariableTextViewer.py	Wed Oct 18 19:36:20 2023 +0200
+++ b/controls/DebugVariablePanel/DebugVariableTextViewer.py	Thu Oct 19 22:52:27 2023 +0200
@@ -243,7 +243,7 @@
         # Test if mouse has been pressed in this bounding box. In that case
         # start a move drag'n drop of item variable
         x, y = event.GetPosition()
-        item_path_bbox = wx.Rect(20, (height - h) / 2, w, h)
+        item_path_bbox = wx.Rect(20, (height - h) // 2, w, h)
         if item_path_bbox.Contains(x, y):
             self.ShowButtons(False)
             data = wx.TextDataObject(str((item.GetVariable(), "debug", "move")))