本文整理汇总了Python中gtk.DIALOG_MODAL属性的典型用法代码示例。如果您正苦于以下问题:Python gtk.DIALOG_MODAL属性的具体用法?Python gtk.DIALOG_MODAL怎么用?Python gtk.DIALOG_MODAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gtk
的用法示例。
在下文中一共展示了gtk.DIALOG_MODAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: quit
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
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()
示例2: gerr
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def gerr(message = None):
"""Display a graphical error. This should only be used for serious
errors as it will halt execution"""
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
dialog.run()
dialog.destroy()
示例3: key_edit_window_title
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
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
示例4: _create_command_dialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
dialog = gtk.Dialog(
_("New Command"),
None,
gtk.DIALOG_MODAL,
(
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
)
)
table = gtk.Table(3, 2)
label = gtk.Label(_("Enabled:"))
table.attach(label, 0, 1, 0, 1)
enabled = gtk.CheckButton()
enabled.set_active(enabled_var)
table.attach(enabled, 1, 2, 0, 1)
label = gtk.Label(_("Name:"))
table.attach(label, 0, 1, 1, 2)
name = gtk.Entry()
name.set_text(name_var)
table.attach(name, 1, 2, 1, 2)
label = gtk.Label(_("Command:"))
table.attach(label, 0, 1, 2, 3)
command = gtk.Entry()
command.set_text(command_var)
table.attach(command, 1, 2, 2, 3)
dialog.vbox.pack_start(table)
dialog.show_all()
return (dialog,enabled,name,command)
示例5: _error
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def _error(self, msg):
err = gtk.MessageDialog(dialog,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
msg
)
err.run()
err.destroy()
示例6: start_logger
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def start_logger(self, _widget, Terminal):
""" Handle menu item callback by saving text to a file"""
savedialog = gtk.FileChooserDialog(title="Save Log File As",
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
savedialog.show_all()
response = savedialog.run()
if response == gtk.RESPONSE_OK:
try:
logfile = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
fd = open(logfile, 'w+')
# Save log file path,
# associated file descriptor, signal handler id
# and last saved col,row positions respectively.
vte_terminal = Terminal.get_vte()
(col, row) = vte_terminal.get_cursor_position()
self.loggers[vte_terminal] = {"filepath":logfile,
"handler_id":0, "fd":fd,
"col":col, "row":row}
# Add contents-changed callback
self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
except:
e = sys.exc_info()[1]
error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK, e.strerror)
error.run()
error.destroy()
savedialog.destroy()
示例7: message
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def message(self, text, title):
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO,
gtk.BUTTONS_CLOSE,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
dlg.run()
dlg.destroy()
示例8: question_yes_no
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def question_yes_no(self, text, title):
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_YES_NO,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
response = dlg.run()
dlg.destroy()
if response == gtk.RESPONSE_YES:
return True
return False
示例9: inputdialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def inputdialog(self, text, title, default_response=""):
# Define a little helper function
def inputdialog_entry_activated(entry):
dlg.response(gtk.RESPONSE_OK)
# Create the dialog
dlg = gtk.MessageDialog(self.window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_OK_CANCEL,
title)
dlg.set_title(title)
dlg.format_secondary_text(text)
# Create an entry widget
entry = gtk.Entry()
entry.set_text(default_response)
entry.connect("activate", inputdialog_entry_activated)
dlg.vbox.pack_start(entry)
entry.show()
# Run the dialog
response = dlg.run()
dlg.destroy()
if response == gtk.RESPONSE_OK:
return entry.get_text()
return None
示例10: confirmDialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def confirmDialog(parent, message):
"""Creates a confirmation dialog and returns the response."""
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, message)
dialog.show()
response = dialog.run()
dialog.destroy()
return response
示例11: errorDialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def errorDialog(parent=None, message="An error has occured!"):
"""Creates an error dialog."""
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
dialog.show()
dialog.run()
dialog.destroy()
示例12: show_dialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def show_dialog(self, title, surname, group):
labelSurname = gtk.Label(_("Surname"))
entrySurname = gtk.Entry()
if surname:
entrySurname.set_text(surname)
labelGroup = gtk.Label(_("Group"))
entryGroup = gtk.Entry()
if group:
entryGroup.set_text(group)
dialog = gtk.Dialog(title,
None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
table = gtk.Table(2, 2)
table.attach(labelSurname, 0, 1, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.EXPAND, xpadding=5, ypadding=5)
table.attach(labelGroup, 0, 1, 1, 2, xoptions=gtk.SHRINK, yoptions=gtk.EXPAND, xpadding=5, ypadding=5)
table.attach(entrySurname, 1, 2, 0, 1, xoptions=gtk.FILL, yoptions=gtk.EXPAND, xpadding=5, ypadding=5)
table.attach(entryGroup, 1, 2, 1, 2, xoptions=gtk.FILL, yoptions=gtk.EXPAND, xpadding=5, ypadding=5)
dialog.vbox.pack_start(table, fill=True, expand=True)
dialog.show_all()
response = dialog.run()
if response == gtk.RESPONSE_ACCEPT:
result = (entrySurname.get_text(), entryGroup.get_text())
else:
result = None
dialog.destroy()
return result
示例13: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def __init__(self, title, message, parent=None, modal=False):
if modal:
modal = gtk.DIALOG_MODAL
else:
modal = 0
gtk.Dialog.__init__(self, title, parent, modal, (gtk.STOCK_OK, gtk.RESPONSE_OK))
self.message = message
label = gtk.Label(message)
self.get_content_area().add(label)
self.set_position(gtk.WIN_POS_CENTER)
self.set_gravity(gtk.gdk.GRAVITY_CENTER)
self.show_all()
示例14: message
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
def message(self, data):
"""Function to display messages to the user
"""
msg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO,
gtk.BUTTONS_CLOSE, data)
msg.set_resizable(1)
msg.set_title(self.dialog_title)
self.img.set_from_file(self.sun_icon)
msg.set_image(self.img)
msg.show_all()
msg.run()
msg.destroy()
示例15: get_password
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import DIALOG_MODAL [as 别名]
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