Blob Blame History Raw
From 587f3418f2b772cfd24686f4448a29f340791e6b Mon Sep 17 00:00:00 2001
From: Scott Talbert <swt@techie.net>
Date: Thu, 30 Dec 2021 15:47:07 -0500
Subject: [PATCH] Fix even more Python 3.10 issues with wx.lib classes

(cherry picked from commit f5a55e6bf38ab5a0e7b7161477d2d523d057ec29)
---
 wx/lib/agw/flatnotebook.py   |  2 +-
 wx/lib/agw/foldpanelbar.py   |  2 +-
 wx/lib/agw/knobctrl.py       |  8 ++++----
 wx/lib/agw/ribbon/art_msw.py | 12 ++++++------
 wx/lib/calendar.py           | 10 +++++-----
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/wx/lib/agw/flatnotebook.py b/wx/lib/agw/flatnotebook.py
index 67781bccc..51da09e48 100644
--- a/wx/lib/agw/flatnotebook.py
+++ b/wx/lib/agw/flatnotebook.py
@@ -3738,7 +3738,7 @@ def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatu
         if pageTextColour is not None:
             dc.SetTextForeground(pageTextColour)
 
-        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
+        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, int(imageYCoord))
 
         # draw 'x' on tab (if enabled)
         if pc.HasAGWFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
diff --git a/wx/lib/agw/foldpanelbar.py b/wx/lib/agw/foldpanelbar.py
index 8f2ce5f51..7afba1bae 100644
--- a/wx/lib/agw/foldpanelbar.py
+++ b/wx/lib/agw/foldpanelbar.py
@@ -1014,7 +1014,7 @@ def DrawVerticalGradient(self, dc, rect):
         rf, gf, bf = 0, 0, 0
 
         for y in range(rect.y, rect.y + rect.height):
-            currCol = (r1 + rf, g1 + gf, b1 + bf)
+            currCol = (int(r1 + rf), int(g1 + gf), int(b1 + bf))
 
             dc.SetBrush(wx.Brush(currCol, wx.BRUSHSTYLE_SOLID))
             dc.DrawRectangle(rect.x, rect.y + (y - rect.y), rect.width, rect.height)
diff --git a/wx/lib/agw/knobctrl.py b/wx/lib/agw/knobctrl.py
index 1e5045ff6..c18ef18f0 100644
--- a/wx/lib/agw/knobctrl.py
+++ b/wx/lib/agw/knobctrl.py
@@ -675,7 +675,7 @@ def DrawDiagonalGradient(self, dc, size):
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
 
         for ii in range(0, maxsize, 2):
-            currCol = (r1 + rf, g1 + gf, b1 + bf)
+            currCol = (int(r1 + rf), int(g1 + gf), int(b1 + bf))
             dc.SetPen(wx.Pen(currCol, 2))
             dc.DrawLine(0, ii+2, ii+2, 0)
             rf = rf + rstep
@@ -683,7 +683,7 @@ def DrawDiagonalGradient(self, dc, size):
             bf = bf + bstep
 
         for ii in range(0, maxsize, 2):
-            currCol = (r1 + rf, g1 + gf, b1 + bf)
+            currCol = (int(r1 + rf), int(g1 + gf), int(b1 + bf))
             dc.SetPen(wx.Pen(currCol, 2))
             dc.DrawLine(ii+2, maxsize, maxsize, ii+2)
             rf = rf + rstep
@@ -763,9 +763,9 @@ def DrawInsetCircle(self, dc, pencolour):
         pt2 = wx.Point(int(cx+r*math.sqrt(2)/2.0), int(cy-r*math.sqrt(2)/2.0))
 
         dc.SetPen(p2)
-        dc.DrawArc(pt1, pt2, (cx, cy))
+        dc.DrawArc(pt1, pt2, (int(cx), int(cy)))
         dc.SetPen(p1)
-        dc.DrawArc(pt2, pt1, (cx, cy))
+        dc.DrawArc(pt2, pt1, (int(cx), int(cy)))
 
 
     def DrawBoundingCircle(self, dc, size):
diff --git a/wx/lib/agw/ribbon/art_msw.py b/wx/lib/agw/ribbon/art_msw.py
index 5fddc9d47..c2650fbd6 100644
--- a/wx/lib/agw/ribbon/art_msw.py
+++ b/wx/lib/agw/ribbon/art_msw.py
@@ -1306,9 +1306,9 @@ def DrawScrollButton(self, dc, wnd, rect_, style):
         background.height -= 2
 
         if style & RIBBON_SCROLL_BTN_UP:
-            background.height /= 2
+            background.height //= 2
         else:
-            background.height /= 5
+            background.height //= 5
 
         dc.GradientFillLinear(background, self._page_background_top_colour,
                               self._page_background_top_gradient_colour, wx.SOUTH)
