Python gtk 模块,RESPONSE_OK 实例源码

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

项目:flashplayer-pygtk    作者:nanpuyue    | 项目源码 | 文件源码
def on_open_clicked(widget, window, box):
    dialog=gtk.FileChooserDialog(title="?? Flash ??", action=gtk.FILE_CHOOSER_ACTION_OPEN,
        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    swf_filter=gtk.FileFilter()
    swf_filter.set_name("Flash ??(*.swf)")
    swf_filter.add_pattern("*.[Ss][Ww][Ff]")
    dialog.add_filter(swf_filter)
    response = dialog.run()

    if response == gtk.RESPONSE_OK:
        filename = dialog.get_filename()
        dialog.destroy()
        window.remove(box)
        play_args = pre_play(filename)
        display_html(window, play_args)

    dialog.destroy()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def importFile(self, *args):
        fn = gtk.FileChooserDialog(title="Import File",
                                   action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
        _filter = gtk.FileFilter()
        _filter.set_name("C++ Files")
        _filter.add_pattern("*.cpp")
        _filter.add_pattern("*.h")
        fn.add_filter(_filter)
        _filter = gtk.FileFilter()
        _filter.set_name("All Files")
        _filter.add_pattern("*")
        fn.add_filter(_filter)
        fn.show()

        resp = fn.run()
        if resp == gtk.RESPONSE_OK:
            text = open(fn.get_filename()).read()

            self.addNotebookPage(os.path.basename(fn.get_filename()), text)

        fn.destroy()
项目:colorize    作者:BruXy    | 项目源码 | 文件源码
def gui_ask_for_api():
    """Gtk dialog for API key insert."""
    message = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_OK_CANCEL)
    message.set_markup(colorize.MSG_ASK_API.replace(colorize.URL,"<u>" + colorize.URL +"</u>"))

    entry = gtk.Entry(max=64)
    entry.set_text("Enter your API key")
    entry.show()
    message.vbox.pack_end(entry)
    entry.connect("activate", lambda _: d.response(gtk.RESPONSE_OK))
    message.set_default_response(gtk.RESPONSE_OK)
    message.run()

    api_key = entry.get_text().decode('utf8')
    fp = open(colorize.HOME + colorize.API_KEY_FILE, 'w')
    fp.write("YOUR_API_KEY={0}{1}".format(api_key, os.linesep))
    fp.close()

    # process buttong click immediately
    message.destroy()
    while gtk.events_pending():
        gtk.main_iteration()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        if 'default_value' in kwargs:
            default_value = kwargs['default_value']
            del kwargs['default_value']
        else:
            default_value = ''

        query = args[-1]
        args = args[:-1]

        super(EntryDialog, self).__init__(*args, **kwargs)

        label = gtk.Label(query)
        self.vbox.pack_start(label, True, True)

        entry = gtk.Entry()
        entry.set_text(str(default_value))
        entry.connect("activate",
                      lambda ent, dlg, resp: dlg.response(resp),
                      self, gtk.RESPONSE_OK)
        self.vbox.pack_end(entry, True, True, 0)
        self.vbox.show_all()
        self.entry = entry
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(self.last_open_dir)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.last_open_dir = chooser.get_current_folder()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy()
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def keep_list_dialog(self, w):

        chooser = gtk.FileChooserDialog('Open..', None, gtk.FILE_CHOOSER_ACTION_OPEN,
                                       (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        chooser.set_select_multiple(True)
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_size_request(640,480)

        filter = gtk.FileFilter()
        filter.set_name("All Files")
        filter.add_pattern("*")
        chooser.add_filter(filter)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            self.keep_list = chooser.get_filenames()

        chooser.destroy()

        if self.keep_list is not None:
            Thread(target=self._announce_keep_list).start()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def changeAllFonts(self, widget):
        """Changes all fonts at once."""
        dialog = gtk.FontSelectionDialog("Select Font")

        dialog.set_font_name(self.defaults["font"])

        if dialog.run() == gtk.RESPONSE_OK:
            newFont = dialog.get_font_name()

            self.clock1FontButton.set_font_name(newFont)
            self.clock2FontButton.set_font_name(newFont)
            self.bat1FontButton.set_font_name(newFont)
            self.bat2FontButton.set_font_name(newFont)
            self.fontButton.set_font_name(newFont)

        dialog.destroy()

        self.generateConfig()
        self.changeOccurred()
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def connectionLost(self, reason):
        if len(self.buffer) == 0:
             dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "An error occurred; file could not be retrieved.")
             dialog.run()
             dialog.destroy()
             return

        fd = gtk.FileChooserDialog(title=None, action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
        fd.set_default_response(gtk.RESPONSE_OK)
        fd.set_current_name(self.filename)
        response = fd.run()
        if response == gtk.RESPONSE_OK:
            destfilename = fd.get_filename()
            f = open(destfilename, 'w')
            f.write(self.buffer)
            f.close()
        fd.destroy()
项目: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()
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy()
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(self.last_open_dir)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.last_open_dir = chooser.get_current_folder()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy()
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(self.last_open_dir)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            self.last_open_dir = chooser.get_current_folder()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy()
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def on_open(self, action):
        chooser = gtk.FileChooserDialog(title="Open dot File",
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_CANCEL,
                                                 gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN,
                                                 gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        filter = gtk.FileFilter()
        filter.set_name("Graphviz dot files")
        filter.add_pattern("*.dot")
        chooser.add_filter(filter)
        filter = gtk.FileFilter()
        filter.set_name("All files")
        filter.add_pattern("*")
        chooser.add_filter(filter)
        if chooser.run() == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            chooser.destroy()
            self.open_file(filename)
        else:
            chooser.destroy()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def show_font_dialog(parent, title, button):
    if not hasattr(parent, 'dlgFont'):
        parent.dlgFont = None

    if parent.dlgFont == None:
        parent.dlgFont = gtk.FontSelectionDialog(title)
    fontsel = parent.dlgFont.fontsel
    fontsel.set_font_name(button.selected_font.to_string())    

    response = parent.dlgFont.run()

    if response == gtk.RESPONSE_OK:        
        button.selected_font = pango.FontDescription(fontsel.get_font_name())        
        button.set_label(button.selected_font.to_string())
        button.get_child().modify_font(button.selected_font)
    parent.dlgFont.hide()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def show_open_dialog(parent, title, action):        
    dlg = gtk.FileChooserDialog(title=title, parent=parent, action=action)
    dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)

    dlg.add_button(gtk.STOCK_SAVE if action==gtk.FILE_CHOOSER_ACTION_SAVE else gtk.STOCK_OPEN, gtk.RESPONSE_OK)        
    dlg.set_do_overwrite_confirmation(True)        
    if not hasattr(parent,'lastPath'):
        parent.lastPath = os.path.expanduser("~")
    dlg.set_current_folder( parent.lastPath )

    if dlg.run() == gtk.RESPONSE_OK:
        filename = dlg.get_filename()
        parent.lastPath = os.path.dirname(filename)
    else:
        filename = None
    dlg.destroy()
    return filename
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def show_save_buffer(self, terminal):        
        dlg = gtk.FileChooserDialog(title=_("Guardar como"), parent=self.wMain, action=gtk.FILE_CHOOSER_ACTION_SAVE)
        dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        dlg.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_OK)        
        dlg.set_do_overwrite_confirmation(True)
        dlg.set_current_name( os.path.basename("gcm-buffer-%s.txt" % (time.strftime("%Y%m%d%H%M%S")) ))
        if not hasattr(self,'lastPath'):
            self.lastPath = os.path.expanduser("~")
        dlg.set_current_folder( self.lastPath )

        if dlg.run() == gtk.RESPONSE_OK:
            filename = dlg.get_filename()
            self.lastPath = os.path.dirname(filename)            

            try:              
                buff = terminal.get_text_range(0, 0, terminal.get_property('scrollback-lines')-1, terminal.get_column_count()-1, lambda *args: True, None, None ).strip()                
                f = open(filename, "w")
                f.write(buff)
                f.close()
            except:                
                dlg.destroy()
                msgbox("%s: %s" % (_("No se puede abrir archivo para escritura"), filename) )
                return

        dlg.destroy()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_btnDel_clicked(self, widget, *args):
        if self.treeServers.get_selection().get_selected()[1]!=None:
            if not self.treeModel.iter_has_child(self.treeServers.get_selection().get_selected()[1]):
                #Eliminar solo el nodo
                name = self.treeModel.get_value(self.treeServers.get_selection().get_selected()[1],0)
                if msgconfirm("%s [%s]?" % (_("Confirma que desea eliminar el host"), name) ) == gtk.RESPONSE_OK:
                    host = self.treeModel.get_value(self.treeServers.get_selection().get_selected()[1],1)
                    groups[host.group].remove(host)
                    self.updateTree()
            else:                
                #Eliminar todo el grupo                
                group = self.get_group(self.treeModel.iter_children(self.treeServers.get_selection().get_selected()[1]))
                if msgconfirm("%s [%s]?" % (_("Confirma que desea eliminar todos los hosts del grupo"), group) ) == gtk.RESPONSE_OK:                                
                    try:
                        del groups[group]
                    except:
                        pass
                    for h in dict(groups):
                        if h.startswith(group+'/'):
                            del groups[h]
                    self.updateTree()
        self.writeConfig()                    
    #-- Wmain.on_btnDel_clicked }

    #-- Wmain.on_btnHSplit_clicked {
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def edit_memory(self, memory, locations):
        if len(locations) > 1:
            dlg = memdetail.MultiMemoryDetailEditor(self._features, memory)
        else:
            dlg = memdetail.MemoryDetailEditor(self._features, memory)
        r = dlg.run()
        if r == gtk.RESPONSE_OK:
            self.need_refresh = True
            mem = dlg.get_memory()
            if len(locations) > 1:
                self._apply_multiple(memory, dlg.get_fields(), locations)
            else:
                if "name" not in mem.immutable:
                    mem.name = self.rthread.radio.filter_name(mem.name)
                job = common.RadioJob(self._set_memory_cb, "set_memory", mem)
                job.set_desc(_("Writing memory {number}").format(
                        number=mem.number))
                self.rthread.submit(job)
        dlg.destroy()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, rthread, parent=None):
        gtk.Dialog.__init__(self,
                            title=_("Shift"),
                            buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK))

        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)

        self.rthread = rthread

        self.__prog = gtk.ProgressBar()
        self.__prog.show()

        self.__labl = gtk.Label("")
        self.__labl.show()

        self.vbox.pack_start(self.__prog, 1, 1, 1)
        self.vbox.pack_start(self.__labl, 0, 0, 0)

        self.quiet = False

        self.thread = None
