- PyGTK - Drag and Drop
- PyGTK - Timeout
- PyGTK - Ruler Class
- PyGTK - Clipboard Class
- PyGTK - Calendar Class
- PyGTK - SpinButton Class
- PyGTK - DrawingArea Class
- PyGTK - Image Class
- PyGTK - Arrow Class
- PyGTK - Scrolledwindow Class
- PyGTK - Viewport Class
- PyGTK - ProgressBar Class
- PyGTK - Statusbar Class
- PyGTK - Paned Class
- PyGTK - TreeView Class
- PyGTK - AspectFrame Class
- PyGTK - Frame Class
- PyGTK - Notebook Class
- PyGTK - File Chooser Dialog
- PyGTK - Color Selection Dialog
- PyGTK - Font Selection Dialog
- PyGTK - AboutDialog Class
- PyGTK - MessageDialog Class
- PyGTK - Dialog Class
- PyGTK - Scrollbar Class
- PyGTK - Scale Class
- PyGTK - Range Class
- PyGTK - Adjustment Class
- PyGTK - Toolbar Class
- PyGTK - MenuBar, Menu & MenuItem
- PyGTK - RadioButton Class
- PyGTK - CheckButton Class
- PyGTK - ToggleButton Class
- PyGTK - ComboBox Class
- PyGTK - Layout Class
- PyGTK - EventBox Class
- PyGTK - Alignment Class
- PyGTK - ButtonBox Class
- PyGTK - Box Class
- PyGTK - Containers
- PyGTK - Event Handling
- PyGTK - Signal Handling
- PyGTK - Entry Class
- PyGTK - Label CLass
- PyGTK - Button Class
- PyGTK - Window Class
- PyGTK - Important Classes
- PyGTK - Hello World
- PyGTK - Environment
- PyGTK - Introduction
- PyGTK - Home
PyGTK Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
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 cpcked.
The gtk.Button class has the following constructor −
gtk.Button(label = None, stock = None, use_underpne = True)
Wherein,
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.
Underpne − If True, an underscore in the text indicates the next character should be underpned and used for the mnemonic accelerator.
Some of the predefined constants for stock parameter are −
STOCK_OK
STOCK_STOP
STOCK_YES
STOCK_NO
STOCK_QUIT
STOCK_CANCEL
STOCK_CLOSE
The Button class has the following important methods −
S.NO | Methods and Description |
---|---|
1 | set_label() 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. |
2 | get_label() This retrieves the text from the label of the button |
3 | set_focus_on_cpck() If True, the button grabs focus when cpcked with the mouse. |
4 | set_apgnment() This is the horizontal and vertical apgnment of the child widget. The value ranges from 0.0 to 1.0. |
5 | set_image() 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 "cpcked" signal to be emitted. |
cpcked | 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. |