Python gtk.FileFilter() Examples
The following are 25
code examples of gtk.FileFilter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gtk
, or try the search function
.
Example #1
Source File: xdot.py From EasY_HaCk with Apache License 2.0 | 6 votes |
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()
Example #2
Source File: xdot.py From POC-EXP with GNU General Public License v3.0 | 6 votes |
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()
Example #3
Source File: xdot.py From openxenmanager with GNU General Public License v2.0 | 6 votes |
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()
Example #4
Source File: xdot.py From NoobSec-Toolkit with GNU General Public License v2.0 | 6 votes |
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()
Example #5
Source File: xdot.py From NoobSec-Toolkit with GNU General Public License v2.0 | 6 votes |
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()
Example #6
Source File: xdot.py From NoobSec-Toolkit with GNU General Public License v2.0 | 6 votes |
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()
Example #7
Source File: xdot.py From NoobSec-Toolkit with GNU General Public License v2.0 | 6 votes |
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()
Example #8
Source File: mcplatform.py From MCEdit-Unified with ISC License | 5 votes |
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]
Example #9
Source File: webapp.py From kano-toolset with GNU General Public License v2.0 | 5 votes |
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
Example #10
Source File: core.py From Tocino with GNU General Public License v2.0 | 5 votes |
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
Example #11
Source File: core.py From ns3-802.11ad with GNU General Public License v2.0 | 5 votes |
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
Example #12
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 5 votes |
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
Example #13
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 5 votes |
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
Example #14
Source File: mcplatform.py From GDMC with ISC License | 5 votes |
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]
Example #15
Source File: core.py From ns-3-dev-git with GNU General Public License v2.0 | 5 votes |
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
Example #16
Source File: core.py From royal-chaos with MIT License | 5 votes |
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
Example #17
Source File: core.py From ns3-rdma with GNU General Public License v2.0 | 5 votes |
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
Example #18
Source File: core.py From 802.11ah-ns3 with GNU General Public License v2.0 | 5 votes |
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
Example #19
Source File: core.py From ns3-load-balance with GNU General Public License v2.0 | 5 votes |
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
Example #20
Source File: core.py From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 | 5 votes |
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
Example #21
Source File: core.py From ntu-dsi-dcn with GNU General Public License v2.0 | 5 votes |
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
Example #22
Source File: tintwizard.py From malfs-milis with MIT License | 5 votes |
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
Example #23
Source File: tintwizard.py From malfs-milis with MIT License | 5 votes |
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()
Example #24
Source File: mcplatform.py From GDMC with ISC License | 4 votes |
def run_dlg(): chooser = gtk.FileChooserDialog(title, None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) chooser.set_default_response(gtk.RESPONSE_OK) chooser.set_current_folder(initialDir) chooser.set_current_name(defaultName) # Add custom Filter if type(_filetype) in (list, tuple): for i, filet in enumerate(_filetype): if i % 2 == 0: file_filter = gtk.FileFilter() file_filter.set_name(filet) if ";" in _suffix[i + 1]: for _suff in _suffix.split(";"): if _suff: file_filter.add_pattern(_suff) else: file_filter.add_pattern(_suffix[i + 1]) chooser.add_filter(file_filter) else: file_filter = gtk.FileFilter() file_filter.set_name(filetype[:filetype.index("\0")]) if "\0" in suffix and suffix.count("*.") > 1: __suffix = suffix.split("\0")[:-2] else: __suffix = suffix if type(__suffix) in (list, tuple): for suff in __suffix: file_filter.add_pattern("*." + suff) else: 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()
Example #25
Source File: config_ui.py From deluge-FileBotTool with GNU General Public License v3.0 | 4 votes |
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 #########