Dismissing a popup menu

I'd like to be able to dismiss a popup menu after a short time if the user doesn't access it.

I know that "wxPython in Action" says this can't be programmed, but I'm hoping that someone has found a way. The simpler the better, of course.

Has anything made this possible since Robin's book came out? If so, as of a specific wxPython version?

Bob

Personally, I don’t see why you couldn’t use a wx.Timer object to do this. Start the timer when the popup menu is activated and after a few seconds, destroy it in the timer event handler. Alternatively, use the FlatMenu widget instead. It has popup functionality too and might be easier to control since it’s pure Python.

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

Mike, I've tried using wx.CallLater(2000,self.menu.Destroy) just before the PopupMenu call, but it does nothing, and no error message is generated. I don't understand that at all. I haven't yet tried wx.Timer because I thought that would have the same problem. Don't both use the same basic code?

Pressing the Alt key dismisses the popup, so simulating that keystroke might do the trick. But all the keystroke simulators I've come across are Windows-specific, and more trouble than they're worth in this case, imo.

I'd rather stay with PopupMenu if the programmatic dismissal thereof can be made to work, so I'll be listening here. But if it can't, I will give the FlatMenu widget a try.

Thanks, Mike.

Bob

···

At 10:17 AM 10/13/2011, you wrote:

Personally, I don't see why you couldn't use a wx.Timer object to do this. Start the timer when the popup menu is activated and after a few seconds, destroy it in the timer event handler. Alternatively, use the FlatMenu widget instead. It has popup functionality too and might be easier to control since it's pure Python.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Bob,
You might want to take a look at Andreas ToasterBox in the demo, it does
almost exactly what you are looking for, and more. If the (extra)style
is set to TB_COMPLEX you can put controls into it including buttons,
etc., so it should let you do what you need and it is cross platform.

Gadget/Steve

···

On 13/10/2011 3:43 PM, Bob Klahn wrote:

At 10:17 AM 10/13/2011, you wrote:

Personally, I don't see why you couldn't use a wx.Timer object to do
this. Start the timer when the popup menu is activated and after a
few seconds, destroy it in the timer event handler. Alternatively,
use the FlatMenu widget instead. It has popup functionality too and
might be easier to control since it's pure Python.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Mike, I've tried using wx.CallLater(2000,self.menu.Destroy) just
before the PopupMenu call, but it does nothing, and no error message
is generated. I don't understand that at all. I haven't yet tried
wx.Timer because I thought that would have the same problem. Don't
both use the same basic code?

Pressing the Alt key dismisses the popup, so simulating that keystroke
might do the trick. But all the keystroke simulators I've come across
are Windows-specific, and more trouble than they're worth in this
case, imo.

I'd rather stay with PopupMenu if the programmatic dismissal thereof
can be made to work, so I'll be listening here. But if it can't, I
will give the FlatMenu widget a try.

Thanks, Mike.

Bob

On Windows, hitting Alt alone activates/deactivates (toggling)
the menu bar. A widget will lose its focus.

jmf

···

On 13 oct, 16:43, Bob Klahn <bobsto...@comcast.net> wrote:

Pressing the Alt key dismisses the popup, so simulating that
keystroke might do the trick. But all the keystroke simulators I've
come across are Windows-specific, and more trouble than they're worth
in this case, imo.

Most of the time yes, that's what Alt does, but not when the popup menu is active. The popup eats that keystroke.

Bob

···

At 11:52 AM 10/13/2011, jmfauth wrote:

On 13 oct, 16:43, Bob Klahn <bobsto...@comcast.net> wrote:

>
> Pressing the Alt key dismisses the popup, so simulating that
> keystroke might do the trick. But all the keystroke simulators I've
> come across are Windows-specific, and more trouble than they're worth
> in this case, imo.
>

On Windows, hitting Alt alone activates/deactivates (toggling)
the menu bar. A widget will lose its focus.

Yes, more or less. wx.CallLater uses a timer.

Back to the original question, there is still not any way that I know of to programatically dismiss a popup menu.

···

On 10/13/11 7:43 AM, Bob Klahn wrote:

At 10:17 AM 10/13/2011, you wrote:

Personally, I don't see why you couldn't use a wx.Timer object to do
this. Start the timer when the popup menu is activated and after a few
seconds, destroy it in the timer event handler. Alternatively, use the
FlatMenu widget instead. It has popup functionality too and might be
easier to control since it's pure Python.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Mike, I've tried using wx.CallLater(2000,self.menu.Destroy) just before
the PopupMenu call, but it does nothing, and no error message is
generated. I don't understand that at all. I haven't yet tried wx.Timer
because I thought that would have the same problem. Don't both use the
same basic code?

--
Robin Dunn
Software Craftsman

Is a popup menu a native control?

Yes.

···

On 10/15/11 3:48 PM, Dev Player wrote:

Is a popup menu a native control?

--
Robin Dunn
Software Craftsman