我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.STOCK_NO。
def stopall_collectors(self, button): self.status_context_menu.tray_ind.set_icon(gtk.STOCK_NO) self.status_context_menu.stopall_menu_item.set_sensitive(False) self.status_context_menu.startall_menu_item.set_sensitive(True) self.stopall_button.set_sensitive(False) self.startall_button.set_sensitive(True) i = 0.0 pb = ProgressBarDetails() pb.setValue(0.0) while gtk.events_pending(): gtk.main_iteration() for collector in self.engine.collectors: if collector.is_enabled() and isinstance(collector, engine.collector.AutomaticCollector): collector.terminate() pb.setValue(i/len(self.engine.collectors)) pb.appendText("stopping "+collector.name) while gtk.events_pending(): gtk.main_iteration() i += 1 pb.setValue(1.0) if not pb.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE)): pb.destroy()
def quit(self, widget, event=None): """Asks if user would like to save file before quitting, then quits the program.""" if self.toSave: if self.oneConfigFile: response = gtk.RESPONSE_YES else: dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.get_content_area().add(gtk.Label("Save config before quitting?")) dialog.get_content_area().set_size_request(300, 100) dialog.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True # Return True to stop it quitting when we hit "Cancel" elif response == gtk.RESPONSE_NO: gtk.main_quit() elif response == gtk.RESPONSE_YES: self.save() gtk.main_quit() else: gtk.main_quit()
def delete_format(self, widget, data=None): # ???? ???????? gtk.RadioButton for format_id in self.format_radio: if format_id.get_active(): # ?????????? ??????, ? ??????? ???????? ???????????? ?????????? ???? ????? dialog = gtk.Dialog('???????? ??????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"', self.window, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_OK)) dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) dialog.set_resizable(False) dialog.set_border_width(10) self.confirmation_label = gtk.Label('?? ????????????? ?????? ??????? ?????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"?') dialog.vbox.pack_start(self.confirmation_label, True, True, 5) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_CANCEL: dialog.hide() dialog.destroy() if response == gtk.RESPONSE_OK: # ??????? ?????? name = self.data['formats'][self.format_radio.index(format_id)]['name'] del self.data['formats'][self.format_radio.index(format_id)] config = open(self.path, 'wb') json.dump(self.data, config) config.close() self.format_radio[self.format_radio.index(format_id)].hide() if len(self.format_radio) == 1: pass elif self.format_radio.index(format_id) + 1 <= len(self.format_radio) - 1: self.format_radio[self.format_radio.index(format_id) + 1].set_active(True) elif self.format_radio.index(format_id) + 1 > len(self.format_radio) - 1: self.format_radio[self.format_radio.index(format_id) - 1].set_active(True) del self.format_radio[self.format_radio.index(format_id)] if len(self.format_radio) < 1: self.delete_button.set_sensitive(False) self.edit_button.set_sensitive(False) self.add_success_label.set_markup('<span foreground="#008600">"' + str(name) + '" ??????? ??????\n</span>') dialog.hide() dialog.destroy() break # ??? ??????? ???????????? ?????????? ?????? ???????
def mess_yesno(mess, title = ""): return mess_with_buttons(mess, (gtk.STOCK_YES, gtk.RESPONSE_YES, \ gtk.STOCK_NO, gtk.RESPONSE_NO), title) == gtk.RESPONSE_YES
def question(msg, window=None): if mac: response = macutils.question(msg) return response else: dialog = gtk.MessageDialog(window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, msg) dialog.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO) dialog.set_default_response(gtk.RESPONSE_NO) dialog.set_skip_taskbar_hint(False) response = dialog.run() dialog.destroy() return response in (gtk.RESPONSE_OK, gtk.RESPONSE_YES)
def __init__(self, app_engine, gui): menu = gtk.Menu() # show main application main_application_menu_item = gtk.MenuItem("Main Application") main_application_menu_item.show() menu.append(main_application_menu_item) main_application_menu_item.connect('activate', self.show_main_gui, gui) #separator sep0 = gtk.SeparatorMenuItem() sep0.show() menu.append(sep0) for collector in app_engine.collectors: if isinstance(collector, engine.collector.ManualCollector): menu_item_collector = gtk.MenuItem(collector.command_description) menu.append(menu_item_collector) menu_item_collector.connect('activate', self.run_collector, collector) #separator sep1 = gtk.SeparatorMenuItem() sep1.show() menu.append(sep1) # show about_menu_item dialog self.startall_menu_item = gtk.MenuItem("Start All Collectors") self.startall_menu_item.show() menu.append(self.startall_menu_item) self.startall_menu_item.connect('activate', gui.startall_collectors) # show about_menu_item dialog self.stopall_menu_item = gtk.MenuItem("Stop All Collectors") self.stopall_menu_item.show() menu.append(self.stopall_menu_item) self.stopall_menu_item.connect('activate', gui.stopall_collectors) self.stopall_menu_item.set_sensitive(False) #separator sep2 = gtk.SeparatorMenuItem() sep2.show() menu.append(sep2) # show about_menu_item dialog about_menu_item = gtk.MenuItem("About") about_menu_item.show() menu.append(about_menu_item) about_menu_item.connect('activate', self.show_about_dialog) # add quit_menu_item item quit_menu_item = gtk.MenuItem("Quit") quit_menu_item.show() menu.append(quit_menu_item) quit_menu_item.connect('activate', self.kill_me, app_engine) self.tray_ind = appindicator.Indicator("ECEL", gtk.STOCK_NO, appindicator.CATEGORY_SYSTEM_SERVICES) self.tray_ind.set_status(appindicator.STATUS_ACTIVE) self.tray_ind.set_menu(menu) menu.show_all()
def do_test(self, domsgbox=True): global myconfig self._tmp_home = None home_dir, config_name = gconsole.check_args() if not (config_name.find('/') >= 0 or config_name.find('\\') >= 0): config_name = os.path.join(home_dir, config_name) log.debug("config file used: %s", config_name) myconfig = config.Config(file=config_name) initialize.locations(self, home_dir) gettext.install('griffith', self.locations['i18n'], unicode=1) search_successful = '' search_unsuccessful = '' get_successful = '' get_unsuccessful = '' # test all plugins ? test_all = True dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, 'Test all plugins ?') dialog.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO) dialog.set_default_response(gtk.RESPONSE_NO) dialog.set_skip_taskbar_hint(False) response = dialog.run() dialog.destroy() if not response == gtk.RESPONSE_YES: test_all = False # iterate through all testable plugins for i in self.test_plugins: if domsgbox and test_all == False: # ask for test of that specific plugin dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, 'Test plugin %s ?' %i) dialog.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO) dialog.set_default_response(gtk.RESPONSE_NO) dialog.set_skip_taskbar_hint(False) response = dialog.run() dialog.destroy() if not response == gtk.RESPONSE_YES: continue print "Starting test of plugin: %s" % i plugin = __import__(i) # search test if self.do_test_searchplugin(i, False): search_successful = search_successful + i + ', ' else: search_unsuccessful = search_unsuccessful + i + ', ' # movie test if self.do_test_plugin(i, False): get_successful = get_successful + i + ', ' else: get_unsuccessful = get_unsuccessful + i + ', ' if domsgbox: gutils.info('SearchPluginTests\n Success: %s\n Failed: %s\n\nPluginTests\n Success: %s\n Failed: %s' % (search_successful, search_unsuccessful, get_successful, get_unsuccessful)) # # Start the tests #
def do_close(self, tab_child=None): if tab_child: eset = tab_child else: eset = self.get_current_editorset() if not eset: return False if eset.is_modified(): dlg = miscwidgets.YesNoDialog( title=_("Save Changes?"), parent=self, buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dlg.set_text(_("File is modified, save changes before closing?")) res = dlg.run() dlg.destroy() if res == gtk.RESPONSE_YES: self.do_save(eset) elif res != gtk.RESPONSE_NO: raise ModifiedError() eset.rthread.stop() eset.rthread.join() eset.prepare_close() if eset.radio.pipe: eset.radio.pipe.close() if isinstance(eset.radio, chirp_common.LiveRadio): action = self.menu_ag.get_action("openlive") if action: action.set_sensitive(True) page = self.tabs.page_num(eset) if page is not None: self.tabs.remove_page(page) return True