Capturing PopupTransientWindow Button Event

Hello,

I am trying to use the wx.PopupTransientWindow class to create a pop up menu button, but I am having difficulty capturing any Button event that occurs in the window. Is this because the ProcessLeftDown event is being called before the Button event?
Is there a way to capture that wx.EVT_BUTTON?
If not, is there another solution I’m not thinking of that can mimic this popup menu button? I was working on wx.Menu() instead, but I need the menu buttons to be regular buttons, which didn’t seem (easily) possible with the wx.Menu().

I’ve attached a modified code from the wx demo to simulate my situation.

Python 2.7 with wx 2.8. on Windows 7 Machine.

Much thanks,
Jake

TransientWindowButton.py (2.18 KB)

Hate to do this but does anybody have any insight into this? I still haven’t come up with a clean solution.
I’ve tried Publishing a message from the PopupTransientWindow to capture in the Parent window like such:
def ProcessLeftDown(self, event):
print “TransientPopup ProcessLeftDown”
Publisher.sendMessage((“TransientButtonClick”), event)
return False
but I cant discern if the mouseclick happened in the PopupTransientWindow (therefore on the Button), or if it happened outside the window.
ProcessLeftDown is always called if the PopupTransientWindow exists, but is there a way to determine if the click was in the PopupTransientWindow or was outside the PopupTransientWindow ?

···

On Thursday, December 19, 2013 9:26:24 AM UTC-5, Jake Larrimore wrote:

Hello,

I am trying to use the wx.PopupTransientWindow class to create a pop up menu button, but I am having difficulty capturing any Button event that occurs in the window. Is this because the ProcessLeftDown event is being called before the Button event?
Is there a way to capture that wx.EVT_BUTTON?
If not, is there another solution I’m not thinking of that can mimic this popup menu button? I was working on wx.Menu() instead, but I need the menu buttons to be regular buttons, which didn’t seem (easily) possible with the wx.Menu().

I’ve attached a modified code from the wx demo to simulate my situation.

Python 2.7 with wx 2.8. on Windows 7 Machine.

Much thanks,
Jake

Jake Larrimore wrote:

Hello,

I am trying to use the wx.PopupTransientWindow class to create a pop up
menu button, but I am having difficulty capturing any Button event that
occurs in the window. Is this because the ProcessLeftDown event is being
called before the Button event?
Is there a way to capture that wx.EVT_BUTTON?
If not, is there another solution I'm not thinking of that can mimic
this popup menu button? I was working on wx.Menu() instead, but I need
the menu buttons to be regular buttons, which didn't seem (easily)
possible with the wx.Menu().

I've attached a modified code from the wx demo to simulate my situation.

Python 2.7 with wx 2.8. on Windows 7 Machine.

The wx popup window classes on Windows have always had problems dealing with child widgets, I think because the native window being used for the popup wasn't intended to have children or something like that.

However I just ran your sample with the forthcoming wxPython 3.0 and the EVT_BUTTON event does work as expected there. My guess is that it will also work with the 2.9.5 release as well if you want to get started with an upgrade right away.

···

--
Robin Dunn
Software Craftsman

Hey Robin,
Thanks for the heads up. I will take a look.
Jake

···

On Friday, December 27, 2013 8:29:48 PM UTC-5, Robin Dunn wrote:

Jake Larrimore wrote:

Hello,

I am trying to use the wx.PopupTransientWindow class to create a pop up

menu button, but I am having difficulty capturing any Button event that

occurs in the window. Is this because the ProcessLeftDown event is being

called before the Button event?

Is there a way to capture that wx.EVT_BUTTON?

If not, is there another solution I’m not thinking of that can mimic

this popup menu button? I was working on wx.Menu() instead, but I need

the menu buttons to be regular buttons, which didn’t seem (easily)

possible with the wx.Menu().

I’ve attached a modified code from the wx demo to simulate my situation.

Python 2.7 with wx 2.8. on Windows 7 Machine.

The wx popup window classes on Windows have always had problems dealing
with child widgets, I think because the native window being used for the
popup wasn’t intended to have children or something like that.

However I just ran your sample with the forthcoming wxPython 3.0 and the
EVT_BUTTON event does work as expected there. My guess is that it will
also work with the 2.9.5 release as well if you want to get started with
an upgrade right away.


Robin Dunn

Software Craftsman

http://wxPython.org