Explicit NumPy.float64 to int typecasting in FCObjects.py

I cannot tell whether the original code worked before, but this explicit typecasting is necessary now.
The issue occurs, for example if attempting to execute "PieChart.py" or  "ScaledBitmap2Demo.py" in "samples\floatcanvas". Without typecasting, type errors are thrown, such as "TypeError: Image.Scale(): argument 1 has unexpected type 'numpy.float64'".
Apparently, this problem might be due to recent updates in Python and NumPy.
This commit is contained in:
PChemGuy
2022-08-20 17:41:12 +03:00
parent 8d771a389c
commit af3721f167
2 changed files with 4 additions and 4 deletions

View File

@@ -572,7 +572,7 @@ class RibbonFrame(wx.Frame):
(c.Blue() + 192) % 256)
dc.SetTextForeground(foreground)
dc.DrawText(colour, (iWidth - size.GetWidth() + 1) / 2, (iHeight - size.GetHeight()) / 2)
dc.DrawText(colour, int((iWidth - size.GetWidth() + 1) / 2), int((iHeight - size.GetHeight()) / 2))
dc.SelectObjectAsSource(wx.NullBitmap)
item = gallery.Append(bitmap, wx.ID_ANY)

View File

@@ -2269,7 +2269,7 @@ class ScaledBitmap2(TextObjectMixin, DrawObject, ):
"""
XY = WorldToPixel(self.XY)
H = ScaleWorldToPixel(self.Height)[0]
W = H * (self.bmpWidth / self.bmpHeight)
W = int(H * (self.bmpWidth / self.bmpHeight))
if (self.ScaledBitmap is None) or (self.ScaledBitmap[0] != (0, 0, self.bmpWidth, self.bmpHeight, W, H) ):
#if True: #fixme: (self.ScaledBitmap is None) or (H != self.ScaledHeight) :
self.ScaledHeight = H
@@ -2689,7 +2689,7 @@ class PieChart(XYObjectMixin, LineOnlyMixin, DrawObject):
dc.SetPen(self.Pen)
for i, brush in enumerate(self.Brushes):
dc.SetBrush( brush )
dc.DrawEllipticArc(Corner[0], Corner[1], WH[0], WH[1], self.Angles[i], self.Angles[i+1])
dc.DrawEllipticArc(int(Corner[0]), int(Corner[1]), int(WH[0]), int(WH[1]), self.Angles[i], self.Angles[i+1])
if HTdc and self.HitAble:
if self.Scaled:
radius = (ScaleWorldToPixel(self.Diameter)/2)[0]# just the x-coord
@@ -2697,7 +2697,7 @@ class PieChart(XYObjectMixin, LineOnlyMixin, DrawObject):
radius = self.Diameter/2
HTdc.SetPen(self.HitPen)
HTdc.SetBrush(self.HitBrush)
HTdc.DrawCircle(CenterXY, radius)
HTdc.DrawCircle(CenterXY.tolist(), int(radius))
class Group(DrawObject):