Howdy,
I'm using wxPython 2.8.7.1 and trying to subclass wx.Hyperlink in
XRCed. As the guide in wxpywiki, I write the code below which simply
sets colors:
class MyHyperlinkCtrl(wx.HyperlinkCtrl):
def __init__(self):
p = wx.PreHyperlinkCtrl()
self.PostCreate(p)
self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
But, it is strage that the HyperlinkCtrl still shows up with default
color. Therefore I am sure something has been done after OnCreate and
overwrite my color setting. Why? In my opinion, XRC loader setup
control settings in Pre...Post section or even after __init__, but
there should be nothing after OnCreate.
My workaround is binding EVT_PAINT instead of EVT_WINDOW_CREATE:
Howdy,
I'm using wxPython 2.8.7.1 and trying to subclass wx.Hyperlink in
XRCed. As the guide in wxpywiki, I write the code below which simply
sets colors:
class MyHyperlinkCtrl(wx.HyperlinkCtrl):
def __init__(self):
p = wx.PreHyperlinkCtrl()
self.PostCreate(p)
self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
But, it is strage that the HyperlinkCtrl still shows up with default
color. Therefore I am sure something has been done after OnCreate and
overwrite my color setting. Why?
More likely the OnCreate is not getting called. There are some widget types where the create event will be sent before you have a chance to bind the handler.
My workaround is binding EVT_PAINT instead of EVT_WINDOW_CREATE:
That is fine, and something like this is usually used as the workaround, although EVT_SIZE might be a better choice since that will likely happen before the first paint event and before the widget is actually visible.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Hi Robin,
It seems that the real world is much more complicated. I set
breakpoints in the handler and find that it has been invoked no matter
the event is EVT_WINDOW_CREATE, EVT_SIZE or EVT_PAINT. But only
EVT_PAINT works.
The behavior of color setting in EVT_WINDOW_CREATE, EVT_SIZE is
equivalent that ONLY self.VisitedColour is set. Furthermore, if there
is no URL info in XRC file and I put self.URL = ... in
EVT_WINDOW_CREATE, EVT_SIZE handler, it is useless. The control
behaves as no URL attached; my setting is overwritten by something.
Very strange eh?
I'm really confused... Could someone give me a insight explaination?
Hi Robin,
It seems that the real world is much more complicated. I set
breakpoints in the handler and find that it has been invoked no matter
the event is EVT_WINDOW_CREATE, EVT_SIZE or EVT_PAINT. But only
EVT_PAINT works.
The behavior of color setting in EVT_WINDOW_CREATE, EVT_SIZE is
equivalent that ONLY self.VisitedColour is set. Furthermore, if there
is no URL info in XRC file and I put self.URL = ... in
EVT_WINDOW_CREATE, EVT_SIZE handler, it is useless. The control
behaves as no URL attached; my setting is overwritten by something.
Very strange eh?
I'm really confused... Could someone give me a insight explaination?
Please provide a runnable sample and I'll see if I can spot what is happening. Also, be sure to mention platform and version.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!