Reputation: 1
That's the question.
I'm making an indicator for Ubuntu, all works fine, but... When I try to set two "RadioMenuItem" they are totally independent. I can check both.
The items:
item_first = gtk.RadioMenuItem('First Radio')
item_first.connect('activate', first_radio)
menu.append(item_first)
item_second = gtk.RadioMenuItem('Second Radio')
item_second.connect('activate', second_radio)
menu.append(item_second)
Should I use a container or something like this? Please, help me.
Upvotes: 0
Views: 314
Reputation: 654
That's an old one, I know. However the solution is as following:
item_first = gtk.RadioMenuItem('First Radio')
item_first.connect('activate', first_radio)
menu.append(item_first)
item_second = gtk.RadioMenuItem('Second Radio', group=item_first) # <-- note group
item_second.connect('activate', second_radio)
menu.append(item_second)
Upvotes: 1
Reputation: 710
Try this,
self.menu = Gtk.Menu()
self.menu_items = list("First Radio","Second Radio")
group = []
for i in range(1,5):
menu_item = Gtk.RadioMenuItem.new_with_label(group, str(i))
group = menu_item.get_group()
self.menu_items[i] = menu_item
self.menu.append(menu_item)
menu_item.connect("activate", self.on_menu_select, i)
menu_item.show()
self.menu_items[2].set_active(True)
Upvotes: 1