Python gtk 模块,STOCK_OK 实例源码

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

项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def __init__(self, title, parent, ok_button=True, cancel_button=True,
                 width=600, height=260, extra_buttons=None):
        buttons = []

        if extra_buttons:
            buttons.extend(extra_buttons)

        if ok_button:
            buttons.extend([gtk.STOCK_OK, gtk.RESPONSE_ACCEPT])

        if cancel_button:
            buttons.extend([gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT])

        buttons = tuple(buttons)
        gtk.Dialog.__init__(self, title, parent, DEF_DIALOG_FLAGS, buttons)
        self.set_size_request(width, height)
        self.set_has_separator(False)
    # __init__()
# Dialog
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_save_ngc(self, *arg) :
        filechooserdialog = gtk.FileChooserDialog(_("Save as ngc..."), None,
            gtk.FILE_CHOOSER_ACTION_SAVE,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        try :
            filt = gtk.FileFilter()
            filt.set_name("NGC")
            filt.add_mime_type("text/ngc")
            filt.add_pattern("*.ngc")
            filechooserdialog.add_filter(filt)
            filechooserdialog.set_current_folder(NGC_DIR)
            filechooserdialog.set_keep_above(True)
            filechooserdialog.set_transient_for(self.get_toplevel())

            if filechooserdialog.run() == gtk.RESPONSE_OK:
                gcode = self.to_gcode()
                filename = filechooserdialog.get_filename()
                if filename[-4] != ".ngc" not in filename :
                    filename += ".ngc"
                with open(filename, "wb") as f:
                    f.write(self.to_gcode())
                f.close()
        finally :
            filechooserdialog.destroy()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_loadCfg(self, *arg) :
        filechooserdialog = gtk.FileChooserDialog(_("Open a cfg file"), None, \
                    gtk.FILE_CHOOSER_ACTION_OPEN, \
                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                     gtk.STOCK_OK, gtk.RESPONSE_OK))
        try:
            filt = gtk.FileFilter()
            filt.set_name(_("Config files"))
            filt.add_mime_type("text/xml")
            filt.add_pattern("*.cfg")
            filechooserdialog.add_filter(filt)
            filechooserdialog.set_current_folder(os.path.join(NCAM_DIR, CUSTOM_DIR))
            filechooserdialog.set_keep_above(True)
            filechooserdialog.set_transient_for(self.get_toplevel())

            if filechooserdialog.run() == gtk.RESPONSE_OK:
                self.add_feature(None, filechooserdialog.get_filename())
        finally :
            filechooserdialog.destroy()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, **args):
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                   gtk.STOCK_OK, gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, buttons=buttons, **args)

        self.label = gtk.Label()
        self.label.set_size_request(300, 100)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.label, 1, 1, 0)

        self.text = gtk.Entry()
        self.text.connect("activate", self.respond_ok, None)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.text, 1, 1, 0)

        self.label.show()
        self.text.show()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def get_password(self,parent):
        dialog = gtk.Dialog("Configure System Password",parent,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT))
        self.pass1 = gtk.HBox()
                self.label1 = gtk.Label("          Passsword: ")
                self.pass1.pack_start(self.label1,False,True,0)
        self.password1 = gtk.Entry()
        self.password1.set_visibility(False)
        self.pass1.pack_start(self.password1,False,True,0)
        dialog.vbox.add(self.pass1)
        self.pass2 = gtk.HBox()
                self.label2 = gtk.Label("  Verify Password: ")
                self.pass2.pack_start(self.label2,False,True,0)
        self.password2 = gtk.Entry()
        self.password2.set_visibility(False)
        self.pass2.pack_start(self.password2,False,True,0)
        dialog.vbox.add(self.pass2)
        dialog.show_all()
        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            self.a = self.password1.get_text()
            self.b = self.password2.get_text()
            dialog.destroy()
        else:
            self.a = ''
            self.b = ''
            dialog.destroy()


    # Configure Network Dialog
