How to check menu item state?

Hi friends,

Just imagine a menubar with menu items, each menu item handler should check where this this item already checked or not. It's like IsChecked method for RADIO item, but this menu entries shouldn't be a RADIO-like.

So how I can check if *plain* menu items is already choosed or not?

Thanks in advance!

Are you defining the menu items with wx.ITEM_CHECK? Then you can just
check IsChecked()

···

On 2/3/07, Basil Shubin <bashu@yandex.ru> wrote:

Just imagine a menubar with menu items, each menu item handler should
check where this this item already checked or not. It's like IsChecked
method for RADIO item, but this menu entries shouldn't be a RADIO-like.

--

# p.d.

Peter Decker wrote:

···

On 2/3/07, Basil Shubin <bashu@yandex.ru> wrote:

Just imagine a menubar with menu items, each menu item handler should
check where this this item already checked or not. It's like IsChecked
method for RADIO item, but this menu entries shouldn't be a RADIO-like.

Are you defining the menu items with wx.ITEM_CHECK? Then you can just
check IsChecked()

No. And that is a problem, I want *plain* menu item without any 'kind' properties. And don't know is it possible for menu item like that, to check it state, to prevent from slecting twice.

Basil Shubin wrote:

Peter Decker wrote:

Just imagine a menubar with menu items, each menu item handler should
check where this this item already checked or not. It's like IsChecked
method for RADIO item, but this menu entries shouldn't be a RADIO-like.

Are you defining the menu items with wx.ITEM_CHECK? Then you can just
check IsChecked()

No. And that is a problem, I want *plain* menu item without any 'kind' properties. And don't know is it possible for menu item like that, to check it state, to prevent from slecting twice.

When you get the first event for the menu item then disable it. Then it can't be selected again. If you don't want it to appear disabled, then you you just need to write your event handlers such that they ignore the other events.

···

On 2/3/07, Basil Shubin <bashu@yandex.ru> wrote:

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

Robin Dunn wrote:

Basil Shubin wrote:

Peter Decker wrote:

Just imagine a menubar with menu items, each menu item handler should
check where this this item already checked or not. It's like IsChecked
method for RADIO item, but this menu entries shouldn't be a RADIO-like.

Are you defining the menu items with wx.ITEM_CHECK? Then you can just
check IsChecked()

No. And that is a problem, I want *plain* menu item without any 'kind' properties. And don't know is it possible for menu item like that, to check it state, to prevent from slecting twice.

When you get the first event for the menu item then disable it. Then it can't be selected again. If you don't want it to appear disabled, then you you just need to write your event handlers such that they ignore the other events.

But how I can accomplish this? Is there straightforward algorithm? How I can check where this event was already called or not, so it can be possible to ignore or execute it forward?

···

On 2/3/07, Basil Shubin <bashu@yandex.ru> wrote:

Create an attribute for the frame or application such as
'menuItemCalled', and set it to False initially. Then write your event
handler like this:

if app.menuItemCalled:
  return
app.menuItemCalled = True
... rest of code.

···

On 2/4/07, Basil Shubin <bashu@yandex.ru> wrote:

> When you get the first event for the menu item then disable it. Then it
> can't be selected again. If you don't want it to appear disabled, then
> you you just need to write your event handlers such that they ignore the
> other events.

But how I can accomplish this? Is there straightforward algorithm? How I
can check where this event was already called or not, so it can be
possible to ignore or execute it forward?

--

# p.d.

Peter Decker wrote:

But how I can accomplish this? Is there straightforward algorithm? How I
can check where this event was already called or not, so it can be
possible to ignore or execute it forward?

Create an attribute for the frame or application such as
'menuItemCalled', and set it to False initially. Then write your event
handler like this:

if app.menuItemCalled:
return
app.menuItemCalled = True
... rest of code.

Yes, I have imagine something like that, but asks to know if there any other solution.

Thanks Peter!