Python gi.repository.Gtk.STOCK_OPEN Examples
The following are 30
code examples of gi.repository.Gtk.STOCK_OPEN().
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
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: file_chooser.py From ebook-viewer with GNU General Public License v3.0 | 6 votes |
def show_dialog(self, importing=False): """ Displays FileChooserDialog with ePub file filters and returns Gtk.ResponseType and filename string :return (response, filename): """ dialog = Gtk.FileChooserDialog(_("Please choose a file"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) # Always start in user dir dialog.set_current_folder(path.expanduser("~")) # Add filters so only .epub files show # TODO: Filter list for all conversion supported ebooks self.__add_filters(dialog, importing) response = dialog.run() filename = dialog.get_filename() dialog.destroy() return response, filename
Example #2
Source File: settings_dialog.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
def select_image(self, button): """ Show a file chooser dialog and let the user to select an image. """ dialog = Gtk.FileChooserDialog(_('Please select an image'), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) png_filter = Gtk.FileFilter() png_filter.set_name("PNG files") png_filter.add_mime_type("image/png") png_filter.add_pattern("*.png") dialog.add_filter(png_filter) response = dialog.run() if response == Gtk.ResponseType.OK: self.break_config['image'] = dialog.get_filename() pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(self.break_config['image'], 16, 16, True) self.img_break.set_from_pixbuf(pixbuf) elif response == Gtk.ResponseType.CANCEL: self.break_config.pop('image', None) self.img_break.set_from_stock('gtk-missing-image', Gtk.IconSize.BUTTON) dialog.destroy()
Example #3
Source File: main.py From badKarma with GNU General Public License v3.0 | 6 votes |
def import_file(self, widget): """ import nmap xml """ dialog = Gtk.FileChooserDialog("Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_nmap(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() self.engine.import_file(file_selected) self._sync() elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy()
Example #4
Source File: pyspc_gui.py From pyspc with GNU General Public License v3.0 | 6 votes |
def on_file(self, button): dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) filter_csv = Gtk.FileFilter() filter_csv.set_name("CSV Files") filter_csv.add_pattern("*.csv") dialog.add_filter(filter_csv) response = dialog.run() if response == Gtk.ResponseType.OK: path = dialog.get_filename() self.data = pd.read_csv(path) self.verticalbox.remove(self.scrollable_treelist) self.add_treeview() dialog.destroy()
Example #5
Source File: bruter.py From badKarma with GNU General Public License v3.0 | 6 votes |
def bruter_open_pass_file(self ,widget): dialog = Gtk.FileChooserDialog("Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_txt(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() self.bruter_pass_wl_path.set_text(file_selected) elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy()
Example #6
Source File: bruter.py From badKarma with GNU General Public License v3.0 | 6 votes |
def bruter_open_user_file(self ,widget): dialog = Gtk.FileChooserDialog("Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_txt(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() self.bruter_user_wl_path.set_text(file_selected) elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy()
Example #7
Source File: pyspc_gui.py From pyspc with GNU General Public License v3.0 | 6 votes |
def on_file_clicked(self, widget): # dialog = Gtk.FileChooserDialog("Please choose a file", self, # Gtk.FileChooserAction.OPEN, # (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, # Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) # response = dialog.run() # if response == Gtk.ResponseType.OK: # path = dialog.get_filename() # # self.open_file.set_label("File Selected: %s" % os.path.basename(path)) # self.data = pd.read_csv(path) # elif response == Gtk.ResponseType.CANCEL: # print("Cancel clicked") # dialog.destroy() dialog = FileDialog(self) # dialog.show_all() response = dialog.run() if response == Gtk.ResponseType.OK: self.data = dialog.data dialog.destroy()
Example #8
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 6 votes |
def on_new_subtitle_clicked(self): dialog = Gtk.FileChooserDialog("Please choose a subtitle file...", self.win, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) if self.fn: dialog.set_current_folder(os.path.dirname(self.fn)) filter_py = Gtk.FileFilter() filter_py.set_name("Subtitles") filter_py.add_pattern("*.srt") filter_py.add_pattern("*.vtt") dialog.add_filter(filter_py) response = dialog.run() if response == Gtk.ResponseType.OK: print("Open clicked") print("File selected: " + dialog.get_filename()) self.select_subtitles_file(dialog.get_filename()) elif response == Gtk.ResponseType.CANCEL: print("Cancel clicked") self.subtitle_combo.set_active(0) dialog.destroy()
Example #9
Source File: window.py From pyWinUSB with MIT License | 6 votes |
def __show_file_chooser(self, button): """ Tworzenie dialogu wyboru pliku obrazu """ dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL , Gtk.ResponseType.CANCEL , Gtk.STOCK_OPEN , Gtk.ResponseType.OK )) filters = { "application/x-cd-image": "CD/DVD image" } for key, val in filters.items(): filter_text = Gtk.FileFilter() filter_text.set_name(val) filter_text.add_mime_type(key) dialog.add_filter(filter_text) response = dialog.run() if response == Gtk.ResponseType.OK: self.path.set_text(dialog.get_filename()) elif response == Gtk.ResponseType.CANCEL: print("Cancel clicked") dialog.destroy()
Example #10
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 6 votes |
def on_download_subtitle_clicked(self): dialog = Gtk.FileChooserDialog("Please choose a subtitle file...", self.win, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) if self.fn: dialog.set_current_folder(os.path.dirname(self.fn)) filter_py = Gtk.FileFilter() filter_py.set_name("Subtitles") filter_py.add_pattern("*.srt") filter_py.add_pattern("*.vtt") dialog.add_filter(filter_py) response = dialog.run() if response == Gtk.ResponseType.OK: print("Open clicked") print("File selected: " + dialog.get_filename()) self.select_subtitles_file(dialog.get_filename()) elif response == Gtk.ResponseType.CANCEL: print("Cancel clicked") self.subtitle_combo.set_active(0) dialog.destroy()
Example #11
Source File: color_grid.py From wpgtk with GNU General Public License v2.0 | 6 votes |
def on_import_click(self, widget): fcd = Gtk.FileChooserDialog( 'Select a colorscheme', self.parent, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) filter = Gtk.FileFilter() filter.set_name("JSON colorscheme") filter.add_mime_type("application/json") fcd.add_filter(filter) response = fcd.run() if response == Gtk.ResponseType.OK: self.color_list = color.get_color_list(fcd.get_filename(), True) self.render_buttons() self.render_sample() fcd.destroy()
Example #12
Source File: etreeGramplet.py From addons-source with GNU General Public License v2.0 | 6 votes |
def __select_file(self, obj): """ Call back function to handle the open button press """ my_action = Gtk.FileChooserAction.SAVE dialog = Gtk.FileChooserDialog('lxml', action=my_action, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) name = os.path.basename(self.entry.get_text()) dialog.set_current_name(name) dialog.set_current_folder(self.__base_path) dialog.present() status = dialog.run() if status == Gtk.ResponseType.OK: self.set_filename(dialog.get_filename()) dialog.destroy()
Example #13
Source File: xdot.py From bokken with GNU General Public License v2.0 | 6 votes |
def on_open(self, action): chooser = Gtk.FileChooserDialog(title="Open dot File", action=Gtk.FileChooserAction.OPEN, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) chooser.set_default_response(Gtk.ResponseType.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.ResponseType.OK: filename = chooser.get_filename() self.last_open_dir = chooser.get_current_folder() chooser.destroy() self.open_file(filename) else: chooser.destroy()
Example #14
Source File: lxmlGramplet.py From addons-source with GNU General Public License v2.0 | 6 votes |
def __select_file(self, obj): """ Call back function to handle the open button press """ my_action = Gtk.FileChooserAction.SAVE dialog = Gtk.FileChooserDialog('lxml', action=my_action, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) name = os.path.basename(self.entry.get_text()) dialog.set_current_name(name) dialog.set_current_folder(self.__base_path) dialog.present() status = dialog.run() if status == Gtk.ResponseType.OK: self.set_filename(dialog.get_filename()) dialog.destroy()
Example #15
Source File: extras.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def run_quick_open(self): """ Display a dialog asking a user which file should be opened. The value of target_path in the returned dictionary is an absolute path. :return: A dictionary with target_uri and target_path keys representing the path chosen. :rtype: dict """ self.set_action(Gtk.FileChooserAction.OPEN) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT) self.show_all() response = self.run() if response == Gtk.ResponseType.CANCEL: return None target_path = self.get_filename() if not os.access(target_path, os.R_OK): gui_utilities.show_dialog_error('Permissions Error', self.parent, 'Can not read the selected file.') return None target_uri = self.get_uri() return {'target_uri': target_uri, 'target_path': target_path}
Example #16
Source File: main_button_menu.py From bokken with GNU General Public License v2.0 | 6 votes |
def _save(self, widget, data): chooser = Gtk.FileChooserDialog(title=None,action=Gtk.FileChooserAction.SAVE, buttons=(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK)) response = chooser.run() if response == Gtk.ResponseType.OK: all = ['asm', 'hex', 'str'] filename = chooser.get_filename() if data != 'all': output = open(filename + '.' + data, 'wb') content = self._get_content(data) output.write(content) output.close() else: for fmt in all: output = open(filename + '.' + fmt, 'wb') content = self._get_content(fmt) output.write(content) output.close() chooser.destroy()
Example #17
Source File: extras.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def run_quick_select_directory(self): """ Display a dialog which asks the user to select a directory to use. The value of target_path in the returned dictionary is an absolute path. :return: A dictionary with target_uri and target_path keys representing the path chosen. :rtype: dict """ self.set_action(Gtk.FileChooserAction.SELECT_FOLDER) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT) self.show_all() response = self.run() if response == Gtk.ResponseType.CANCEL: return None target_uri = self.get_uri() target_path = self.get_filename() return {'target_uri': target_uri, 'target_path': target_path}
Example #18
Source File: gtk.py From bups with MIT License | 6 votes |
def on_add_clicked(self, btn): dialog = Gtk.FileChooserDialog(_("Please choose a directory"), self, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) response = dialog.run() if response == Gtk.ResponseType.OK: dirpath = dialog.get_filename() print("Dir selected: " + dirpath) self.add_dir(dirpath) elif response == Gtk.ResponseType.CANCEL: print("Cancel clicked") dialog.destroy()
Example #19
Source File: launcher_wine.py From games_nebula with GNU General Public License v3.0 | 5 votes |
def setup_custom_exe(self, button): file_path = '' file_name = '' dialog = Gtk.FileChooserDialog( _("Select an executable"), self.main_window, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK ) ) dialog.set_current_folder(self.wineprefix + '/drive_c/Games/' + self.game_name) file_filter = Gtk.FileFilter() file_filter.set_name("*.exe") file_filter.add_pattern("*.exe") dialog.add_filter(file_filter) response = dialog.run() if response == Gtk.ResponseType.OK: file_path = dialog.get_current_folder() file_name = dialog.get_filename().split('/')[-1] if '.exe' in file_name: button.set_label(file_name) button.get_parent().get_children()[-1].set_sensitive(True) dialog.destroy() else: dialog.destroy() return file_path, file_name
Example #20
Source File: diff_dialog.py From bokken with GNU General Public License v2.0 | 5 votes |
def select_file(self, widget, icon_pos='', event=''): if self.input_entry2.get_text(): self.get_file(self.input_entry2) self.response(0) else: chooser = Gtk.FileChooserDialog(title=None,action=Gtk.FileChooserAction.OPEN, buttons=(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK)) self.resp = chooser.run() if self.resp == Gtk.ResponseType.DELETE_EVENT or self.resp == Gtk.ResponseType.REJECT or self.resp == Gtk.ResponseType.CANCEL: chooser.destroy() else: self.file_name = chooser.get_filename() self.input_entry2.set_text(self.file_name) chooser.destroy()
Example #21
Source File: main.py From oomox with GNU General Public License v3.0 | 5 votes |
def import_themix_colors(self): self.ask_unsaved_changes() filechooser_dialog = Gtk.FileChooserDialog( _("Please choose a file with oomox colors"), self, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK ) ) filechooser_response = filechooser_dialog.run() if filechooser_response in ( Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT ): filechooser_dialog.destroy() return import_theme_path = filechooser_dialog.get_filename() filechooser_dialog.destroy() import_theme_name = os.path.basename(import_theme_path) while True: dialog = RenameDialog(transient_for=self, entry_text=import_theme_name) if not dialog_is_yes(dialog): return new_theme_name = dialog.entry_text if not self.ask_colorscheme_exists(new_theme_name): self.import_theme_from_path( path=import_theme_path, new_name=new_theme_name ) return
Example #22
Source File: main.py From oomox with GNU General Public License v3.0 | 5 votes |
def import_from_plugin(self, plugin): self.ask_unsaved_changes() filechooser_dialog = Gtk.FileChooserDialog( _("Please choose an image file"), self, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK ) ) filechooser_response = filechooser_dialog.run() if filechooser_response in ( Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT ): filechooser_dialog.destroy() return import_theme_path = filechooser_dialog.get_filename() filechooser_dialog.destroy() import_theme_name = os.path.basename(import_theme_path) new_theme_path = os.path.join(plugin.user_theme_dir, import_theme_name) dest_dir = os.path.dirname(new_theme_path) if not os.path.exists(dest_dir): os.makedirs(dest_dir) shutil.copy(import_theme_path, new_theme_path) self.colorscheme_path = new_theme_path self.reload_presets()
Example #23
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def pick_file(self, *args): """ Ask the user which file he means to open. """ # Use a GTK file dialog to choose file dialog = Gtk.FileChooserDialog(title = _('Open...'), transient_for = self.p_win, action = Gtk.FileChooserAction.OPEN) dialog.add_buttons(Gtk.STOCK_OPEN, Gtk.ResponseType.OK) dialog.set_default_response(Gtk.ResponseType.OK) dialog.set_position(Gtk.WindowPosition.CENTER) filter = Gtk.FileFilter() filter.set_name(_('PDF files')) filter.add_mime_type('application/pdf') filter.add_pattern('*.pdf') dialog.add_filter(filter) filter = Gtk.FileFilter() filter.set_name(_('All files')) filter.add_pattern('*') dialog.add_filter(filter) response = dialog.run() if response == Gtk.ResponseType.OK: self.swap_document(os.path.abspath(dialog.get_filename())) dialog.destroy()
Example #24
Source File: gtk.py From pywebview with BSD 3-Clause "New" or "Revised" License | 5 votes |
def create_file_dialog(self, dialog_type, directory, allow_multiple, save_filename, file_types): if dialog_type == FOLDER_DIALOG: gtk_dialog_type = gtk.FileChooserAction.SELECT_FOLDER title = localization['linux.openFolder'] button = gtk.STOCK_OPEN elif dialog_type == OPEN_DIALOG: gtk_dialog_type = gtk.FileChooserAction.OPEN if allow_multiple: title = localization['linux.openFiles'] else: title = localization['linux.openFile'] button = gtk.STOCK_OPEN elif dialog_type == SAVE_DIALOG: gtk_dialog_type = gtk.FileChooserAction.SAVE title = localization['global.saveFile'] button = gtk.STOCK_SAVE dialog = gtk.FileChooserDialog(title, self.window, gtk_dialog_type, (gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL, button, gtk.ResponseType.OK)) dialog.set_select_multiple(allow_multiple) dialog.set_current_folder(directory) self._add_file_filters(dialog, file_types) if dialog_type == SAVE_DIALOG: dialog.set_current_name(save_filename) response = dialog.run() if response == gtk.ResponseType.OK: file_name = dialog.get_filenames() else: file_name = None dialog.destroy() return file_name
Example #25
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 5 votes |
def on_file_clicked(self, widget): dialog = Gtk.FileChooserDialog("Please choose an audio or video file...", self.win, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) dialog.set_select_multiple(True) downloads_dir = os.path.expanduser('~/Downloads') if os.path.isdir(downloads_dir): dialog.set_current_folder(downloads_dir) filter_py = Gtk.FileFilter() filter_py.set_name("Videos") filter_py.add_mime_type("video/*") filter_py.add_mime_type("audio/*") dialog.add_filter(filter_py) response = dialog.run() if response == Gtk.ResponseType.OK: print("Open clicked") print("File selected:", dialog.get_filenames()) self.queue_files(dialog.get_filenames()) #self.select_file(dialog.get_filename()) elif response == Gtk.ResponseType.CANCEL: print("Cancel clicked") dialog.destroy()
Example #26
Source File: audiotsmgtk.py From audiotsm with MIT License | 5 votes |
def on_open(self, button): """Called when the open button is clicked.""" dialog = Gtk.FileChooserDialog( 'Open audio file', self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) response = dialog.run() if response == Gtk.ResponseType.OK: path = dialog.get_filename() self.open_file(path) dialog.destroy()
Example #27
Source File: __init__.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def __init__(self, extension, opener, preferences): GObject.GObject.__init__(self) self.extension = extension # XXX self.opener = opener self.uistate = extension.uistate self.preferences = preferences self._close_button = None self.iconview = FileBrowserIconView(opener, self.icon_size) self.add(ScrolledWindow(self.iconview, shadow=Gtk.ShadowType.NONE)) self.on_preferences_changed() self.preferences.connect('changed', self.on_preferences_changed) self.buttonbox = Gtk.VBox() self.pack_end(self.buttonbox, False, True, 0) open_folder_button = IconButton(Gtk.STOCK_OPEN, relief=False) open_folder_button.connect('clicked', self.on_open_folder) self.buttonbox.pack_start(open_folder_button, False, True, 0) refresh_button = IconButton(Gtk.STOCK_REFRESH, relief=False) refresh_button.connect('clicked', lambda o: self.on_refresh_button()) self.buttonbox.pack_start(refresh_button, False, True, 0) zoomin = IconButton(Gtk.STOCK_ZOOM_IN, relief=False) zoomout = IconButton(Gtk.STOCK_ZOOM_OUT, relief=False) zoomin.connect('clicked', lambda o: self.on_zoom_in()) zoomout.connect('clicked', lambda o: self.on_zoom_out()) self.buttonbox.pack_end(zoomout, False, True, 0) self.buttonbox.pack_end(zoomin, False, True, 0) self.zoomin_button = zoomin self.zoomout_button = zoomout self.set_icon_size(self.icon_size) self.iconview.connect('folder-changed', lambda o: self.update_title())
Example #28
Source File: simpledialog.py From eavatar-me with Apache License 2.0 | 5 votes |
def chooseOpenFile(): dialog = Gtk.FileChooserDialog("Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) # self.add_filters(dialog) response = dialog.run() filename = dialog.get_filename() dialog.destroy() if response == Gtk.ResponseType.OK: return filename
Example #29
Source File: file_dialog.py From bokken with GNU General Public License v2.0 | 5 votes |
def select_file(self, widget): chooser = Gtk.FileChooserDialog(title="Select target",action=Gtk.FileChooserAction.OPEN, buttons=(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK)) self.resp = chooser.run() if self.resp == Gtk.ResponseType.OK: self.file_name = chooser.get_filename() self.input_entry.get_child().set_text(self.file_name) chooser.destroy()
Example #30
Source File: latextext_gtk3.py From LaTeXText with GNU General Public License v3.0 | 5 votes |
def on_select_preamble(self, widget): dialog = Gtk.FileChooserDialog("Please choose a Latex preamble file", self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) dialog.set_keep_above(True) dialog.set_modal(True) response = dialog.run() if response == Gtk.ResponseType.OK: self.entryPreamble.set_text(dialog.get_filename()) dialog.destroy()