Python gi.repository.Gtk.MessageDialog() Examples
The following are 30
code examples of gi.repository.Gtk.MessageDialog().
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: plugin_loader.py From oomox with GNU General Public License v3.0 | 6 votes |
def init_plugins(): all_plugin_paths = {} for _plugins_dir in (PLUGINS_DIR, USER_PLUGINS_DIR): if not os.path.exists(_plugins_dir): continue for plugin_name in os.listdir(_plugins_dir): all_plugin_paths[plugin_name] = os.path.join(_plugins_dir, plugin_name) for plugin_name, plugin_path in all_plugin_paths.items(): try: load_plugin(plugin_name, plugin_path) except Exception as exc: error_dialog = Gtk.MessageDialog( text=_('Error loading plugin "{plugin_name}"').format( plugin_name=plugin_name ), secondary_text=( plugin_path + ":\n" + '\n'.join([str(arg) for arg in exc.args]) + '\n' * 2 + traceback.format_exc() ), buttons=Gtk.ButtonsType.CLOSE ) error_dialog.run() error_dialog.destroy()
Example #2
Source File: gui.py From epoptes with GNU General Public License v3.0 | 6 votes |
def disconnected(self, _daemon): """Called from uiconnection->Daemon->connectionLost.""" self.mainwin.set_sensitive(False) # If the reactor is not running at this point it means that we were # closed normally. # noinspection PyUnresolvedReferences if not reactor.running: return self.save_settings() msg = _("Lost connection with the epoptes service.") msg += "\n\n" + \ _("Make sure the service is running and then restart epoptes.") dlg = Gtk.MessageDialog(type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, message_format=msg) dlg.set_title(_('Service connection error')) dlg.run() dlg.destroy() # noinspection PyUnresolvedReferences reactor.stop()
Example #3
Source File: asktext.py From textext with BSD 3-Clause "New" or "Revised" License | 6 votes |
def window_deleted_cb(self, widget, event, view): if (self._gui_config.get("confirm_close", self.DEFAULT_CONFIRM_CLOSE) and self._source_buffer.get_text(self._source_buffer.get_start_iter(), self._source_buffer.get_end_iter(), True) != self.text): dlg = Gtk.MessageDialog(self._window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE) dlg.set_markup( "<b>Do you want to close TexText without save?</b>\n\n" "Your changes will be lost if you don't save them." ) dlg.add_button("Continue editing", Gtk.ResponseType.CLOSE) \ .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.BUTTON)) dlg.add_button("Close without save", Gtk.ResponseType.YES) \ .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON)) dlg.set_title("Close without save?") res = dlg.run() dlg.destroy() if res in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT): return True Gtk.main_quit() return False
Example #4
Source File: backend_gtk3.py From Computable with MIT License | 6 votes |
def error_msg_gtk(msg, parent=None): if parent is not None: # find the toplevel Gtk.Window parent = parent.get_toplevel() if not parent.is_toplevel(): parent = None if not is_string_like(msg): msg = ','.join(map(str,msg)) dialog = Gtk.MessageDialog( parent = parent, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK, message_format = msg) dialog.run() dialog.destroy()
Example #5
Source File: backend_gtk3.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def error_msg_gtk(msg, parent=None): if parent is not None: # find the toplevel Gtk.Window parent = parent.get_toplevel() if not parent.is_toplevel(): parent = None if not isinstance(msg, str): msg = ','.join(map(str, msg)) dialog = Gtk.MessageDialog( parent = parent, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK, message_format = msg) dialog.run() dialog.destroy()
Example #6
Source File: dialog.py From ImEditor with GNU General Public License v3.0 | 6 votes |
def message_dialog(parent, dialog_type, title, text): """Simplify way to show a message in a dialog""" button_type = Gtk.ButtonsType.OK if dialog_type == 'info': dialog_type = Gtk.MessageType.INFO elif dialog_type == 'warning': dialog_type = Gtk.MessageType.WARNING elif dialog_type == 'error': dialog_type = Gtk.MessageType.ERROR elif dialog_type == 'question': dialog_type = Gtk.MessageType.QUESTION button_type = Gtk.ButtonsType.YES_NO dialog = Gtk.MessageDialog(parent, 0, dialog_type, button_type, title) dialog.format_secondary_text(text) response = dialog.run() dialog.destroy() return response
Example #7
Source File: backend_gtk3.py From matplotlib-4-abaqus with MIT License | 6 votes |
def error_msg_gtk(msg, parent=None): if parent is not None: # find the toplevel Gtk.Window parent = parent.get_toplevel() if not parent.is_toplevel(): parent = None if not is_string_like(msg): msg = ','.join(map(str,msg)) dialog = Gtk.MessageDialog( parent = parent, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK, message_format = msg) dialog.run() dialog.destroy()
Example #8
Source File: mainwindow.py From lplayer with MIT License | 6 votes |
def on_remove_track(self, widget): if self.active_row is not None: if len(self.trackview.get_selected_rows()) > 1: msg = _('Are you sure to delete the tracks?') else: msg = _('Are you sure to delete the track?') dialog = Gtk.MessageDialog( self, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, msg) if dialog.run() == Gtk.ResponseType.OK: dialog.destroy() self.remove_rows(self.trackview.get_selected_rows()) else: dialog.destroy()
Example #9
Source File: preferences.py From indicator-sysmonitor with GNU General Public License v3.0 | 6 votes |
def on_save(self, evnt=None, data=None): """The action of the save button.""" try: self.update_parent() except Exception as ex: error_dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, ex) error_dialog.set_title("Error") error_dialog.run() error_dialog.destroy() return False self.ind_parent.save_settings() self.update_autostart() self.destroy()
Example #10
Source File: gtk.py From encompass with GNU General Public License v3.0 | 6 votes |
def restore_wallet(self, wallet): dialog = Gtk.MessageDialog( parent = None, flags = Gtk.DialogFlags.MODAL, buttons = Gtk.ButtonsType.CANCEL, message_format = "Please wait..." ) dialog.show() def recover_thread( wallet, dialog ): wallet.restore(lambda x:x) GObject.idle_add( dialog.destroy ) thread.start_new_thread( recover_thread, ( wallet, dialog ) ) r = dialog.run() dialog.destroy() if r==Gtk.ResponseType.CANCEL: return False if not wallet.is_found(): show_message("No transactions found for this seed") return True
Example #11
Source File: backend_gtk3.py From neural-network-animation with MIT License | 6 votes |
def error_msg_gtk(msg, parent=None): if parent is not None: # find the toplevel Gtk.Window parent = parent.get_toplevel() if not parent.is_toplevel(): parent = None if not is_string_like(msg): msg = ','.join(map(str,msg)) dialog = Gtk.MessageDialog( parent = parent, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK, message_format = msg) dialog.run() dialog.destroy()
Example #12
Source File: RemarkableWindow.py From Remarkable with MIT License | 6 votes |
def check_for_save(self, widget): reply = False if self.text_buffer.get_modified(): message = "Do you want to save the changes you have made?" dialog = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, message) dialog.set_title("Save?") dialog.set_default_response(Gtk.ResponseType.YES) if dialog.run() == Gtk.ResponseType.NO: reply = False else: reply = True dialog.destroy() return reply
Example #13
Source File: tomboy.py From gtg with GNU General Public License v3.0 | 6 votes |
def checkTomboyPresent(self): """ Returns true is Tomboy/Gnote is present, otherwise shows a dialog (only once) and returns False """ if not hasattr(self, 'activated'): self.activated = self.findTomboyIconPath() # The notification to disable the plug-in to the user will be # showed only once DIALOG_DESTROY_WITH_PARENT = Gtk.DialogFlags.DESTROY_WITH_PARENT if not self.activated: message = _("Tomboy/Gnote not found. Please install it or " "disable the Tomboy/Gnote plugin in GTG") dialog = Gtk.MessageDialog( parent=self.plugin_api.get_ui().get_window(), flags=DIALOG_DESTROY_WITH_PARENT, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, message_format=message, ) dialog.run() dialog.destroy() return self.activated # Return a textual token to represent the Tomboy widget. It's useful # since the task is saved as pure text
Example #14
Source File: gtkui.py From alienfx with GNU General Public License v3.0 | 6 votes |
def on_action_delete_theme_activate(self, widget): """ Handler for when the "Delete Theme" action is triggered.""" main_window = self.builder.get_object("main_window") dialog = Gtk.MessageDialog(main_window, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO, ("Are you sure you want to delete this theme from disk? " + "This cannot be undone!""")) response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.NO: return if self.themefile.delete_theme_from_disk(): self.theme_loaded_from_file = False self.enable_delete_theme_button(False) self.load_theme("New Theme")
Example #15
Source File: settings_dialog.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
def __delete_break(self, break_config, is_short, on_remove): """ Remove the break after a confirmation. """ def __confirmation_dialog_response(widget, response_id): if response_id == Gtk.ResponseType.OK: if is_short: self.config.get('short_breaks').remove(break_config) else: self.config.get('long_breaks').remove(break_config) on_remove() widget.destroy() messagedialog = Gtk.MessageDialog(parent=self.window, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.WARNING, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, _("Delete"), Gtk.ResponseType.OK), message_format=_("Are you sure you want to delete this break?")) messagedialog.connect("response", __confirmation_dialog_response) messagedialog.format_secondary_text(_("You can't undo this action.")) messagedialog.show()
Example #16
Source File: settings_dialog.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
def on_reset_menu_clicked(self, button): self.popover.hide() def __confirmation_dialog_response(widget, response_id): if response_id == Gtk.ResponseType.OK: utility.reset_config() self.config = Config() # Remove breaks from the container self.box_short_breaks.foreach(lambda element: self.box_short_breaks.remove(element)) self.box_long_breaks.foreach(lambda element: self.box_long_breaks.remove(element)) # Remove plugins from the container self.box_plugins.foreach(lambda element: self.box_plugins.remove(element)) # Initialize again self.__initialize(self.config) widget.destroy() messagedialog = Gtk.MessageDialog(parent=self.window, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.WARNING, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, _("Reset"), Gtk.ResponseType.OK), message_format=_("Are you sure you want to reset all settings to default?")) messagedialog.connect("response", __confirmation_dialog_response) messagedialog.format_secondary_text(_("You can't undo this action.")) messagedialog.show()
Example #17
Source File: window.py From dynamic-wallpaper-editor with GNU General Public License v3.0 | 6 votes |
def confirm_save_modifs(self): if self._is_saved: return True if self.gio_file is None: msg_text = _("There are unsaved modifications to your wallpaper.") else: fn = self.gio_file.get_path().split('/')[-1] msg_text = _("There are unsaved modifications to %s") % fn dialog = Gtk.MessageDialog(modal=True, transient_for=self, \ message_format=msg_text) dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("Discard"), Gtk.ResponseType.NO) dialog.add_button(_("Save"), Gtk.ResponseType.APPLY) result = dialog.run() dialog.destroy() if result == Gtk.ResponseType.APPLY: self.action_save() return True elif result == Gtk.ResponseType.NO: # if discarded return True return False # if cancelled or closed
Example #18
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 6 votes |
def delete_note(self, widget, note_selected): # delete a note from the db # ask for confirmation with a dialog dialog = Gtk.MessageDialog(Gtk.Window(), 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, "Delete note?") dialog.format_secondary_text( "This operation will be irreversible.") response = dialog.run() if response == Gtk.ResponseType.OK: dialog.close() for note in note_selected: self.database.remove_note(note) try: self.scrolledwindow.destroy() except: pass self.refresh(self.database, self.host) elif response == Gtk.ResponseType.CANCEL: dialog.close()
Example #19
Source File: app.py From syncthing-gtk with GNU General Public License v2.0 | 6 votes |
def check_delete(self, mode, id, name): """ Asks user if he really wants to do what he just asked to do """ msg = _("Do you really want to permanently stop synchronizing directory '%s'?") if mode == "device": msg = _("Do you really want remove device '%s' from Syncthing?") d = Gtk.MessageDialog( self["window"], Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg % name ) r = d.run() d.hide() d.destroy() if r == Gtk.ResponseType.YES: # Load config from server (to have something to delete from) self.daemon.read_config(self.cb_delete_config_loaded, None, mode, id)
Example #20
Source File: ICLogon.py From pychess with GNU General Public License v3.0 | 6 votes |
def onHelperConnectionError(self, connection, error): if self.helperconn is not None: dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO) dialog.set_markup(_("Guest logins disabled by FICS server")) text = "PyChess can maintain users status and games list only if it changes\n\ 'open', 'gin' and 'availinfo' user variables.\n\ Do you enable to set these variables on?" dialog.format_secondary_text(text) response = dialog.run() dialog.destroy() self.helperconn.cancel() self.helperconn.close() self.helperconn = None set_user_vars = response == Gtk.ResponseType.YES async def coro(): await self.main_connected_event.wait() self.connection.start_helper_manager(set_user_vars) create_task(coro())
Example #21
Source File: __init__.py From pychess with GNU General Public License v3.0 | 6 votes |
def load_from_xml(self): if os.path.isfile(self.dockLocation): try: self.dock.loadFromXML(self.dockLocation, self.docks) except Exception as e: # We don't send error message when error caused by no more existing SwitcherPanel if e.args[0] != "SwitcherPanel" and "unittest" not in sys.modules.keys(): stringio = StringIO() traceback.print_exc(file=stringio) error = stringio.getvalue() log.error("Dock loading error: %s\n%s" % (e, error)) msg_dia = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CLOSE) msg_dia.set_markup(_( "<b><big>PyChess was unable to load your panel settings</big></b>")) msg_dia.format_secondary_text(_( "Your panel settings have been reset. If this problem repeats, \ you should report it to the developers")) msg_dia.run() msg_dia.hide() os.remove(self.dockLocation) for title, panel, menu_item in self.docks.values(): title.unparent() panel.unparent()
Example #22
Source File: interface.py From RAFCON with Eclipse Public License 1.0 | 6 votes |
def show_notice(query): from gi.repository import Gtk from rafcon.gui.helpers.label import set_button_children_size_request from rafcon.gui.singleton import main_window_controller from xml.sax.saxutils import escape dialog = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.OK) if main_window_controller: dialog.set_transient_for(main_window_controller.view.get_top_widget()) dialog.set_markup(escape(query)) set_button_children_size_request(dialog) dialog.run() dialog.destroy() # overwrite the show_notice_func of the interface: thus the user input is now retrieved from a dialog box and not # from raw input any more
Example #23
Source File: __init__.py From gtg with GNU General Public License v3.0 | 6 votes |
def on_remove_button(self, widget=None, data=None): """ When the remove button is pressed, a confirmation dialog is shown, and if the answer is positive, the backend is deleted. """ backend_id = self.backends_tv.get_selected_backend_id() if backend_id is None: # no backend selected return backend = self.req.get_backend(backend_id) dialog = Gtk.MessageDialog( parent=self.dialog, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO, message_format=_("Do you really want to remove the '%s' " "synchronization service?") % backend.get_human_name()) response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: # delete the backend and remove it from the lateral treeview self.req.remove_backend(backend_id) self.backends_tv.remove_backend(backend_id)
Example #24
Source File: backend_gtk3.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def _show_shortcuts_dialog(self): dialog = Gtk.MessageDialog( self._figure.canvas.get_toplevel(), 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, self._get_help_text(), title="Help") dialog.run() dialog.destroy()
Example #25
Source File: app.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def display_run_daemon_dialog(self): """ Displays 'Syncthing is not running, should I start it for you?' dialog. """ if self.connect_dialog == None: # Don't override already existing dialog log.debug("Creating run_daemon_dialog") self.connect_dialog = Gtk.MessageDialog( self["window"], Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, 0, "%s\n%s" % ( _("Syncthing daemon doesn't appear to be running."), _("Start it now?") ) ) cb = Gtk.CheckButton(_("Always start daemon automatically")) self.connect_dialog.get_content_area().pack_end(cb, False, False, 2) self.connect_dialog.add_button("_Start", RESPONSE_START_DAEMON) self.connect_dialog.add_button("gtk-quit", RESPONSE_QUIT) # There is only one response available on this dialog self.connect_dialog.connect("response", self.cb_connect_dialog_response, cb) if self.is_visible(): self.connect_dialog.show_all() else: cb.show() # Keep this one visible, even if dialog is not # Update notification icon menu so user can start daemon from there self["menu-si-shutdown"].set_visible(False) self["menu-si-resume"].set_visible(True)
Example #26
Source File: app.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def quit(self, *a): if self.process != None: if IS_WINDOWS: # Always kill subprocess on windows self.process.kill() self.process = None elif self.config["autokill_daemon"] == 2: # Ask d = Gtk.MessageDialog( self["window"], Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, 0, "%s\n%s" % ( _("Exiting."), _("Shutdown Syncthing daemon as well?") ) ) d.add_button("gtk-yes", RESPONSE_SLAIN_DAEMON) d.add_button("gtk-no", RESPONSE_SPARE_DAEMON) cb = Gtk.CheckButton(_("Always do same; Don't show this window again")) d.get_content_area().pack_end(cb, False, False, 2) d.connect("response", self.cb_kill_daemon_response, cb) d.show_all() return elif self.config["autokill_daemon"] == 1: # Yes self.process.terminate() self.process = None Gtk.Application.quit(self)
Example #27
Source File: winetricks_cache_backup.py From games_nebula with GNU General Public License v3.0 | 5 votes |
def cb_button_restore_backup(self, button): self.config_save() files_cache = os.listdir(self.winetricks_cache) files_backup = os.listdir(self.winetricks_cache_backup) files_to_copy = list(set(files_backup) - set(files_cache)) self.n_files_to_copy = len(files_to_copy) if self.n_files_to_copy == 0: message_dialog = Gtk.MessageDialog( self.main_window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("All files from backup exists in cache"), width_request = 360 ) content_area = message_dialog.get_content_area() content_area.set_property('margin-left', 10) content_area.set_property('margin-right', 10) content_area.set_property('margin-top', 10) content_area.set_property('margin-bottom', 10) action_area = message_dialog.get_action_area() action_area.set_property('spacing', 10) self.main_window.hide() message_dialog.run() message_dialog.destroy() self.main_window.show() else: self.button_make_backup.set_visible(False) self.button_restore_backup.set_visible(False) self.progressbar.set_visible(True) for file_name in files_to_copy: self.copy_files(file_name, 'restore_backup')
Example #28
Source File: app.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def display_connect_dialog(self, message, quit_button=True): """ Displays 'Be patient, i'm trying to connect here' dialog, or updates it's message if said dialog is already displayed. """ if self.connect_dialog == None: log.debug("Creating connect_dialog") self.connect_dialog = Gtk.MessageDialog( self["window"], Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, 0, "-") if quit_button: self.connect_dialog.add_button("gtk-quit", RESPONSE_QUIT) # There is only one response available on this dialog self.connect_dialog.connect("response", self.cb_connect_dialog_response, None) if self.is_visible(): self.connect_dialog.show_all() def set_label(d, message): """ Small, recursive helper function to set label somehwere deep in dialog """ for c in d.get_children(): if isinstance(c, Gtk.Container): if set_label(c, message): return True elif isinstance(c, Gtk.Label): c.set_markup(message) return True return False log.verbose("Setting connect_dialog label %s" % message[0:15]) set_label(self.connect_dialog.get_content_area(), message)
Example #29
Source File: editordialog.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def syncthing_cb_post_error(self, exception, *a): # TODO: Unified error message if isinstance(exception, ConnectionRestarted): # Should be ok, this restart is triggered # by App handler for 'config-saved' event. return self.syncthing_cb_post_config() message = "%s\n%s" % ( _("Failed to save configuration."), str(exception) ) if hasattr(exception, "full_response"): try: fr = unicode(exception.full_response)[0:1024] except UnicodeError: # ... localized error strings on windows are usually # in anything but unicode :( fr = str(repr(exception.full_response))[0:1024] message += "\n\n" + fr d = Gtk.MessageDialog( self["editor"], Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, message ) d.run() d.hide() d.destroy() self["editor"].set_sensitive(True)
Example #30
Source File: __init__.py From pychess with GNU General Public License v3.0 | 5 votes |
def create_database(self): dialog = Gtk.FileChooserDialog( _("Create New Pgn Database"), mainwindow(), Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_NEW, Gtk.ResponseType.ACCEPT)) dialog.set_current_folder(os.path.expanduser("~")) dialog.set_current_name("new.pgn") response = dialog.run() if response == Gtk.ResponseType.ACCEPT: new_pgn = dialog.get_filename() if not new_pgn.endswith(".pgn"): new_pgn = "%s.pgn" % new_pgn if not os.path.isfile(new_pgn): # create new file with open(new_pgn, "w"): pass self.open_chessfile(new_pgn) else: d = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK) d.set_markup(_("<big><b>File '%s' already exists.</b></big>") % new_pgn) d.run() d.destroy() dialog.destroy()