我有旧的wxPython 2.0代码:
region = wx.RegionFromPoints([(0, 0), (w, 0), (w, h), (0, h)])
box = wx.RegionFromPoints([(100, 100), (500, 100), (500, 500), (100, 500)])
region.SubtractRegion(box)
现在在wxPython 3.0中它看起来像这样:
region = wx.Region([(0, 0), (w, 0), (w, h), (0, h)])
box = wx.Region([(100, 100), (500, 100), (500, 500), (100, 500)])
region.SubtractRegion(box)
Traceback看起来像这样:
Traceback (most recent call last):
File "transparent.py", line 22, in OnPaint
region.SubtractRegion(box)
AttributeError: 'Region' object has no attribute 'SubtractRegion'
检查Phoenix文档,它没有提及新wxPython 3.0中的“SubtractRegion”
有解决方法吗?
答案 0 :(得分:2)
现在只有Subtract
,因为不再需要重命名为SubtractRegion
来支持重载。请参阅Subtract
方法可用的重载文档:https://docs.wxpython.org/wx.Region.html#wx.Region.Subtract
另外https://docs.wxpython.org/MigrationGuide.html#overloaded-functions