Friday, July 20, 2018

PyGTK - MessageDialog Class

PyGTK - MessageDialog Class


A Messagedialog widget is a Dialog window configured to display an image representing the type of message, i.e., error, question, or some informational text. A MessageDialog object is declared by using the following constructor −
gtk.MessageDialog(parent = None, flags = 0, type = gtk.MESSAGE_INFO, 
   buttons = gtk.BUTTONS_NONE, message_format = None)
The following predefined message types are used to configure message dialog −
gtk.MESSAGE_INFOThis is an informational message
gtk.MESSAGE_WARNINGThis is a nonfatal warning message
gtk.MESSAGE_QUESTIONThis question requires a choice
gtk.MESSAGE_ERRORThis is a fatal error message
A set of predefined button sets are also available for use.
gtk.BUTTONS_NONENo buttons at all
gtk.BUTTONS_OKThis is an OK button
gtk.BUTTONS_CLOSEThis is a Close button
gtk.BUTTONS_CANCELThis is a Cancel button
gtk.BUTTONS_YES_NOThese are the Yes and No buttons
gtk.BUTTONS_OK_CANCELThese are OK and Cancel buttons
When the MessageBox menu item is activated, the following callback function is called and a message box pops up as an output.
def on_msgdlg(self, widget):
   md = gtk.MessageDialog(self,
      gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
      gtk.BUTTONS_CLOSE, "Error message")
   md.run()
The above function will generate the following output −
Error Message

No comments:

Post a Comment