|
@@ -52,7 +52,28 @@ else:
|
|
|
if wxPythonPhoenix and CheckWxVersion([4, 0, 3, 0]):
|
|
|
from wx import NewIdRef as NewId
|
|
|
else:
|
|
|
- from wx import NewId
|
|
|
+ from wx import NewId # noqa: F401
|
|
|
+
|
|
|
+
|
|
|
+def convertToInt(argsOrKwargs, roundVal=False):
|
|
|
+ """Convert args, kwargs float value to int
|
|
|
+
|
|
|
+ :param tuple/list/dict argsOrKwargs: args or kwargs
|
|
|
+ :param bool roundVal: True if you want round float value
|
|
|
+
|
|
|
+ return list or dict
|
|
|
+ """
|
|
|
+ result = {} if isinstance(argsOrKwargs, dict) else []
|
|
|
+ j = None
|
|
|
+ for i in argsOrKwargs:
|
|
|
+ if isinstance(result, dict):
|
|
|
+ i, j = argsOrKwargs[i], i
|
|
|
+ if isinstance(i, float):
|
|
|
+ if roundVal:
|
|
|
+ i = round(i)
|
|
|
+ i = int(i)
|
|
|
+ result.update({j: i}) if j else result.append(i)
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
def BitmapFromImage(image, depth=-1):
|
|
@@ -122,6 +143,23 @@ class Panel(wx.Panel):
|
|
|
wx.Panel.SetToolTipString(self, tip)
|
|
|
|
|
|
|
|
|
+class Slider(wx.Slider):
|
|
|
+ """Wrapper around wx.Slider to have more control
|
|
|
+ over the widget on different platforms/wxpython versions"""
|
|
|
+
|
|
|
+ def __init__(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs)
|
|
|
+
|
|
|
+ wx.Slider.__init__(self, *args, **kwargs)
|
|
|
+
|
|
|
+ def SetRange(self, minValue, maxValue):
|
|
|
+ wx.Slider.SetRange(self, int(minValue), int(maxValue))
|
|
|
+
|
|
|
+ def SetValue(self, value):
|
|
|
+ wx.Slider.SetValue(self, int(value))
|
|
|
+
|
|
|
+
|
|
|
class SpinCtrl(wx.SpinCtrl):
|
|
|
"""Wrapper around wx.SpinCtrl to have more control
|
|
|
over the widget on different platforms"""
|
|
@@ -129,6 +167,8 @@ class SpinCtrl(wx.SpinCtrl):
|
|
|
gtk3MinSize = 130
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs)
|
|
|
if gtk3:
|
|
|
if 'size' in kwargs:
|
|
|
kwargs['size'] = wx.Size(max(self.gtk3MinSize, kwargs['size'][0]), kwargs['size'][1])
|
|
@@ -481,11 +521,13 @@ class PseudoDC(wx.adv.PseudoDC if wxPythonPhoenix else wx.PseudoDC):
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
super(PseudoDC, self).__init__(*args, **kwargs)
|
|
|
|
|
|
- def DrawLinePoint(self, pt1, pt2):
|
|
|
+ def DrawLinePoint(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args, roundVal=True)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs, roundVal=True)
|
|
|
if wxPythonPhoenix:
|
|
|
- super(PseudoDC, self).DrawLine(pt1, pt2)
|
|
|
+ super(PseudoDC, self).DrawLine(*args, **kwargs)
|
|
|
else:
|
|
|
- super(PseudoDC, self).DrawLinePoint(pt1, pt2)
|
|
|
+ super(PseudoDC, self).DrawLinePoint(*args, **kwargs)
|
|
|
|
|
|
def DrawRectangleRect(self, rect):
|
|
|
if wxPythonPhoenix:
|
|
@@ -501,6 +543,21 @@ class PseudoDC(wx.adv.PseudoDC if wxPythonPhoenix else wx.PseudoDC):
|
|
|
if not wxPythonPhoenix:
|
|
|
super(PseudoDC, self).EndDrawing()
|
|
|
|
|
|
+ def DrawRectangle(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args, roundVal=True)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs, roundVal=True)
|
|
|
+ super(PseudoDC, self).DrawRectangle(*args, **kwargs)
|
|
|
+
|
|
|
+ def DrawBitmap(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args, roundVal=True)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs, roundVal=True)
|
|
|
+ super(PseudoDC, self).DrawBitmap(*args, **kwargs)
|
|
|
+
|
|
|
+ def DrawCircle(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args, roundVal=True)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs, roundVal=True)
|
|
|
+ super(PseudoDC, self).DrawCircle(*args, **kwargs)
|
|
|
+
|
|
|
|
|
|
class ClientDC(wx.ClientDC):
|
|
|
"""Wrapper around wx.ClientDC to have more control
|
|
@@ -519,13 +576,15 @@ class Rect(wx.Rect):
|
|
|
"""Wrapper around wx.Rect to have more control
|
|
|
over the widget on different platforms/wxpython versions"""
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
+ args = convertToInt(argsOrKwargs=args)
|
|
|
+ kwargs = convertToInt(argsOrKwargs=kwargs)
|
|
|
wx.Rect.__init__(self, *args, **kwargs)
|
|
|
|
|
|
def ContainsXY(self, x, y):
|
|
|
if wxPythonPhoenix:
|
|
|
- return wx.Rect.Contains(self, x=x, y=y)
|
|
|
+ return wx.Rect.Contains(self, x=int(x), y=int(y))
|
|
|
else:
|
|
|
- return wx.Rect.ContainsXY(self, x, y)
|
|
|
+ return wx.Rect.ContainsXY(self, int(x), int(y))
|
|
|
|
|
|
def ContainsRect(self, rect):
|
|
|
if wxPythonPhoenix:
|
|
@@ -535,9 +594,9 @@ class Rect(wx.Rect):
|
|
|
|
|
|
def OffsetXY(self, dx, dy):
|
|
|
if wxPythonPhoenix:
|
|
|
- return wx.Rect.Offset(self, dx, dy)
|
|
|
+ return wx.Rect.Offset(self, int(dx), int(dy))
|
|
|
else:
|
|
|
- return wx.Rect.OffsetXY(self, dx, dy)
|
|
|
+ return wx.Rect.OffsetXY(self, int(dx), int(dy))
|
|
|
|
|
|
|
|
|
class CheckBox(wx.CheckBox):
|