PyGTK - Button Class
The gtk.Button widget is usually displayed as a pushbutton with a text label. It is generally used to attach a callback function or method that is called when the button is clicked.
The gtk.Button class has the following constructor −
gtk.Button(label = None, stock = None, use_underline = True)
Label − The text to be displayed by the button label
Stock − The stock id identifying the stock image and text to be used in the button. Default is None.
Underline − If True, an underscore in the text indicates the next character should be underlined and used for the mnemonic accelerator.
Some of the predefined constants for stock parameter are −
The Button class has the following important methods −
|S.NO||Methods and Description|
This sets the text of the button label to label. This string is also used to select the stock item if the "use_stock" property is True.
This retrieves the text from the label of the button
If True, the button grabs focus when clicked with the mouse.
This is the horizontal and vertical alignment of the child widget. The value ranges from 0.0 to 1.0.
This sets the image property to the value of image. The "gtkbutton-images" property should be set to True.
The following signals are emitted by the Button widget −
|activate||This is emitted when the gtk.Widget's activate() method is called. For a button it causes the "clicked" signal to be emitted.|
|clicked||This is emitted when the mouse button is pressed and released while the pointer is over the button or when the button is triggered with the keyboard.|