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


Python Gtk.MessageDialog方法代码示例

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


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

示例1: on_action_delete_theme_activate

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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") 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:19,代码来源:gtkui.py

示例2: error_msg_gtk

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_gtk3.py

示例3: window_deleted_cb

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:textext,项目名称:textext,代码行数:24,代码来源:asktext.py

示例4: disconnected

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:epoptes,项目名称:epoptes,代码行数:21,代码来源:gui.py

示例5: error_msg_gtk

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:18,代码来源:backend_gtk3.py

示例6: message_dialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:ImEditor,项目名称:ImEditor,代码行数:19,代码来源:dialog.py

示例7: on_remove_track

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:atareao,项目名称:lplayer,代码行数:19,代码来源:mainwindow.py

示例8: on_save

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:fossfreedom,项目名称:indicator-sysmonitor,代码行数:18,代码来源:preferences.py

示例9: restore_wallet

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:mazaclub,项目名称:encompass,代码行数:23,代码来源:gtk.py

示例10: check_for_save

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:jamiemcg,项目名称:Remarkable,代码行数:19,代码来源:RemarkableWindow.py

示例11: on_remove_button

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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) 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:26,代码来源:__init__.py

示例12: checkTomboyPresent

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:26,代码来源:tomboy.py

示例13: show_notice

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:18,代码来源:interface.py

示例14: load_from_xml

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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() 
开发者ID:pychess,项目名称:pychess,代码行数:27,代码来源:__init__.py

示例15: onHelperConnectionError

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import MessageDialog [as 别名]
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()) 
开发者ID:pychess,项目名称:pychess,代码行数:24,代码来源:ICLogon.py


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