@@ -1363,28 +1363,28 @@ def DrawScrollButton(self, dc, wnd, rect_, style):
         result = style & RIBBON_SCROLL_BTN_DIRECTION_MASK
 
         if result == RIBBON_SCROLL_BTN_LEFT:
-            arrow_points[0] = wx.Point(rect.width / 2 - 2, rect.height / 2)
+            arrow_points[0] = wx.Point(rect.width // 2 - 2, rect.height // 2)
             if style & RIBBON_SCROLL_BTN_ACTIVE:
                 arrow_points[0].y += 1
             arrow_points[1] = arrow_points[0] + wx.Point(3, -3)
             arrow_points[2] = arrow_points[0] + wx.Point(3,  3)
 
         elif result == RIBBON_SCROLL_BTN_RIGHT:
-            arrow_points[0] = wx.Point(rect.width / 2 + 2, rect.height / 2)
+            arrow_points[0] = wx.Point(rect.width // 2 + 2, rect.height // 2)
             if style & RIBBON_SCROLL_BTN_ACTIVE:
                 arrow_points[0].y += 1
             arrow_points[1] = arrow_points[0] - wx.Point(3,  3)
             arrow_points[2] = arrow_points[0] - wx.Point(3, -3)
 
         elif result == RIBBON_SCROLL_BTN_UP:
-            arrow_points[0] = wx.Point(rect.width / 2, rect.height / 2 - 2)
+            arrow_points[0] = wx.Point(rect.width // 2, rect.height // 2 - 2)
             if style & RIBBON_SCROLL_BTN_ACTIVE:
                 arrow_points[0].y += 1
             arrow_points[1] = arrow_points[0] + wx.Point( 3, 3)
             arrow_points[2] = arrow_points[0] + wx.Point(-3, 3)
 
         elif result == RIBBON_SCROLL_BTN_DOWN:
-            arrow_points[0] = wx.Point(rect.width / 2, rect.height / 2 + 2)
+            arrow_points[0] = wx.Point(rect.width // 2, rect.height // 2 + 2)
             if style & RIBBON_SCROLL_BTN_ACTIVE:
                 arrow_points[0].y += 1
             arrow_points[1] = arrow_points[0] - wx.Point( 3, 3)
diff --git a/wx/lib/calendar.py b/wx/lib/calendar.py
index 66dd2e714..cfb75833b 100644
--- a/wx/lib/calendar.py
+++ b/wx/lib/calendar.py
@@ -491,7 +491,7 @@ def DrawMonth(self, DC):
 
         tw, th = DC.GetTextExtent(month)
         adjust = self.cx_st + (self.sizew - tw) / 2
-        DC.DrawText(month, adjust, self.cy_st + th)
+        DC.DrawText(month, int(adjust), self.cy_st + th)
 
         year = str(self.year)
         tw, th = DC.GetTextExtent(year)
@@ -602,7 +602,7 @@ def DrawWeek(self, DC):
 
             DC.SetPen(pen)
 
-            point = (x + diffx, y + diffy)
+            point = (int(x + diffx), int(y + diffy))
             DC.DrawText(day, point)
             cnt_x = cnt_x + 1
 
@@ -679,7 +679,7 @@ def _DrawDayText(self, x, y, text, font, DC):
 
         adj_v = adj_v + self.num_indent_vert
 
-        DC.DrawText(text, (x + adj_h, y + adj_v))
+        DC.DrawText(text, (int(x + adj_h), int(y + adj_v)))
 
     def DrawDayText(self, DC, key):
         """
@@ -1518,7 +1518,7 @@ def __init__(self, parent, month=None, day=None, year=None):
 
         # alternate spin button to control the month
         h = self.m_date.GetSize().height
-        self.m_spin = wx.SpinButton(self, -1, (115, 20), (h * 1.5, h), wx.SP_VERTICAL)
+        self.m_spin = wx.SpinButton(self, -1, (115, 20), (int(h * 1.5), h), wx.SP_VERTICAL)
         self.m_spin.SetRange(1, 12)
         self.m_spin.SetValue(date.month)
         self.Bind(wx.EVT_SPIN, self.OnMonthSpin, self.m_spin)
@@ -1527,7 +1527,7 @@ def __init__(self, parent, month=None, day=None, year=None):
         self.y_date = wx.TextCtrl(self, -1, str(date.year), (160, 20), (60, -1))
         h = self.y_date.GetSize().height
 
-        self.y_spin = wx.SpinButton(self, -1, (225, 20), (h * 1.5, h), wx.SP_VERTICAL)
+        self.y_spin = wx.SpinButton(self, -1, (225, 20), (int(h * 1.5), h), wx.SP_VERTICAL)
         self.y_spin.SetRange(date.year-100, date.year+100)
         self.y_spin.SetValue(date.year)