📅  最后修改于: 2020-11-08 07:46:23             🧑  作者: Mango
gtk.Button小部件通常显示为带有文本标签的按钮。通常用于附加单击按钮时调用的回调函数或方法。
gtk.Button类具有以下构造函数-
gtk.Button(label = None, stock = None, use_underline = True)
其中,
标签-按钮标签要显示的文本
Stock-库存ID,标识要在按钮中使用的库存图像和文本。默认为无。
下划线-如果为True,则文本中的下划线表示下一个字符应加下划线并用于助记符加速器。
股票参数的一些预定义常量是-
Button类具有以下重要方法-
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_click() If True, the button grabs focus when clicked with the mouse. |
4 |
set_alignment() This is the horizontal and vertical alignment 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. |
Button小部件发出以下信号-
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. |