Python gtk 模块,STOCK_YES 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用gtk.STOCK_YES

项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
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()
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
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

  # ??? ??????? ???????????? ?????????? ?????? ???????
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
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
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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)
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def _setup(self):
        self.thumbnail = gtk.Image()
        self.label = gtk.Label(self.layer.name)
        # creating the fix button, to anchor background frames.
        self._fix_button = Utils.toggle_button_stock(gtk.STOCK_MEDIA_RECORD,20)
        self._fix_button.set_tooltip_text("toggle fixed visibility.")

        # update fixed variable
        self.fixed = Utils.is_frame_fixed(self.layer)
        #images
        pin_img = gtk.Image()
        pin_img.set_from_stock(gtk.STOCK_YES,20)
        pin_img2 = gtk.Image()
        pin_img2.set_from_stock(gtk.STOCK_MEDIA_RECORD,20)

        self._fix_button_images = [pin_img,pin_img2]

        ## connect
        self._fix_button.connect('clicked',self.on_toggle_fix)

        if self.fixed:
            self._fix_button.set_image(self._fix_button_images[0])
            self._fix_button.set_active(True)
        else :
            self._fix_button.set_image(self._fix_button_images[1])
            self._fix_button.set_active(False)

        frame = gtk.Frame()
        layout = gtk.VBox()
        # add frame to this widget
        self.add(frame)

        # add layout manager to the frame
        frame.add(layout)

        layout.pack_start(self.label)
        layout.pack_start(self._fix_button)
        layout.pack_start(self.thumbnail)
        self._get_thumb_image()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
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
#
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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