Reputation: 648
Works ok in Python 2.7 Trying to use wx.PyControl in Python 3.5 and get warning:
test_direct_svg.py:20: wxPyDeprecationWarning: Using deprecated class. Use Control instead. wx.PyControl.init(self, parent, id, pos, size, style, validator, name)
How do I use Control in init?
Python code I'm executing:
import wx
class ComponentFrame(wx.Frame):
def __init__(self, parent, id, title, pos, size):
wx.Frame.__init__(self, parent, id, title, pos, size)
self.panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.HORIZONTAL)
component = SvgComponent(self.panel)
vbox.Add(component, 1, wx.EXPAND | wx.ALL, 10)
self.panel.SetSizer(vbox)
class SvgComponent(wx.PyControl):
def __init__(self, parent, label="",
id=wx.ID_ANY,
pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator,
name="LoggerUI"):
wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name)
if __name__ == '__main__':
app = wx.App()
frame = ComponentFrame(None, wx.ID_ANY, 'test rsvg', (200, 200), (400, 400))
app.MainLoop()
Upvotes: 0
Views: 1576
Reputation: 143187
Error means you have to use wx.Control
instead of wx.PyControl
in all places.
BTW: don't forget frame.Show()
import wx
class ComponentFrame(wx.Frame):
def __init__(self, parent, id, title, pos, size):
wx.Frame.__init__(self, parent, id, title, pos, size)
self.panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.HORIZONTAL)
component = SvgComponent(self.panel)
vbox.Add(component, 1, wx.EXPAND | wx.ALL, 10)
self.panel.SetSizer(vbox)
class SvgComponent(wx.Control):
def __init__(self, parent, label="",
id=wx.ID_ANY,
pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator,
name="LoggerUI"):
wx.Control.__init__(self, parent, id, pos, size, style, validator, name)
if __name__ == '__main__':
app = wx.App()
frame = ComponentFrame(None, wx.ID_ANY, 'test rsvg', (200, 200), (400, 400))
frame.Show()
app.MainLoop()
Upvotes: 3