Phoenix
Phoenix copied to clipboard
GeometrySerializer cannot be instantiated or sub-classed
Operating system: Windows 11 wxPython version & source: 4.1.1 installed from pypi (wheel) Python version & source: 3.8.10 (stock, installer from python.org)
Description of the problem:
I'm trying to implement a serializer that can be used with wx.TopLevelWindow.SaveGeometry(). Following the documentation and this discussion, I tried implementing a class inheriting from wx.TopLevelWindow.GeometrySerializer. However, this leads to a type error, no matter whether I try inheriting directly, or using wx.TopLevelWindow.GeometrySerializer as meta class.
Implementation attempt
import wx
class MySerializer(metaclass=wx.TopLevelWindow.GeometrySerializer):
def SaveField(self, name, value):
print("[{name}] = {value}".format(name=name, value=value))
def RestoreField(self, name):
print("I want {name}".format(name=name))
serializer = MySerializer()
TypeError thrown by the code above
Traceback (most recent call last):
File "serializer.py", line 4, in <module>
class MySerializer(metaclass=wx.TopLevelWindow.GeometrySerializer):
TypeError: wx._core.GeometrySerializer cannot be instantiated or sub-classed
Confirmed. The issue is that wx.TopLevelWindow.GeometrySerializer isn't exposed. The etg scripts don't seem to be able to handle classes defined within classes, as best as I can see.