项目:srcsim2017    作者:ZarjRobotics    | 项目源码 | 文件源码
def exitfc_button_cb(self, button):
        label = gtk.Label("Are you sure you want the FC to exit?")
        dialog = gtk.Dialog("Confirm Exit",
                       None,
                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                       (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                       gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        dialog.vbox.pack_start(label)
        label.show()
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_ACCEPT:
            msg = ZarjExitCommand()
            self.zarj_comm.push_message(msg)
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def browseDirectory(self, sender, dirPathFunc):
        fd = gtk.FileChooserDialog(title='Choose directory to share...', action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OK,gtk.RESPONSE_OK))
        fd.set_default_response(gtk.RESPONSE_OK)
        path = dirPathFunc().strip()
        if len(path):
            fd.set_current_folder(path)
        response = fd.run()
        if response == gtk.RESPONSE_OK:
            self.entryDir.set_text(fd.get_filename())
        fd.destroy()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def create_M_file() :
    p = os.path.join(NCAM_DIR, NGC_DIR, 'M123')
    with open(p, 'wb') as f :
        f.write('#!/usr/bin/env python\n# coding: utf-8\n')

        f.write("import gtk\nimport os\nimport pygtk\npygtk.require('2.0')\nfrom gtk import gdk\n\n")

        f.write("fname = '%s'\n" % os.path.join(NCAM_DIR, CATALOGS_DIR, 'no_skip_dlg.conf'))
        f.write('if os.path.isfile(fname) :\n    exit(0)\n\n')

        f.write("msg = '%s'\n" % _('Stop LinuxCNC program,
toggle the shown button,
then restart'))
        f.write("msg1 = '%s'\n" % _('Skip block not active'))
        f.write("icon_fname = '%s'\n\n" % os.path.join(NCAM_DIR, GRAPHICS_DIR, 'skip_block.png'))

        f.write('dlg = gtk.MessageDialog(parent = None, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, type = gtk.MESSAGE_WARNING, buttons = gtk.BUTTONS_NONE, message_format = msg1)\n\n')

        f.write("dlg.set_title('NativeCAM')\ndlg.format_secondary_markup(msg)\n\n")

        f.write('dlg.set_image(gtk.Image())\n')
        f.write('dlg.get_image().set_from_pixbuf(gdk.pixbuf_new_from_file_at_size(icon_fname, 80, 80))\n\n')

        f.write('cb = gtk.CheckButton(label = "%s")\n' % _("Do not show again"))
        f.write('dlg.get_content_area().pack_start(cb, True, True, 0)\n')
        f.write('dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK).grab_focus()\n\n')

        f.write('dlg.set_keep_above(True)\ndlg.show_all()\n\ndlg.run()\n')
        f.write("if cb.get_active() :\n    open(fname, 'w').close()\n")
        f.write('exit(0)\n')

    os.chmod(p, 0o755)
    mess_dlg(_('LinuxCNC needs to be restarted now'))
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def msg_inv(self, msg, msgid):
        msg = msg.replace('°', '°')
        print('\n%(feature_name)s : %(msg)s' % {'feature_name':self.get_name(), 'msg':msg})

        if (("ALL:msgid-0" in EXCL_MESSAGES) or
                ("%s:msgid-0" % (self.get_type()) in EXCL_MESSAGES) or
                (("%s:msgid-%d" % (self.get_type(), msgid)) in EXCL_MESSAGES)) :
            return

        # create dialog with image and checkbox
        dlg = gtk.MessageDialog(parent = None,
            flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            type = gtk.MESSAGE_WARNING,
            buttons = gtk.BUTTONS_NONE,
            message_format = self.get_name())
        dlg.set_title('NativeCAM')
        dlg.format_secondary_text(msg)
        img = gtk.Image()
        img.set_from_pixbuf(self.get_icon(add_dlg_icon_size))
        dlg.set_image(img)
        cb = gtk.CheckButton(label = _("Do not show again"))
        dlg.get_content_area().pack_start(cb, True, True, 0)
        dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK).grab_focus()

        dlg.set_keep_above(True)
        dlg.show_all()
        dlg.run()
        if cb.get_active() :
            GLOBAL_PREF.add_excluded_msg(self.get_type(), msgid)
        dlg.destroy()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_importXML(self, *arg) :
        filechooserdialog = gtk.FileChooserDialog(_("Import project"), None, \
                gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, \
                gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        try:
            filt = gtk.FileFilter()
            filt.set_name(_("NativeCAM projects"))
            filt.add_mime_type("text/xml")
            filt.add_pattern("*.xml")
            filechooserdialog.add_filter(filt)
            filt = gtk.FileFilter()
            filt.set_name(_("All files"))
            filt.add_pattern("*")
            filechooserdialog.add_filter(filt)
            filechooserdialog.set_current_folder(os.path.join(NCAM_DIR, CATALOGS_DIR, self.catalog_dir, PROJECTS_DIR))
            filechooserdialog.set_keep_above(True)
            filechooserdialog.set_transient_for(self.get_toplevel())

            if filechooserdialog.run() == gtk.RESPONSE_OK:
                fname = filechooserdialog.get_filename()
                try :
                    xml = self.update_features(etree.parse(fname).getroot())
                    self.import_xml(xml)
                    self.file_changed = True
                except etree.ParseError as err :
                    mess_dlg(err, _("Import project"))
        finally:
            filechooserdialog.destroy()

    # will update with new features version and keep the previous values
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_save_project(self, *arg) :
        global CURRENT_PROJECT

        filechooserdialog = gtk.FileChooserDialog(_("Save project as..."), None,
                gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, \
                gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        try:
            filt = gtk.FileFilter()
            filt.set_name(_("NativeCAM projects"))
            filt.add_mime_type("text/xml")
            filt.add_pattern("*.xml")
            filechooserdialog.add_filter(filt)
            d, fname = os.path.split(CURRENT_PROJECT)
            filechooserdialog.set_current_folder(os.path.join(NCAM_DIR, CATALOGS_DIR, self.catalog_dir, PROJECTS_DIR))
            filechooserdialog.set_current_name(fname)
            filechooserdialog.set_do_overwrite_confirmation(True)
            filechooserdialog.set_keep_above(True)
            filechooserdialog.set_transient_for(self.get_toplevel())

            if filechooserdialog.run() == gtk.RESPONSE_OK:
                xml = self.treestore_to_xml()
                CURRENT_PROJECT = filechooserdialog.get_filename()
                if CURRENT_PROJECT[-4] != ".xml" not in CURRENT_PROJECT :
                    CURRENT_PROJECT += ".xml"
                etree.ElementTree(xml).write(CURRENT_PROJECT, pretty_print = True)
                self.file_changed = False
        finally:
            self.display_proj_name()
            filechooserdialog.destroy()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self, title, message, default_text='', modal=True, mask=False):
        gtk.Dialog.__init__(self)
        self.set_title(title)
        self.connect("destroy", self.quit)
        self.connect("delete_event", self.quit)
        if modal:
            self.set_modal(True)
        box = gtk.VBox(spacing=10)
        box.set_border_width(10)
        self.vbox.pack_start(box)
        box.show()
        if message:
            label = gtk.Label(message)
            box.pack_start(label)
            label.show()
        self.entry = gtk.Entry()
        self.entry.set_text(default_text)
        self.entry.set_visibility(not mask)
        box.pack_start(self.entry)
        self.entry.show()
        self.entry.grab_focus()
        button = gtk.Button(stock=gtk.STOCK_OK)
        button.connect("clicked", self.click)
        self.entry.connect("activate", self.click)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()
        button.grab_default()
        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.connect("clicked", self.quit)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()
        self.ret = None
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def _do_manual_select(self, filename):
        radiolist = {}
        for drv, radio in directory.DRV_TO_RADIO.items():
            if not issubclass(radio, chirp_common.CloneModeRadio):
                continue
            radiolist["%s %s" % (radio.VENDOR, radio.MODEL)] = drv

        lab = gtk.Label("""<b><big>Unable to detect model!</big></b>

If you think that it is valid, you can select a radio model below to
force an open attempt. If selecting the model manually works, please
file a bug on the website and attach your image. If selecting the model
does not work, it is likely that you are trying to open some other type
of file.
""")

        lab.set_justify(gtk.JUSTIFY_FILL)
        lab.set_line_wrap(True)
        lab.set_use_markup(True)
        lab.show()
        choice = miscwidgets.make_choice(sorted(radiolist.keys()), False,
                                         sorted(radiolist.keys())[0])
        d = gtk.Dialog(title="Detection Failed",
                       buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
        d.vbox.pack_start(lab, 0, 0, 0)
        d.vbox.pack_start(choice, 0, 0, 0)
        d.vbox.set_spacing(5)
        choice.show()
        d.set_default_size(400, 200)
        # d.set_resizable(False)
        r = d.run()
        d.destroy()
        if r != gtk.RESPONSE_OK:
            return
        try:
            rc = directory.DRV_TO_RADIO[radiolist[choice.get_active_text()]]
            return rc(filename)
        except:
            return
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, settings=None, parent=None, title=_("Radio")):
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                   gtk.STOCK_OK, gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, title,
                            parent=parent,
                            flags=gtk.DIALOG_MODAL)
        self.__make_ui(settings)
        self.__cancel_button = self.add_button(gtk.STOCK_CANCEL,
                                               gtk.RESPONSE_CANCEL)
        self.__okay_button = self.add_button(gtk.STOCK_OK,
                                             gtk.RESPONSE_OK)
        self.__okay_button.grab_default()
        self.__okay_button.grab_focus()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        if "buttons" not in kwargs.keys():
            kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK,
                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)

        self.__fields = {}
        self.set_default_response(gtk.RESPONSE_OK)

        gtk.Dialog.__init__(self, **kwargs)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def save_shot(self):
        # create a new window
        dialog = gtk.Dialog("Manual ScreenShot",
                            None,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))

        dialog.set_size_request(400, 250)
        dialog.set_title("Manual ScreenShot Comment ECEL V2.0")

        table = gtk.Table(5,2,False)
        table.show()
        # create ip row
        ipLabel = gtk.Label("IP")
        ipEntry = gtk.Entry()
        table.attach(ipLabel, 0, 1, 0, 1)
        table.attach(ipEntry, 1, 2, 0, 1)
        ipLabel.show()
        ipEntry.show()

        # create Port row
        portLabel = gtk.Label("Port")
        portEntry = gtk.Entry()
        table.attach(portLabel, 0, 1, 1, 2)
        table.attach(portEntry, 1, 2, 1, 2)
        portLabel.show()
        portEntry.show()

        # create initial row
        initialLabel = gtk.Label("Initials")
        initialEntry = gtk.Entry()
        table.attach(initialLabel, 0, 1, 2, 3)
        table.attach(initialEntry, 1, 2, 2, 3)
        initialLabel.show()
        initialEntry.show()

        #create the comment entry field
        maxChar = 64
        commentEntry = gtk.Entry()
        commentEntry.set_max_length(maxChar)
        commentEntry.insert_text("Enter Comment")
        commentEntry.select_region(0, len(commentEntry.get_text()))
        table.attach(commentEntry, 0, 2, 3, 4)
        commentEntry.show()

        dialog.vbox.pack_start(table)

        response = dialog.run()

        self.ip_entry_text = ipEntry.get_text()
        self.port_entry_text = portEntry.get_text()
        self.initial_entry_text = initialEntry.get_text()
        self.comment_entry_text = commentEntry.get_text()
        dialog.hide_all()
        dialog.destroy()
        return response
