forked from schedutron/CPAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
animalGtk.pyw
52 lines (44 loc) · 1.5 KB
/
animalGtk.pyw
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import pygtk
pygtk.require("2.0")
import gtk
import pango
class GTKApp:
def __init__(self):
top = gtk.Window(gtk.WINDOW_TOPLEVEL)
top.connect("delete_event", gtk.main_quit)
top.connect("destroy", gtk.main_quit)
box = gtk.VBox(False, 0)
lb = gtk.Label("Animals (in pairs; min: pair, max: dozen)")
box.pack_start(lb)
sb = gtk.HBox(False, 0)
adj = gtk.Adjustment(2, 2, 12, 2, 4, 0) # 4 and 0 are page increment and page size, respectively.
sl = gtk.Label("Number: ")
sl.modify_font(pango.FontDescription("Arial Bold 10"))
sb.pack_start(sl)
ct = gtk.SpinButton(adj, 0, 0)
sb.pack_start(ct)
box.pack_start(sb)
cb = gtk.HBox(False, 0)
c2 = gtk.Label("Type: ")
cb.pack_start(c2)
ce = gtk.combo_box_entry_new_text()
for animal in ("dog", "cat", "hamster", "python"):
ce.append_text(animal)
cb.pack_start(ce)
box.pack_start(cb)
qb = gtk.Button("")
red = gtk.gdk.color_parse("red")
sty = qb.get_style()
for st in (gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE):
sty.bg[st] = red
qb.set_style(sty)
q1 = qb.child
q1.set_markup('<span color="white">QUIT</span>')
qb.connect_object("clicked", gtk.Widget.destroy, top)
box.pack_start(qb)
top.add(box)
top.show_all()
if __name__ == "__main__":
animal = GTKApp()
gtk.main()