📜  PyGTK-MessageDialog类

📅  最后修改于: 2020-11-08 07:55:18             🧑  作者: Mango


Messagedialog小部件是一个Dialog窗口,配置为显示代表消息类型的图像,即错误,问题或某些参考文本。通过使用以下构造函数声明MessageDialog对象-

gtk.MessageDialog(parent = None, flags = 0, type = gtk.MESSAGE_INFO, 
   buttons = gtk.BUTTONS_NONE, message_format = None)

以下预定义的消息类型用于配置消息对话框-

gtk.MESSAGE_INFO This is an informational message
gtk.MESSAGE_WARNING This is a nonfatal warning message
gtk.MESSAGE_QUESTION This question requires a choice
gtk.MESSAGE_ERROR This is a fatal error message

也可以使用一组预定义的按钮集。

gtk.BUTTONS_NONE No buttons at all
gtk.BUTTONS_OK This is an OK button
gtk.BUTTONS_CLOSE This is a Close button
gtk.BUTTONS_CANCEL This is a Cancel button
gtk.BUTTONS_YES_NO These are the Yes and No buttons
gtk.BUTTONS_OK_CANCEL These are OK and Cancel buttons

激活MessageBox菜单项后,将调用以下回调函数,并弹出一个消息框作为输出。

def on_msgdlg(self, widget):
   md = gtk.MessageDialog(self,
      gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
      gtk.BUTTONS_CLOSE, "Error message")
   md.run()

上面的函数将生成以下输出-

错误信息