项目:inkscapeMadeEasy    作者:fsmMLK    | 项目源码 | 文件源码
def cb_ok(self, widget, data=None):
            buf = self._text.get_buffer()
            self.text = buf.get_text(buf.get_start_iter(),
                                     buf.get_end_iter())
            if isinstance(self._preamble, gtk.FileChooser):
                self.preamble_file = self._preamble.get_filename()
                if not self.preamble_file:
                    self.preamble_file = ""
            else:
                self.preamble_file = self._preamble.get_text()

            if self.scale_factor is not None:
                self.scale_factor = self._scale_adj.get_value()

            try:
                self.callback(self.text, self.preamble_file, self.scale_factor)
            except StandardError, e:
                err_msg = traceback.format_exc()
                dlg = gtk.Dialog("Textext Error", self._window, 
                                 gtk.DIALOG_MODAL)
                dlg.set_default_size(600, 400)
                btn = dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE)
                btn.connect("clicked", lambda w, d=None: dlg.destroy())
                msg = gtk.Label()
                msg.set_markup("<b>Error occurred while converting text from Latex to SVG:</b>")

                txtw = gtk.ScrolledWindow()
                txtw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
                txtw.set_shadow_type(gtk.SHADOW_IN)
                txt = gtk.TextView()
                txt.set_editable(False)
                txt.get_buffer().set_text(err_msg)
                txtw.add(txt)

                dlg.vbox.pack_start(msg, expand=False, fill=True)
                dlg.vbox.pack_start(txtw, expand=True, fill=True)
                dlg.show_all()
                dlg.run()
                return False

            gtk.main_quit()
            return False
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_columns(self):
        eset = self.get_current_editorset()
        driver = directory.get_driver(eset.rthread.radio.__class__)
        radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR,
                                   eset.rthread.radio.MODEL,
                                   eset.rthread.radio.VARIANT)
        d = gtk.Dialog(title=_("Select Columns"),
                       parent=self,
                       buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))

        vbox = gtk.VBox()
        vbox.show()
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(vbox)
        sw.show()
        d.vbox.pack_start(sw, 1, 1, 1)
        d.set_size_request(-1, 300)
        d.set_resizable(False)

        labelstr = _("Visible columns for {radio}").format(radio=radio_name)
        label = gtk.Label(labelstr)
        label.show()
        vbox.pack_start(label)

        fields = []
        memedit = eset.get_current_editor()  # .editors["memedit"]
        unsupported = memedit.get_unsupported_columns()
        for colspec in memedit.cols:
            if colspec[0].startswith("_"):
                continue
            elif colspec[0] in unsupported:
                continue
            label = colspec[0]
            visible = memedit.get_column_visible(memedit.col(label))
            widget = gtk.CheckButton(label)
            widget.set_active(visible)
            fields.append(widget)
            vbox.pack_start(widget, 1, 1, 1)
            widget.show()

        res = d.run()
        selected_columns = []
        if res == gtk.RESPONSE_OK:
            for widget in fields:
                colnum = memedit.col(widget.get_label())
                memedit.set_column_visible(colnum, widget.get_active())
                if widget.get_active():
                    selected_columns.append(widget.get_label())

        d.destroy()

        CONF.set(driver, ",".join(selected_columns), "memedit_columns")
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, src_radio, dst_radio, parent=None):
        gtk.Dialog.__init__(self,
                            buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                     gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
                            title=self.TITLE,
                            parent=parent)

        self.col_import = 0
        self.col_nloc = 1
        self.col_oloc = 2
        self.col_name = 3
        self.col_freq = 4
        self.col_comm = 5
        self.col_okay = 6
        self.col_tmsg = 7

        self.caps = {
            self.col_import:  self.ACTION,
            self.col_nloc:    _("To"),
            self.col_oloc:    _("From"),
            self.col_name:    _("Name"),
            self.col_freq:    _("Frequency"),
            self.col_comm:    _("Comment"),
            }

        self.tips = {
            self.col_nloc:  _("Location memory will be imported into"),
            self.col_oloc:  _("Location of memory in the file being imported"),
            }

        self.types = {
            self.col_import:  gobject.TYPE_BOOLEAN,
            self.col_oloc:    gobject.TYPE_INT,
            self.col_nloc:    gobject.TYPE_INT,
            self.col_name:    gobject.TYPE_STRING,
            self.col_freq:    gobject.TYPE_STRING,
            self.col_comm:    gobject.TYPE_STRING,
            self.col_okay:    gobject.TYPE_BOOLEAN,
            self.col_tmsg:    gobject.TYPE_STRING,
            }

        self.src_radio = src_radio
        self.dst_radio = dst_radio

        self.used_list = []
        self.not_used_list = []

        self.build_ui()
        self.set_default_size(600, 400)

        self.ww = WaitWindow(_("Preparing memory list..."), parent=parent)
        self.ww.show()
        self.ww.grind()

        self.populate_list()

        self.ww.hide()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def show_diff_blob(title, result):
    d = gtk.Dialog(title=title,
                   buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
    b = gtk.TextBuffer()

    tags = b.get_tag_table()
    for color in ["red", "blue", "green", "grey"]:
        tag = gtk.TextTag(color)
        tag.set_property("foreground", color)
        tags.add(tag)
    tag = gtk.TextTag("bold")
    tag.set_property("weight", pango.WEIGHT_BOLD)
    tags.add(tag)

    try:
        fontsize = CONF.get_int("diff_fontsize", "developer")
    except Exception:
        fontsize = 11
    if fontsize < 4 or fontsize > 144:
        LOG.info("Unsupported diff_fontsize %i. Using 11." % fontsize)
        fontsize = 11

    lines = result.split(os.linesep)
    for line in lines:
        if line.startswith("-"):
            tags = ("red", "bold")
        elif line.startswith("+"):
            tags = ("blue", "bold")
        else:
            tags = ()
        b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags)
    v = gtk.TextView(b)
    fontdesc = pango.FontDescription("Courier %i" % fontsize)
    v.modify_font(fontdesc)
    v.set_editable(False)
    v.show()
    s = gtk.ScrolledWindow()
    s.add(v)
    s.show()
    d.vbox.pack_start(s, 1, 1, 1)
    d.set_size_request(600, 400)
    d.run()
    d.destroy()