项目: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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, choices, **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.label.show()

        try:
            default = choices[0]
        except IndexError:
            default = None

        self.choice = make_choice(sorted(choices), self.editable, default)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.choice, 1, 1, 0)
        self.choice.show()

        self.set_default_response(gtk.RESPONSE_OK)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def gui_select_dir(self, start_dir=None):
        """Prompt the user to pick a directory"""
        import gtk

        if not start_dir:
            start_dir = self._last_dir

        dlg = gtk.FileChooserDialog("Choose folder",
                                    None,
                                    gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                     gtk.STOCK_SAVE, gtk.RESPONSE_OK))
        if start_dir and os.path.isdir(start_dir):
            dlg.set_current_folder(start_dir)

        res = dlg.run()
        fname = dlg.get_filename()
        dlg.destroy()

        if res == gtk.RESPONSE_OK and os.path.isdir(fname):
            self._last_dir = fname
            return fname
        else:
            return None
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def get_mem_range(self):
        d = inputdialog.FieldDialog(title="Select Memory Range")

        limit = RADIOS[self.rtype].mem_upper_limit

        la = gtk.Adjustment(0, 0, limit, 1, 10, 10)
        d.add_field("Start", gtk.SpinButton(la, 0))

        ua = gtk.Adjustment(100, 0, limit, 1, 10, 10)
        d.add_field("End", gtk.SpinButton(ua, 0))

        r = d.run()
        low = int(la.get_value())
        high = int(ua.get_value())
        d.destroy()

        if r == gtk.RESPONSE_OK:
            return low, high
        else:
            return None, None
