本文整理汇总了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")
示例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()
示例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
示例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()
示例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()
示例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
示例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()
示例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()
示例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
示例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
示例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)
示例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
示例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
示例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()
示例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())