Custom widget derived from wxGenButton
I have created a custom widget derived from wxGenButton. I would like to be able to use it in wxGlade.
Alberto Griggio has made several changes to wxGlade to allow this to work.
However there is a problem when I load a .wxg file into wxGlade which contains one of the custom widgets. This is because wxGlade sets the ‘parent’ arg to None when it creates the widget.
This causes a problem in GenButton.init() because the call
font = parent.GetFont() fails.
If I modify init() like this:
if parent:
font = parent.GetFont()
else:
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
then it works OK. Would it be possible to incorporate a change like this in wxPython?
regards
Richard Townsend
Using wxGlade-0.3.3 from CVS; wxPython-2.5.1.5; Python-2.3.3; Win98SE.
I've already made other changes that elimiated the need for "font = parent.GetFont()" but I wonder how passing parent=None could possibly work. Isn't there an exception raised from wx.PyControl.__init__?
···
Richard.Townsend@edl.uk.eds.com wrote:
I have created a custom widget derived from wxGenButton. I would like to be able to use it in wxGlade.
Alberto Griggio has made several changes to wxGlade to allow this to work.
However there is a problem when I load a .wxg file into wxGlade which contains one of the custom widgets. This is because wxGlade sets the 'parent' arg to None when it creates the widget.
This causes a problem in GenButton.__init__() because the call
font = parent.GetFont() fails.
If I modify __init__() like this:
if parent:
font = parent.GetFont()
else:
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
then it works OK. Would it be possible to incorporate a change like this in wxPython?
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!