forked from sebp/PyGObject-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbutton_example.py
More file actions
31 lines (24 loc) · 906 Bytes
/
checkbutton_example.py
File metadata and controls
31 lines (24 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
button = Gtk.CheckButton("Button 1")
button.connect("toggled", self.on_button_toggled, "1")
hbox.pack_start(button, False, False, 0)
button = Gtk.CheckButton("B_utton 2", use_underline=True)
button.set_active(True)
button.connect("toggled", self.on_button_toggled, "2")
hbox.pack_start(button, False, False, 0)
def on_button_toggled(self, button, name):
if button.get_active():
state = "on"
else:
state = "off"
print("Button", name, "was turned", state)
win = CheckButtonWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()