當前位置: 首頁>>代碼示例>>Python>>正文


Python gtk.STOCK_OPEN屬性代碼示例

本文整理匯總了Python中gtk.STOCK_OPEN屬性的典型用法代碼示例。如果您正苦於以下問題:Python gtk.STOCK_OPEN屬性的具體用法?Python gtk.STOCK_OPEN怎麽用?Python gtk.STOCK_OPEN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在gtk的用法示例。


在下文中一共展示了gtk.STOCK_OPEN屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_open

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
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() 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:24,代碼來源:xdot.py

示例2: on_open

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
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() 
開發者ID:ym2011,項目名稱:POC-EXP,代碼行數:26,代碼來源:xdot.py

示例3: show_open_dialog

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
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 
開發者ID:mjun,項目名稱:gnome-connection-manager,代碼行數:19,代碼來源:gnome_connection_manager.py

示例4: chooseFile

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def chooseFile(self, default_dir=None,
                   filter_patterns=None):
        dialog = gtk.FileChooserDialog(
            title="Open File",
            parent=self._win,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                     gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        dialog.set_default_response(gtk.RESPONSE_OK)

        patterns = self._str_to_obj(filter_patterns) or {"xml": "XML Files"}
        for pattern in patterns:
            file_filter = gtk.FileFilter()
            file_filter.set_name(patterns[pattern])
            file_filter.add_pattern('*.{}'.format(pattern))
            dialog.add_filter(file_filter)

        if default_dir is not None:
            dialog.set_current_folder(os.path.expanduser(default_dir))

        path = ""

        response = dialog.run()
        if response == gtk.RESPONSE_OK:
            path = dialog.get_filename()
        elif response == gtk.RESPONSE_CANCEL:
            self.error("No files selected.")

        dialog.destroy()

        return path 
開發者ID:KanoComputing,項目名稱:kano-toolset,代碼行數:34,代碼來源:webapp.py

示例5: filedialog

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def filedialog(self, title=None, default_filename=None):
        chooser = gtk.FileChooserDialog(title=title, parent=self.window,
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(
                                            gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                                            gtk.RESPONSE_OK))
        chooser.resize(700, 500)
        if default_filename:
            chooser.set_filename(os.path.abspath(default_filename))
        filename = None
        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
        chooser.destroy()
        return filename 
開發者ID:avocado-framework,項目名稱:avocado-vt,代碼行數:17,代碼來源:step_editor.py

示例6: __init__

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def __init__(self, trace):
        buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, "Select a process...", buttons=buttons)
        self.proclist = ProcessListView(trace)
        self.vbox.pack_start(self.proclist, expand=True)
        self.proclist.treeview.connect("row_activated", self.procListActivated)
        self.proclist.treeview.connect("cursor_changed", self.procListSelected)
        self.pid = None
        self.resize(300, 600) 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:11,代碼來源:vwvtrace.py

示例7: __init__

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def __init__(self, vsbuilder, parent=None):
        buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, "Select a structure...", buttons=buttons, parent=parent)
        self.selector = VStructBuilderView(vsbuilder)
        self.vbox.pack_start(self.selector, expand=True)
        self.selector.treeview.connect("row_activated", self.nsActivated)
        self.selector.treeview.connect("cursor_changed", self.nsSelected)
        self.modinfo = None
        self.resize(400, 600) 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:11,代碼來源:vwvstruct.py

示例8: openFile

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
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() 
開發者ID:milisarge,項目名稱:malfs-milis,代碼行數:36,代碼來源:tintwizard.py

