Transparent shape control overlay for container?

Thank you Robin,

Malcolm

···

----- Original message -----
From: "Robin Dunn" <robin@alldunn.com>
To: wxpython-users@lists.wxwidgets.org
Date: Fri, 13 Jun 2008 13:59:41 -0700
Subject: Re: [wxpython-users] Transparent shape control overlay for
container?

python@bdurham.com wrote:

Is there a transparent wxPython shape control that I can position on top
of a container to trap all mouse events associated with the container's
child controls?

No, wxWidgets doesn't have anything like that. If you are mainly
wanting a way to consolidate the event handling for the child widgets
then since wxPython allows you to bind any callable to be the event
handler (not just members of the same class like in C++) then you can
simply loop through all the widgets and bind their events to the same
handler functions in the parent class (or wherever you want to put
them). In the handler you can use event.GetEventObject() to know which
widget the event was for.

If that seems too messy for you then the mechanism that wxWidgets
provides for C++ works in Python too. You just derive a new class from
wx.EvtHandler, do you event bindings in the __init__ of that class like
normal, and then push instances of that class onto each of the child
widget's event handler stack with widget.PushEventHandler.

Motivation: I would like to build a composite control using a container
widget (wx.Window or wx.Panel?) filled with multiple controls (static
text and bitmaps). I would like the composite control to handle all
mouse events (mouse over, mouse exit, left click, double click, right
click, drag&drop, etc).

But, like Chris said, if all you need is text and bitmaps then drawing
it yourself and handling the other events in the same widget will
probably end up being a bit easier.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users