当前位置: 首页>>代码示例>>Python>>正文


Python gtk.FILE_CHOOSER_ACTION_OPEN属性代码示例

本文整理汇总了Python中gtk.FILE_CHOOSER_ACTION_OPEN属性的典型用法代码示例。如果您正苦于以下问题:Python gtk.FILE_CHOOSER_ACTION_OPEN属性的具体用法?Python gtk.FILE_CHOOSER_ACTION_OPEN怎么用?Python gtk.FILE_CHOOSER_ACTION_OPEN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gtk的用法示例。


在下文中一共展示了gtk.FILE_CHOOSER_ACTION_OPEN属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_open

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_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 FILE_CHOOSER_ACTION_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: chooseFile

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_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

示例4: filedialog

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_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

示例5: openFile

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_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

示例6: on_btnBrowse_clicked

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_OPEN [as 别名]
def on_btnBrowse_clicked(self, widget, *args):
        global wMain
        filename = show_open_dialog(parent=wMain.wMain, title=_("Abrir"), action=gtk.FILE_CHOOSER_ACTION_OPEN)
        if filename != None:
            self.txtPrivateKey.set_text(filename)
    #-- Whost.on_btnBrowse_clicked } 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:8,代码来源:gnome_connection_manager.py

示例7: on_license_button_clicked

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_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

示例8: on_importar_servidores1_activate

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import FILE_CHOOSER_ACTION_OPEN [as 别名]
def on_importar_servidores1_activate(self, widget, *args):
        filename = show_open_dialog(parent=self.wMain, title=_("Abrir"), action=gtk.FILE_CHOOSER_ACTION_OPEN)
        if filename != None:            
            password = inputbox(_('Importar Servidores'), _('Ingrese clave: '), password=True)
            if password == None:
                return                                                
            
            #abrir archivo con lista de servers y cargarlos en el arbol
            try:
                cp= ConfigParser.RawConfigParser( )
                cp.read( filename )
            
                #validar el pass
                s = decrypt(password, cp.get("gcm", "gcm"))
                if (s != password[::-1]):
                    msgbox(_("Clave invalida"))
                    return
            
                if msgconfirm(_(u'Se sobreescribirá la lista de servidores, continuar?')) != gtk.RESPONSE_OK:
                    return
                    
                grupos={}
                for section in cp.sections():
                    if not section.startswith("host "):
                        continue                    
                    host = HostUtils.load_host_from_ini(cp, section, password)
        
                    if not grupos.has_key(host.group):                    
                        grupos[host.group]=[]  
        
                    grupos[host.group].append( host )
            except:                
                msgbox(_("Archivo invalido"))
                return
            #sobreescribir lista de hosts
            global groups
            groups=grupos
            
            self.updateTree()
    #-- Wmain.on_importar_servidores1_activate }

    #-- Wmain.on_exportar_servidores1_activate { 
开发者ID:mjun,项目名称:gnome-connection-manager,代码行数:44,代码来源:gnome_connection_manager.py


注:本文中的gtk.FILE_CHOOSER_ACTION_OPEN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。