项目:robik    作者:RecunchoMaker    | 项目源码 | 文件源码
def showSettings(self):
        result = gtk.RESPONSE_CANCEL
        settings = Settings()

        for w in settings:
            print w
            widget = self.view.wTree.get_widget(w)
            widget.set_value(settings[w])
            print 'on_'+w+'_change_value'
            #widget.connect('on_'+w+'_change_value', self.change_setting)            
            widget.connect('change_value', self.change_setting)            
        print "Muestro"

        #run the dialog and store the response
        result = self.view.dlg_settings.run()
        if (result==gtk.RESPONSE_OK):
            #get the value of the entry fields
            print "grabaria la configuracion"
            self.settings.save()

        elif (result==gtk.RESPONSE_CANCEL):
            print "cancelo"
            self.settings.load()
        else:
            print "Result = ",result


        #we are done with the dialog, destroy it
        self.view.dlg_settings.hide()

        #return the result
        return result
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def show_error_msg(self, msg):
    errdialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, str(msg))
    errdialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
    errdialog.show_all()
    response_err = errdialog.run()
    if response_err == gtk.RESPONSE_OK:
      errdialog.hide()
      errdialog.destroy()

  # ??????? ??????? ??????????? ???? ? ??????????
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def info(self, msg):
    infodialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, str(msg))
    infodialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
    infodialog.show_all()
    response_info= infodialog.run()
    if response_info == gtk.RESPONSE_OK:
      infodialog.hide()
      infodialog.destroy()

  # ??????? ??????? ??????????? ???? "? ?????????"
