我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用gi.repository.Gtk.RadioMenuItem()。
def __menu_cryptos(self): menu = gtk.Menu() option = None for symbol in sorted(self.symbols): option = gtk.RadioMenuItem(symbol, group = option) option.set_active(symbol == self.symbol) option.connect('activate', self.__set_symbol, symbol) menu.append(option) return submenu(menu, 'Set symbol')
def __menu_refresh(self): menu = gtk.Menu() option = None for rate in REFRESH_RATES: option = gtk.RadioMenuItem('%sm' % rate, group = option) option.set_active(rate == REFRESH_RATES[0]) option.connect('activate', self.__update_refresh_rate, rate) menu.append(option) return submenu(menu, 'Refresh rate')
def __menu_fiat(self): menu = gtk.Menu() option = None for fiat in sorted(FIATS): option = gtk.RadioMenuItem(fiat, group = option) option.set_active(fiat == 'USD') option.connect('activate', self.__set_fiat, fiat) menu.append(option) return submenu(menu, 'Set fiat')
def __menu_decimals(self): menu = gtk.Menu() option = None for i in range(11): option = gtk.RadioMenuItem(i, group = option) option.set_active(i == self.num_decimals) option.connect('activate', self.__set_num_decimals, i) menu.append(option) return submenu(menu, 'Set decimals')
def _build_radiomenuitem(self, name, menu, group=None, set_active=False, on_signal="toggled", callback=None): """ """ menu_item = Gtk.RadioMenuItem(name, group=group) menu_item.set_active(set_active) if callback: menu_item.connect(on_signal, callback) menu.append(menu_item) return menu_item