IDE: hopefully last fix about float type being passed to WxPy4.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 20 Aug 2024 01:26:58 +0200
changeset 3975 2ef76b61bf1e
parent 3974 4c9c1cbf69b2
child 3976 86e39be014d8
IDE: hopefully last fix about float type being passed to WxPy4.
graphics/GraphicCommons.py
graphics/LD_Objects.py
--- a/graphics/GraphicCommons.py	Tue Aug 20 01:25:39 2024 +0200
+++ b/graphics/GraphicCommons.py	Tue Aug 20 01:26:58 2024 +0200
@@ -349,10 +349,10 @@
         posx, posy = self.GetPosition()
         min_width, min_height = self.GetMinSize()
         if width < min_width:
-            self.Pos.x = max(0, self.Pos.x - (width - min_width) * x_factor)
+            self.Pos.x = max(0, round(self.Pos.x - (width - min_width) * x_factor))
             width = min_width
         if height < min_height:
-            self.Pos.y = max(0, self.Pos.y - (height - min_height) * y_factor)
+            self.Pos.y = max(0, round(self.Pos.y - (height - min_height) * y_factor))
             height = min_height
         if scaling is not None:
             self.Pos.x = round_scaling(self.Pos.x, scaling[0])
@@ -1026,16 +1026,16 @@
     """
 
     # Create a new connector
-    def __init__(self, parent, name, type, position, direction, negated=False, edge="none", onlyone=False):
+    def __init__(self, parent, name, Type, position, direction, negated=False, edge="none", onlyone=False):
         DebugDataConsumer.__init__(self)
         ToolTipProducer.__init__(self, parent.Parent)
         self.ParentBlock = parent
         self.Name = name
-        self.Type = type
+        self.Type = Type
         self.Pos = position
         self.Direction = direction
         self.Wires = []
-        if self.ParentBlock.IsOfType("BOOL", type):
+        if self.ParentBlock.IsOfType("BOOL", Type):
             self.Negated = negated
             self.Edge = edge
         else:
@@ -1141,8 +1141,8 @@
         return self.ParentBlock.IsOfType(type, reference) or self.ParentBlock.IsOfType(reference, type)
 
     # Changes the connector name
-    def SetType(self, type):
-        self.Type = type
+    def SetType(self, Type):
+        self.Type = Type
         for wire, _handle in self.Wires:
             wire.SetValid(wire.IsConnectedCompatible())
 
--- a/graphics/LD_Objects.py	Tue Aug 20 01:25:39 2024 +0200
+++ b/graphics/LD_Objects.py	Tue Aug 20 01:26:58 2024 +0200
@@ -593,11 +593,11 @@
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         # Draw two rectangles for representing the contact
-        left_left = (self.Pos.x - 1) * scalex - 2
-        right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
-        top = (self.Pos.y - 1) * scaley - 2
-        width = 4 * scalex + 5
-        height = (self.Size[1] + 3) * scaley + 5
+        left_left = round((self.Pos.x - 1) * scalex) - 2
+        right_left = round((self.Pos.x + self.Size[0] - 2) * scalex) - 2
+        top = round((self.Pos.y - 1) * scaley) - 2
+        width = round(4 * scalex + 5)
+        height = round((self.Size[1] + 3) * scaley) + 5
 
         dc.DrawRectangle(left_left, top, width, height)
         dc.DrawRectangle(right_left, top, width, height)