Python gtk 模块,STOCK_OPEN 实例源码

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

项目: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()
项目: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()
项目: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_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
项目: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 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")
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _setup_actions(self):
        self._add_stock_action("Quit", stock=gtk.STOCK_QUIT)
        self._add_stock_action("Preferences", stock=gtk.STOCK_PREFERENCES)
        self._add_stock_action("Open", stock=gtk.STOCK_OPEN)
        self._add_stock_action("Play", stock=gtk.STOCK_MEDIA_PLAY)
        self._add_stock_action("Stop", stock=gtk.STOCK_MEDIA_STOP)


        act = gtk.ToggleAction("Pause", None, None, gtk.STOCK_MEDIA_PAUSE)
        self.action_group.add_action_with_accel(act, None)
        act.set_accel_group(self.accel_group)
        act.connect_accelerator()
        self.actions["Pause"] = act
    # _setup_actions()
项目: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()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def change_poster_select_file(self, number, handler = update_image):
    filename = gutils.file_chooser(_("Select image"),
                                   action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                   buttons=(gtk.STOCK_CANCEL,
                                            gtk.RESPONSE_CANCEL,
                                            gtk.STOCK_OPEN,
                                            gtk.RESPONSE_OK),
                                   name='',
                                   folder=self.locations['desktop'],
                                   picture=True)
    if filename and filename[0]:
        filename = filename[0].decode('UTF-8')
        if handler:
            return handler(self, number, filename)
    return False
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def cover_image(self,number):
    filename = gutils.file_chooser(_("Select image"), \
        action=gtk.FILE_CHOOSER_ACTION_OPEN, \
        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, \
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    if filename[0]:
        cover_image_process(self, filename[0], number)
项目:python-3-for-absolute-begs    作者:Apress    | 项目源码 | 文件源码
def create_treelist(self):
        """create_treelist

        Create list of options
        """ 
        # Add some messages to the window
        self.liststore = gtk.ListStore(str,str,'gboolean')
        # we'll add some data now
        self.liststore.append(['Kernel', gtk.STOCK_OPEN, True])
        self.liststore.append(['CPU', gtk.STOCK_OPEN, True])
        self.liststore.append(['RAM', gtk.STOCK_OPEN, True])
        self.liststore.append(['Sound Modules', gtk.STOCK_OPEN, True])
        self.liststore.append(['Sound Devices', gtk.STOCK_OPEN, True])
        self.liststore.append(['Asound', gtk.STOCK_OPEN, True])

        # create the TreeViewColumn to display the data
        self.tvcolumn = gtk.TreeViewColumn('Categories')

        # Append liststore model to treeview
        self.treeview1.set_model(model=self.liststore)   

        # add tvcolumn to treeview
        self.treeview1.append_column(self.tvcolumn)

        # create a CellRendererText to render the data
        self.cell = gtk.CellRendererText()
        self.cell0 = gtk.CellRendererPixbuf()

        # add the cell to the tvcolumn and allow it to expand
        self.tvcolumn.pack_start(self.cell0, True)
        self.tvcolumn.pack_start(self.cell, True)

        # set the cell "text" attribute to column 0 - retrieve text
        # from that column in treestore
        self.tvcolumn.set_cell_data_func(self.cell0, self.make_pixbuf)
        self.tvcolumn.add_attribute(self.cell, 'text', 0)
        return
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def gui_open_file(self, start_dir=None, types=[]):
        """Prompt the user to pick a file to open"""
        import gtk

        if not start_dir:
            start_dir = self._last_dir

        dlg = gtk.FileChooserDialog("Select a file to open",
                                    None,
                                    gtk.FILE_CHOOSER_ACTION_OPEN,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                     gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        if start_dir and os.path.isdir(start_dir):
            dlg.set_current_folder(start_dir)

        for desc, spec in types:
            ff = gtk.FileFilter()
            ff.set_name(desc)
            ff.add_pattern(spec)
            dlg.add_filter(ff)

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

        if res == gtk.RESPONSE_OK:
            self._last_dir = os.path.dirname(fname)
            return fname
        else:
            return None
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_preferences(self):
        self.player_path = gtk.Entry()
        self.player_params = gtk.Entry()

        self.player_ao_model = gtk.ListStore(str)
        self.player_ao = gtk.ComboBox(self.player_ao_model)
        cell = gtk.CellRendererText()
        self.player_ao.pack_start(cell, True)
        self.player_ao.add_attribute(cell, "text", 0)

        for t in ("esd", "gst"):
            self.player_ao_model.append((t,))


        self.player_acodec_model = gtk.ListStore(str)
        self.player_acodec = gtk.ComboBox(self.player_acodec_model)
        cell = gtk.CellRendererText()
        self.player_acodec.pack_start(cell, True)
        self.player_acodec.add_attribute(cell, "text", 0)

        for t in ("ffmpeg", "dspmp3"):
            self.player_acodec_model.append((t,))



        hbox = gtk.HBox(homogeneous=False, spacing=2)
        btn = gtk.Button(stock=gtk.STOCK_OPEN)
        hbox.pack_start(self.player_path, fill=True, expand=True)
        hbox.pack_start(btn, fill=True, expand=False)
        btn.connect("clicked", self._choose_mplayer_path)

        hbox.show_all()

        wids = ("MPlayer",
                ("Path:", hbox),
                ("Parameters:", self.player_params),
                ("Audio Output:", self.player_ao),
                ("Audio Codec:", self.player_acodec),
                )

        self.gui_preferences = wids
    # setup_gui_preferences()
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def __init__(self):
        gtk.Window.__init__(self)

        self.graph = Graph()

        window = self

        window.set_title('Dot Viewer')
        window.set_default_size(512, 512)
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # Create actions
        actiongroup.add_actions((
            ('Open', gtk.STOCK_OPEN, None, None, None, self.on_open),
            ('Reload', gtk.STOCK_REFRESH, None, None, None, self.on_reload),
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, None, self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget.on_zoom_100),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        # Create a Toolbar
        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)

        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        self.show_all()
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def __init__(self):
        gtk.Window.__init__(self)

        self.graph = Graph()

        window = self

        window.set_title('Dot Viewer')
        window.set_default_size(512, 512)
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # Create actions
        actiongroup.add_actions((
            ('Open', gtk.STOCK_OPEN, None, None, None, self.on_open),
            ('Reload', gtk.STOCK_REFRESH, None, None, None, self.on_reload),
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, None, self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget.on_zoom_100),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        # Create a Toolbar
        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)

        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        self.show_all()