wx.Menu how do I change group of a radiobutton?

Hi,

I’ve created a wx.Menu with a submenu with several radioitems… for cosmetic reasons I want a separator that splits the radiotems but I still want it to function as one group. When I create the separator, a new group is formed (as it should according to the documentation) and selecting an item in the first group of radioitems will not deselect any in the second group. Is there a way I can easily connect this new group to the one before the separator?

Thanks
Soren

Hi,

I’ve created a wx.Menu with a submenu with several radioitems… for cosmetic reasons I want a separator that splits the radiotems but I still want it to function as one group. When I create the separator, a new group is formed (as it should according to the documentation) and selecting an item in the first group of radioitems will not deselect any in the second group. Is there a way I can easily connect this new group to the one before the separator?

Thanks
Soren

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve

···

From: Søren Nielsen

Sent: Friday, July 16, 2010 9:39 PM

To: wxpython-users@googlegroups.com

Subject: [wxPython-users] wx.Menu how do I change group of a radiobutton?


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):
File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

···

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

···

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

You know, for most of the controls, I would have been right… But of course I jump the gun on this one :wink: scratch my last comment.

Replacing Bind with connect seemed to work fine for me:

self.Connect(301, 305, wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuRadio)

where 301 is the start id (id), 305 is the end id (id2), & self.OnMenuRadio is your event handler.

This is not really my cup of tea but check this link out, it says this is obsolete but it seems accomodate for the fact that the wx.wxEVT_COMMAND_MENU_SELECTED is an integer instead of a wx._core.PyEventBinder object.

Hopefully this helps a bit:

http://wiki.wxpython.org/AnotherTutorial#wx.MenuBar

Regards,

···

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

(OR)

EVT_CUSTOM_MENU_SELECTED = wx.PyEventBinder(wx.wxEVT_COMMAND_MENU_SELECTED, 2)
self.Bind(EVT_CUSTOM_MENU_SELECTED, self.OnMenuRadioButtons, id=301, id2=305)

It’s good I am figuring this out now, it will come in handy later on with my current project. :wink:

Regards,

···

On Sat, Jul 17, 2010 at 8:05 PM, A Wain awainb@gmail.com wrote:

You know, for most of the controls, I would have been right… But of course I jump the gun on this one :wink: scratch my last comment.

Replacing Bind with connect seemed to work fine for me:

self.Connect(301, 305, wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuRadio)

where 301 is the start id (id), 305 is the end id (id2), & self.OnMenuRadio is your event handler.

This is not really my cup of tea but check this link out, it says this is obsolete but it seems accomodate for the fact that the wx.wxEVT_COMMAND_MENU_SELECTED is an integer instead of a wx._core.PyEventBinder object.

Hopefully this helps a bit:

http://wiki.wxpython.org/AnotherTutorial#wx.MenuBar

Regards,

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Wain,

Thanks for the tip but I actually tried that first and found out wx.EVT_COMMAND_MENU_SELECTED does not exist … wx.wxEVT_COMMAND_MENU_SELECTED does however but that one gives the me error…

Regards,
Soren

···

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Ah sorry, didn’t see your other replies at first for some reason…

Thanks a lot!

···

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hi Wain,

Thanks for the tip but I actually tried that first and found out wx.EVT_COMMAND_MENU_SELECTED does not exist … wx.wxEVT_COMMAND_MENU_SELECTED does however but that one gives the me error…

Regards,

Soren

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hm… I seem to get the same effect as just using wx.EVT_MENU … I bind the EVT_COMMAND_MENU_SELECTED to the submenu holding my radioitems… but how do I obtain which item was selected from the wx.CommandEvent sent when I click on them?? I can only get the submenu through event.GetEventObject()

Soren

···

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Ah sorry, didn’t see your other replies at first for some reason…

Thanks a lot!

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hi Wain,

Thanks for the tip but I actually tried that first and found out wx.EVT_COMMAND_MENU_SELECTED does not exist … wx.wxEVT_COMMAND_MENU_SELECTED does however but that one gives the me error…

Regards,

Soren

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

well, like I said, this is not my cup of tee, but I think you need event.GetId to figure out which one was pressed :wink:

Not too sure where to guide you from here, although I am still trying to figure out why you would want to stick a seperator in the middle of the radiobox items? Is there a purpose for this or just for heck of it? :stuck_out_tongue:

Regards,

···

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hm… I seem to get the same effect as just using wx.EVT_MENU … I bind the EVT_COMMAND_MENU_SELECTED to the submenu holding my radioitems… but how do I obtain which item was selected from the wx.CommandEvent sent when I click on them?? I can only get the submenu through event.GetEventObject()

Soren

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Ah sorry, didn’t see your other replies at first for some reason…

Thanks a lot!

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hi Wain,

Thanks for the tip but I actually tried that first and found out wx.EVT_COMMAND_MENU_SELECTED does not exist … wx.wxEVT_COMMAND_MENU_SELECTED does however but that one gives the me error…

Regards,

Soren

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Ah ok, thanks! I do agree its not super pretty… but I guess it’ll do!

Well its purely for cosmetic reasons… I have a relatively long list of radiobuttons and just listing them up in a popupmenu looks a little ugly. Functionwise they can be grouped together into two blocks so I thought I’d split them up with a separator… I think it looks much better that way :slight_smile:

Soren

···

On Sun, Jul 18, 2010 at 5:05 AM, A Wain awainb@gmail.com wrote:

well, like I said, this is not my cup of tee, but I think you need event.GetId to figure out which one was pressed :wink:

Not too sure where to guide you from here, although I am still trying to figure out why you would want to stick a seperator in the middle of the radiobox items? Is there a purpose for this or just for heck of it? :stuck_out_tongue:

Regards,

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hm… I seem to get the same effect as just using wx.EVT_MENU … I bind the EVT_COMMAND_MENU_SELECTED to the submenu holding my radioitems… but how do I obtain which item was selected from the wx.CommandEvent sent when I click on them?? I can only get the submenu through event.GetEventObject()

Soren

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Ah sorry, didn’t see your other replies at first for some reason…

Thanks a lot!

2010/7/18 Søren Nielsen soren.skou.nielsen@gmail.com

Hi Wain,

Thanks for the tip but I actually tried that first and found out wx.EVT_COMMAND_MENU_SELECTED does not exist … wx.wxEVT_COMMAND_MENU_SELECTED does however but that one gives the me error…

Regards,

Soren

On Sat, Jul 17, 2010 at 7:29 PM, A Wain awainb@gmail.com wrote:

Hey Soren,

I think a typo is getting in your way, try replacing:

firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

with:

firstSubMenu.Bind(wx.EVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)

when you view the online docs, the events are written without the “.”, which is necessary. Just add in the “.” between wx and EVT_COMMAND_MENU_SELECTED and hopefully you should be good to go.

Regards,

2010/7/17 Søren Nielsen soren.skou.nielsen@gmail.com

I gave it a try making my own menu class from wx.Menu and bind wx.EVT_MENU to it but I can’t seem to get the selected menuitem when I select one of the radioitems… wxEVT_COMMAND_MENU_SELECTED doesn’t work (isn’t it basically the wx.EVT_MENU commandEvent?) … when I bind that event to a menu I get this error:

Traceback (most recent call last):

File “/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wx.py”, line 1242, in _onRightButtonUp
FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
File “/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.py”, line 1219, in button_release_event

self.callbacks.process(s, event)

File “/usr/lib64/python2.6/site-packages/matplotlib/cbook.py”, line 163, in process
func(*args, **kwargs)
File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1301, in OnMouseButton

self.ShowPopupMenu()

File “/home/specuser/workspace/bioxtasraw/RAW.py”, line 1318, in ShowPopupMenu
firstSubMenu.Bind(wx.wxEVT_COMMAND_MENU_SELECTED, self.OnMenuItemSelection)
File “/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 3918, in Bind

event.Bind(self, id, id2, handler)             

AttributeError: ‘int’ object has no attribute ‘Bind’

I think I’m on the right track, but I just need to be able to extract the selected radioitem when I click on it.

Soren

On Sat, Jul 17, 2010 at 3:05 AM, GadgetSteve@live.co.uk wrote

I would guess all you need to do is to have an wxEVT_COMMAND_MENU_SELECTED handler for all your radio items that deselect all the others for you - i.e. you will have to handle the radio group bit yourself.

Gadget/Steve


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

It's best to catch menu events at the frame rather than in the menu or the menu bar.

In the handler you can use event.GetId() to get the ID of the menu item that was selected, and using the ID you can get the menu item using theFrame.GetMenuBar().FindItemById(id)

···

On 7/17/10 9:40 PM, S�ren Nielsen wrote:

Hm.. I seem to get the same effect as just using wx.EVT_MENU .. I bind
the EVT_COMMAND_MENU_SELECTED to the submenu holding my radioitems...
but how do I obtain which item was selected from the wx.CommandEvent
sent when I click on them?? I can only get the submenu through
event.GetEventObject()

--
Robin Dunn
Software Craftsman

Thanks! It seems to work well on Linux, but on windows the it apparently forces a Check(True) on the new “group” after the separator… and setting menuitem.Check(False) doesn’t remove it. Is there a way to avoid that?

···

On Mon, Jul 19, 2010 at 11:36 PM, Robin Dunn robin@alldunn.com wrote:

On 7/17/10 9:40 PM, Søren Nielsen wrote:

Hm… I seem to get the same effect as just using wx.EVT_MENU … I bind

the EVT_COMMAND_MENU_SELECTED to the submenu holding my radioitems…

but how do I obtain which item was selected from the wx.CommandEvent

sent when I click on them?? I can only get the submenu through

event.GetEventObject()

It’s best to catch menu events at the frame rather than in the menu or the menu bar.

In the handler you can use event.GetId() to get the ID of the menu item that was selected, and using the ID you can get the menu item using theFrame.GetMenuBar().FindItemById(id)

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Not that I know of.

···

On 7/21/10 8:29 AM, S�ren Nielsen wrote:

Thanks! It seems to work well on Linux, but on windows the it apparently
forces a Check(True) on the new "group" after the separator.. and
setting menuitem.Check(False) doesn't remove it. Is there a way to avoid
that?

--
Robin Dunn
Software Craftsman

Ok since I need to have it running on all platforms and its way more trouble than its worth I’m skipping my crazy idea! :slight_smile:

···

On Wed, Jul 21, 2010 at 1:20 PM, Robin Dunn robin@alldunn.com wrote:

On 7/21/10 8:29 AM, Søren Nielsen wrote:

Thanks! It seems to work well on Linux, but on windows the it apparently

forces a Check(True) on the new “group” after the separator… and

setting menuitem.Check(False) doesn’t remove it. Is there a way to avoid

that?

Not that I know of.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Here's one more crazy idea, although I'm not sure how well it would work... Instead of separators use normal radio menu items with a label of "" and disable them.

···

On 7/21/10 10:49 AM, S�ren Nielsen wrote:

Ok since I need to have it running on all platforms and its way more
trouble than its worth I'm skipping my crazy idea! :slight_smile:

--
Robin Dunn
Software Craftsman