项目: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

  # ??? ??????? ???????????? ?????????? ?????? ???????
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def MessageBox(self,parent,text,type=gtk.MESSAGE_INFO):
                message = gtk.MessageDialog(parent,0,type,gtk.BUTTONS_OK)
        message.set_markup(text)    
        response = message.run()
        if response == gtk.RESPONSE_OK:
            message.destroy()


    # Get Password
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def _on_loginDialog_response(self, widget, response):
        handlers = {gtk.RESPONSE_NONE: self._windowClosed,
                   gtk.RESPONSE_DELETE_EVENT: self._windowClosed,
                   gtk.RESPONSE_OK: self._doLogin,
                   gtk.RESPONSE_CANCEL: self._cancelled}
        handler = handlers.get(response)
        if handler is not None:
            handler()
        else:
            log.msg("Unexpected dialog response %r from %s" % (response,
                                                               widget))
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def _get_export_file_name(self):
        sel = gtk.FileChooserDialog("Save...", self.canvas.get_toplevel(),
                                    gtk.FILE_CHOOSER_ACTION_SAVE,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                     gtk.STOCK_SAVE, gtk.RESPONSE_OK))
        sel.set_default_response(gtk.RESPONSE_OK)
        sel.set_local_only(True)
        sel.set_do_overwrite_confirmation(True)
        sel.set_current_name("Unnamed.pdf")

        filter = gtk.FileFilter()
        filter.set_name("Embedded PostScript")
        filter.add_mime_type("image/x-eps")
        sel.add_filter(filter)

        filter = gtk.FileFilter()
        filter.set_name("Portable Document Graphics")
        filter.add_mime_type("application/pdf")
        sel.add_filter(filter)

        filter = gtk.FileFilter()
        filter.set_name("Scalable Vector Graphics")
        filter.add_mime_type("image/svg+xml")
        sel.add_filter(filter)

        resp = sel.run()
        if resp != gtk.RESPONSE_OK:
            sel.destroy()
            return None

        file_name = sel.get_filename()
        sel.destroy()
        return file_name
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def select_folder(self, event):
        dialog_select_folder = gtk.FileChooserDialog()
        dialog_select_folder.set_title("Export To")
        dialog_select_folder.set_transient_for(self)
        dialog_select_folder.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        dialog_select_folder.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
        dialog_select_folder.set_current_folder(self.entry_selected_folder.get_text())

        response = dialog_select_folder.run()
        if response == gtk.RESPONSE_OK:
            self.entry_selected_folder.set_text(dialog_select_folder.get_filename())

        dialog_select_folder.destroy()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def select_file(self, event, entry_filepath):
        dialog_select_folder = gtk.FileChooserDialog()
        dialog_select_folder.set_title("Select File")
        dialog_select_folder.set_transient_for(self)
        dialog_select_folder.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
        dialog_select_folder.set_filename(entry_filepath.get_text())

        response = dialog_select_folder.run()
        if response == gtk.RESPONSE_OK:
            entry_filepath.set_text(dialog_select_folder.get_filename())

        dialog_select_folder.destroy()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def select_folder(self, event, entry_filepath):
        dialog_select_folder = gtk.FileChooserDialog()
        dialog_select_folder.set_title("Select Folder")
        dialog_select_folder.set_transient_for(self)
        dialog_select_folder.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        dialog_select_folder.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
        dialog_select_folder.set_current_folder(entry_filepath.get_text())

        response = dialog_select_folder.run()
        if response == gtk.RESPONSE_OK:
            entry_filepath.set_text(dialog_select_folder.get_filename())

        dialog_select_folder.destroy()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def run(self):
        result = super(EntryDialog, self).run()
        if result == gtk.RESPONSE_OK:
            text = self.entry.get_text()
        else:
            text = None
        return text
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def run(self):
        result = super(FolderDialog, self).run()
        if result == gtk.RESPONSE_OK:
            text = self.fcb1.get_filename()
        else:
            text = None
        return text
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def openFile(self, *args):
        if (not self.getModified()) or self.ask("There are unsaved files.\nContinue?"):
            fn = gtk.FileChooserDialog(title="Save File",
                                       action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                       buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
            _filter = gtk.FileFilter()
            _filter.set_name("Micro:Pi Files")
            _filter.add_pattern("*.%s" % SETTINGS['fileExtention'])
            fn.add_filter(_filter)
            _filter = gtk.FileFilter()
            _filter.set_name("All Files")
            _filter.add_pattern("*")
            fn.add_filter(_filter)
            fn.show()

            resp = fn.run()
            if resp == gtk.RESPONSE_OK:
                try:
                    #text = open(fn.get_filename()).read()
                    #try:
                        #d = text.replace("\n", "")
                        #d = base64.b64decode(d)
                        #data = pickle.loads(d)
                    #except:
                        #data = pickle.loads(text)
                    data = self.loadFilesFromFile(fn.get_filename())

                    mw = MainWin(data)
                    yes = True
                    mw.saveLocation = fn.get_filename()
                    mw.setSaved()
                    OPENWINDOWS.append(mw)
                except Exception as e:
                    yes = False
            fn.destroy()
            if resp == gtk.RESPONSE_OK and not yes:
                self.message("File is not a Micro:Pi File")
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def saveAs(self, *args):
        self.saveInternalOpenFiles()

        fn = gtk.FileChooserDialog(title="Save File As",
                                   action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
        _filter = gtk.FileFilter()
        _filter.set_name("Micro:Pi Files")
        _filter.add_pattern("*.%s" % SETTINGS['fileExtention'])
        fn.add_filter(_filter)
        _filter = gtk.FileFilter()
        _filter.set_name("All Files")
        _filter.add_pattern("*")
        fn.add_filter(_filter)
        fn.show()

        resp = fn.run()

        #files = []
        #for f in self.notebook:
            #fin = self.notebook.get_tab_label(f).get_children()[0].get_label()
            #tb = f.get_child().get_buffer()
            #txt = tb.get_text(*tb.get_bounds())
            #files.append([fin, txt])
        #data = base64.b64encode(pickle.dumps(files))
        #data = "".join(data[i:i+64]+"\n" for i in xrange(0, len(data), 64))

        if resp == gtk.RESPONSE_OK:
            fp = fn.get_filename()
            if fp[-(len(SETTINGS["fileExtention"])+1):] != "." + SETTINGS["fileExtention"]:
                fp += "." + SETTINGS["fileExtention"]
            #open(fp, 'w').write(data)
            self.saveLocation = fp
            self.save()
            self.setSaved()
        fn.destroy()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def run(self):
        result = super(SettingsDialog, self).run()
        if result == gtk.RESPONSE_OK:
            SETTINGS["quickstart"] = self.s1.get_active()
            SETTINGS["theme"] = "dark" if self.rb2.get_active() else "light"
            SETTINGS["mbitLocation"] = self.fcb1.get_filename() if self.fcb1.get_filename() else SETTINGS["mbitLocation"]
            saveSettings()

            if SETTINGS['theme'] == 'dark':
                colour = gtk.gdk.color_parse(DARKCOL)
            else:
                colour = gtk.gdk.color_parse(LIGHTCOL)

            for w in OPENWINDOWS:
                w.window.modify_bg(gtk.STATE_NORMAL, colour)

                mgr = gtkSourceView.style_scheme_manager_get_default()
                w.style_scheme = mgr.get_scheme('tango' if SETTINGS['theme']=='light' else 'oblivion')
                for f in w.notebook:
                    f.get_child().props.buffer.set_style_scheme(w.style_scheme)
                w.serialConsole.window.modify_bg(gtk.STATE_NORMAL, colour)
                if SENDIMAGE: w.serialConsole.imageCreator.window.modify_bg(gtk.STATE_NORMAL, colour)
                w.serialConsole.consoleBody.props.buffer.set_style_scheme(w.style_scheme)
                w.consoleBody.props.buffer.set_style_scheme(w.style_scheme)

        self.destroy()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def get_url_from_chooser(self):
        self.gui_url_chooser.set_uri(self.preferences["uri"])
        self.gui_url_chooser.show()
        r = self.gui_url_chooser.run()
        self.gui_url_chooser.hide()

        if r == gtk.RESPONSE_OK:
            t = self.gui_url_chooser.get_uri()
            self.preferences["uri"] = t
            return t
        else:
            self.gui_url_chooser.set_uri(self.preferences["uri"])
            return None
    # get_url_from_chooser()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def _on_loginDialog_response(self, widget, response):
        handlers = {gtk.RESPONSE_NONE: self._windowClosed,
                   gtk.RESPONSE_DELETE_EVENT: self._windowClosed,
                   gtk.RESPONSE_OK: self._doLogin,
                   gtk.RESPONSE_CANCEL: self._cancelled}
        handler = handlers.get(response)
        if handler is not None:
            handler()
        else:
            log.msg("Unexpected dialog response %r from %s" % (response,
                                                               widget))
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def openFile(self, widget=None, default=False):
        """Reads from a config file. If default=True, open the tint2 default config."""
        self.new()

        if not default:
            chooser = gtk.FileChooserDialog("Open Config File", self, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
            chooser.set_default_response(gtk.RESPONSE_OK)

            if self.curDir != None:
                chooser.set_current_folder(self.curDir)

            chooserFilter = gtk.FileFilter()
            chooserFilter.set_name("All files")
            chooserFilter.add_pattern("*")
            chooser.add_filter(chooserFilter)
            chooser.show()

            response = chooser.run()

            if response == gtk.RESPONSE_OK:
                self.filename = chooser.get_filename()
                self.curDir = os.path.dirname(self.filename)
            else:
                chooser.destroy()
                return

            chooser.destroy()
        else:
            self.filename = os.path.expandvars("$HOME/.config/tint2/tint2rc")
            self.curDir = os.path.expandvars("$HOME/.config/tint2")

        self.readTint2Config()
        self.generateConfig()
        self.updateStatusBar()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def saveAs(self, widget=None, event=None):
        """Prompts the user to select a file and then saves the generated config file."""
        self.generateConfig()

        chooser = gtk.FileChooserDialog("Save Config File As...", self, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)

        if self.curDir != None:
            chooser.set_current_folder(self.curDir)

        chooserFilter = gtk.FileFilter()
        chooserFilter.set_name("All files")
        chooserFilter.add_pattern("*")
        chooser.add_filter(chooserFilter)
        chooser.show()

        response = chooser.run()

        if response == gtk.RESPONSE_OK:
            self.filename = chooser.get_filename()

            if os.path.exists(self.filename):
                overwrite = confirmDialog(self, "This file already exists. Overwrite this file?")

                if overwrite == gtk.RESPONSE_YES:
                    self.writeFile()
                    chooser.destroy()
                    return True
                else:
                    self.filename = None
                    chooser.destroy()
                    return False
            else:
                self.writeFile()
                chooser.destroy()
                return True
        else:
            self.filename = None
            chooser.destroy()
            return False
项目: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,&#10;toggle the shown button,&#10;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 key_press_event(self, win, event):
        if event.type == gdk.KEY_PRESS:
            k_name = gdk.keyval_name(event.keyval)
#            print(k_name)
            if ((k_name >= 'KP_0' and k_name <= 'KP_9') or \
                    (k_name >= '0' and k_name <= '9')) :
                self.input(None, k_name[-1])
            elif k_name in ['KP_Decimal', 'period', 'comma', 'KP_Separator'] :
                if (self.data_type == 'float'):
                    self.input(None, decimal_point)
            elif k_name in ['KP_Divide', 'slash'] :
                self.input(None, '/')
            elif k_name in ['KP_Multiply', 'asterisk'] :
                self.input(None, '*')
            elif k_name in ['parenleft', 'parenright'] :
                self.input(None, '()')
            elif k_name == 'F2' :
                self.input(None, 'F2')
            elif k_name in ['C', 'c'] :
                self.input(None, 'C')
            elif k_name == 'equal' :
                self.input(None, '=')
            elif k_name in ['KP_Subtract', 'minus'] :
                self.input(None, '-')
            elif k_name in ['KP_Add', 'plus'] :
                self.input(None, '+')
            elif k_name == 'BackSpace' :
                self.input(None, 'BS')
            elif k_name in ['KP_Enter', 'Return', 'space']:
                self.dlg.response(gtk.RESPONSE_OK)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def ok(self, btn):
        self.convert_units = False
        self.dlg.response(gtk.RESPONSE_OK)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def focus_out(self, widget, event):
        if vkb_cancel_on_out:
            self.dlg.response(gtk.RESPONSE_CANCEL)
        else :
            self.dlg.response(gtk.RESPONSE_OK)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def list_btn_released(self, widget, event):
        self.list_window.response(gtk.RESPONSE_OK)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def string_edit_focus_out(self, widget, event):
        self.stringedit_window.response(gtk.RESPONSE_OK)