Python gtk.STOCK_CANCEL Examples
The following are 30
code examples of gtk.STOCK_CANCEL().
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 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 #2
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 #3
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 #4
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 6 votes |
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()
Example #5
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 6 votes |
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
Example #6
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 #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: 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 #9
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 #10
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 #11
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 #12
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 #13
Source File: menu.py From hardening-script-el6-kickstart with Apache License 2.0 | 5 votes |
def get_password(self,parent): dialog = gtk.Dialog("Configure System Password",parent,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT)) self.pass1 = gtk.HBox() self.label1 = gtk.Label(" Passsword: ") self.pass1.pack_start(self.label1,False,True,0) self.password1 = gtk.Entry() self.password1.set_visibility(False) self.pass1.pack_start(self.password1,False,True,0) dialog.vbox.add(self.pass1) self.pass2 = gtk.HBox() self.label2 = gtk.Label(" Verify Password: ") self.pass2.pack_start(self.label2,False,True,0) self.password2 = gtk.Entry() self.password2.set_visibility(False) self.pass2.pack_start(self.password2,False,True,0) dialog.vbox.add(self.pass2) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_ACCEPT: self.a = self.password1.get_text() self.b = self.password2.get_text() dialog.destroy() else: self.a = '' self.b = '' dialog.destroy() # Appply Configurations to Kickstart File
Example #14
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 #15
Source File: mcplatform.py From MCEdit-Unified with ISC License | 5 votes |
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!"
Example #16
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 #17
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 #18
Source File: operations.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def _create_pdb_procedure_browser_dialog(self): dialog = gimpui.ProcBrowserDialog( _("Procedure Browser"), role=pg.config.PLUGIN_NAME, buttons=(gtk.STOCK_ADD, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_alternative_button_order((gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL)) dialog.connect("response", self._on_pdb_procedure_browser_dialog_response) dialog.show_all() return dialog
Example #19
Source File: gnome_connection_manager.py From gnome-connection-manager with GNU General Public License v3.0 | 5 votes |
def __init__(self, title, message, default_text='', modal=True, mask=False): gtk.Dialog.__init__(self) self.set_title(title) self.connect("destroy", self.quit) self.connect("delete_event", self.quit) if modal: self.set_modal(True) box = gtk.VBox(spacing=10) box.set_border_width(10) self.vbox.pack_start(box) box.show() if message: label = gtk.Label(message) box.pack_start(label) label.show() self.entry = gtk.Entry() self.entry.set_text(default_text) self.entry.set_visibility(not mask) box.pack_start(self.entry) self.entry.show() self.entry.grab_focus() button = gtk.Button(stock=gtk.STOCK_OK) button.connect("clicked", self.click) self.entry.connect("activate", self.click) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show() button.grab_default() button = gtk.Button(stock=gtk.STOCK_CANCEL) button.connect("clicked", self.quit) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show() self.ret = None
Example #20
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 #21
Source File: terminal.py From NINJA-PingU with GNU General Public License v3.0 | 5 votes |
def key_edit_window_title(self): window = self.get_toplevel() dialog = gtk.Dialog(_('Rename Window'), window, gtk.DIALOG_MODAL, ( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT )) dialog.set_default_response(gtk.RESPONSE_ACCEPT) dialog.set_has_separator(False) dialog.set_resizable(False) dialog.set_border_width(8) label = gtk.Label(_('Enter a new title for the Terminator window...')) name = gtk.Entry() name.set_activates_default(True) if window.title.text != self.vte.get_window_title(): name.set_text(self.get_toplevel().title.text) dialog.vbox.pack_start(label, False, False, 6) dialog.vbox.pack_start(name, False, False, 6) dialog.show_all() res = dialog.run() if res == gtk.RESPONSE_ACCEPT: if name.get_text(): window.title.force_title(None) window.title.force_title(name.get_text()) else: window.title.force_title(None) dialog.destroy() return # End key events
Example #22
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 #23
Source File: vwvtrace.py From nightmare with GNU General Public License v2.0 | 5 votes |
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)
Example #24
Source File: vwvstruct.py From nightmare with GNU General Public License v2.0 | 5 votes |
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)
Example #25
Source File: step_editor.py From avocado-vt with GNU General Public License v2.0 | 5 votes |
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
Example #26
Source File: vwvstruct.py From nightmare with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent=None): buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK) gtk.Dialog.__init__(self, "Select a structure namespace...", buttons=buttons, parent=parent) self.selector = VStructNamespaceSelector() 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)
Example #27
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 #28
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 #29
Source File: tintwizard.py From malfs-milis with MIT License | 5 votes |
def quit(self, widget, event=None): """Asks if user would like to save file before quitting, then quits the program.""" if self.toSave: if self.oneConfigFile: response = gtk.RESPONSE_YES else: dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.get_content_area().add(gtk.Label("Save config before quitting?")) dialog.get_content_area().set_size_request(300, 100) dialog.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True # Return True to stop it quitting when we hit "Cancel" elif response == gtk.RESPONSE_NO: gtk.main_quit() elif response == gtk.RESPONSE_YES: self.save() gtk.main_quit() else: gtk.main_quit()
Example #30
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