Gtk.CheckButton
继承关系
Gtk.CheckButton复选框。Gtk.CheckButton是Gtk.ToggleButton的直接子类
Methods
| 方法修饰词 | 方法名及参数 |
|---|---|
| static | new () |
| static | new_with_label (label) |
| static | new_with_mnemonic (label) |
Virtual Methods
| do_draw_indicator (cr) |
例子
代码:
#!/usr/bin/env python3
# Created by xiaosanyu at 16/6/14
# section 011
TITLE = "CheckButton"
DESCRIPTION = """
A Gtk.CheckButton places a discrete Gtk.ToggleButton next to a widget,
(usually a Gtk.Label). See the section on Gtk.ToggleButton widgets for more information about toggle/check buttons.
The important signal ( Gtk.ToggleButton ::toggled ) is also inherited from Gtk.ToggleButton.
"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class CheckButtonWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="CheckButton Demo")
self.set_border_width(10)
hbox = Gtk.Box(spacing=6)
self.add(hbox)
button1 = Gtk.CheckButton.new_with_label("Check Button")
button1.connect("toggled", self.on_button_toggled)
hbox.pack_start(button1, False, False, 0)
@staticmethod
def on_button_toggled(button):
if button.get_active():
state = "check"
else:
state = "not check"
print("Button was", state)
def main():
win = CheckButtonWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
使用方法同Gtk.ToggleButton
只是多一个复选框而已
代码下载地址:http://download.youkuaiyun.com/detail/a87b01c14/9594728

本文介绍Gtk.CheckButton组件的使用方法,它是Gtk.ToggleButton的一个子类,用于创建复选框。文章提供了一个Python示例,展示了如何创建一个带标签的复选按钮,并监听其状态改变。
764

被折叠的 条评论
为什么被折叠?