示例9: askOpenFileGtk

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def askOpenFileGtk(title, suffixes, initialDir):
    fls = []
    def run_dlg():
        chooser = gtk.FileChooserDialog(title,
                                        None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(initialDir)
        chooser.set_current_name("world")  # For some reason the Windows isn't closing if this line ins missing or the parameter is ""

        # Add custom Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name(_("Levels and Schematics"))
        for suffix in suffixes:
            file_filter.add_pattern("*." + suffix)
        chooser.add_filter(file_filter)

        # Add "All files" Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name("All files")
        file_filter.add_pattern("*")
        chooser.add_filter(file_filter)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            fls.append(chooser.get_filename())
        else:
            fls.append(None)
        chooser.destroy()
        gtk.main_quit()

    gtk.idle_add(run_dlg)
    gtk.main()

    return fls[0] 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:39,代碼來源:mcplatform.py

示例10: askOpenFileGtk

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def askOpenFileGtk(title, suffixes, initialDir):
    fls = []

    def run_dlg():
        chooser = gtk.FileChooserDialog(title,
                                        None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser.set_current_folder(initialDir)
        chooser.set_current_name("world")  # For some reason the Windows isn't closing if this line ins missing or the parameter is ""

        # Add custom Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name(_("Levels and Schematics"))
        for suffix in suffixes:
            file_filter.add_pattern("*." + suffix)
        chooser.add_filter(file_filter)

        # Add "All files" Filter
        file_filter = gtk.FileFilter()
        file_filter.set_name("All files")
        file_filter.add_pattern("*")
        chooser.add_filter(file_filter)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            fls.append(chooser.get_filename())
        else:
            fls.append(None)
        chooser.destroy()
        gtk.main_quit()

    gtk.idle_add(run_dlg)
    gtk.main()

    return fls[0] 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:40,代碼來源:mcplatform.py

示例11: askOpenFolderGtk

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def askOpenFolderGtk(title, initialDir):
    if hasGtk:
        fls = []

        def run_dlg():
            chooser = gtk.FileChooserDialog(title,
                                        None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))

            chooser.set_default_response(gtk.RESPONSE_OK)
            chooser.set_current_folder(initialDir)
            chooser.set_current_name("world")
            chooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)

            response = chooser.run()
            if response == gtk.RESPONSE_OK:
                fls.append(chooser.get_filename())  # Returns the folder path if gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER is the action
            else:
                fls.append(None)
            chooser.destroy()
            gtk.main_quit()

        gtk.idle_add(run_dlg)
        gtk.main()
        return fls[0]
    else:
        print "You currently need gtk to use an Open Folder Dialog!" 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:30,代碼來源:mcplatform.py

示例12: on_license_button_clicked

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def on_license_button_clicked(self, button):
        log.debug("License button clicked.")
        chooser = gtk.FileChooserDialog(_("Choose your FileBot license file"),
            None,
            gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                        gtk.RESPONSE_OK))

        chooser.set_transient_for(self.pref_dialog)
        chooser.set_property("skip-taskbar-hint", True)
        chooser.set_local_only(False)

        file_filter = gtk.FileFilter()
        file_filter.set_name(_("FileBot license files"))
        file_filter.add_pattern("*." + "psm")
        chooser.add_filter(file_filter)
        file_filter = gtk.FileFilter()
        file_filter.set_name(_("All files"))
        file_filter.add_pattern("*")
        chooser.add_filter(file_filter)

        # Run the dialog
        response = chooser.run()

        if response == gtk.RESPONSE_OK:
            license = chooser.get_filenames()[0]
        else:
            chooser.destroy()
            return
        chooser.destroy()

        # License file should definetly be under 10K
        size = os.stat(license).st_size
        if size > 10*1000:
            e = user_messenger.InfoDialog("Error", "License file is too big.")
            e.resize(220, 125)
            e.run_async()
            defer.returnValue()

        with open(license, 'rb') as l:
            license_data = l.read()
        log.debug("Sending license data to server.")
        result = yield client.filebottool.activate_filebot_license(license_data)
        log.debug("Recieved reply from server: %s", result)
        if result.startswith("FilebotLicenseError: "):
            title = "Error with License File"
            msg = result[21:]
        else:
            title = "Success!"
            msg = result

        dialog = user_messenger.InfoDialog(title, msg)
        dialog.resize(220, 125)
        dialog.run_async()




#########
#  Section: Utilities
######### 
開發者ID:Laharah,項目名稱:deluge-FileBotTool,代碼行數:63,代碼來源:config_ui.py

示例13: __init__

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
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() 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:52,代碼來源:xdot.py

示例14: __init__

# 需要導入模塊: import gtk [as 別名]
# 或者: from gtk import STOCK_OPEN [as 別名]
def __init__(self, window):
        #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),
            ('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')
        toolbar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#d5e5f7"))
        vbox.pack_start(toolbar, False)

        vbox.pack_start(self.widget)

        #self.set_focus(self.widget)

        #self.show_all()
        self.widget.zoom_image(1.0) 
開發者ID:OpenXenManager,項目名稱:openxenmanager,代碼行數:53,代碼來源:xdot.py


注:本文中的gtk.STOCK_OPEN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。