26CITIES = (
"Bari",
"Bologna",
"Firenze",
"Milano",
"Napoli",
"Palermo",
27 "Roma",
"Torino",
"Venezia")
29MODES = {
"normal":
"You can change the Spinbox value clicking on buttons or typing in it and pressing <RETURN>",
30 "readonly":
"You can only use up and down buttons",
31 "autoadd":
"As Normal, but every new value you type is added to the Spinbox list"}
33WRAPS = [
"When you arrive at the end of the list you can continue from the beginning",
34 "When you arrive at the end of the list you cannot go beyond"]
37def change_label(event):
40 labSample.config(fcolor=
"dark blue")
41 labSample.set_content(
"Selected city: " + w.get_content())
43 labSample.config(fcolor=
"brown")
44 labSample.set_content(
"Selected number: " + w.get_content())
47def change_mode(event):
49 labMode.set_content(MODES[opt])
52def change_wrap(event):
54 labWrap.set_content(WRAPS[0]
if opt
else WRAPS[1])
58winMain = Ntk.Main(200, 150, 640, 480,
"Spinbox")
60vfr1 = Ntk.HorFrame(winMain, 0, 0, FILL, -60)
63rfr1 = Ntk.RowFrame(vfr1, 0, 0,
"50%", FILL, content=
"Spinbox1")
64rfr1.config(bcolor=
"#B0D0D0", relief=RIDGE )
65rfr1.config_children(ALL, bcolor=
"#B0D0B0")
66rfr1.config_children(Ntk.Spinbox, rbcolor=
"#A0C0A0")
69spb1 = Ntk.Spinbox(rfr1, CENTER, 0,
"50%", FILL, pad=(0, 3), limits=CITIES,
73labModeTitle = Ntk.Label(rfr1, 0, 0, FILL, FILL, pad=(0, 5),
74 content=
"Spinbox modes")
75labModeTitle.config(bcolor=rfr1.get_config(
"bcolor"), relief=FLAT, anchor=S,
79vfrMode = Ntk.VerFrame(rfr1, 0, CENTER,
"40%",
"80%")
80vfrMode.config(relief=SUNKEN)
82optMode = Ntk.StringVar()
83tempT = tuple(MODES.keys())
84radMode1 = Ntk.Radiobutton(vfrMode, 0, PACK, FILL,
"33%", content=tempT[0],
85 variable=(optMode, tempT[0]), command=change_mode)
86radMode2 = Ntk.Radiobutton(vfrMode, 0, PACK, FILL,
"33%", content=tempT[1],
87 variable=(optMode, tempT[1]), command=change_mode)
88radMode3 = Ntk.Radiobutton(vfrMode, 0, PACK, FILL,
"33%", content=tempT[2],
89 variable=(optMode, tempT[2]), command=change_mode)
90labMode = Ntk.Label(rfr1, PACK, CENTER, FILL,
"80%", pad=(5, 0,10, 0))
91labMode.config(anchor=NW)
94labWrapTitle = Ntk.Label(rfr1, 0, 0, FILL, FILL, pad=(0, 5),
95 content=
"Enable wrap")
96labWrapTitle.config(bcolor=rfr1.get_config(
"bcolor"), relief=FLAT, anchor=S,
100optWrap = Ntk.BooleanVar()
101vfrWrap = Ntk.VerFrame(rfr1, 0, CENTER,
"40%",
"80%")
102vfrWrap.config(relief=SUNKEN)
103radWrap1 = Ntk.Radiobutton(vfrWrap, 0, PACK, FILL,
"50%", content=
"True",
104 variable=(optWrap,
True), command=change_wrap)
105radWrap2 = Ntk.Radiobutton(vfrWrap, 0, PACK, FILL,
"50%", content=
"False",
106 variable=(optWrap,
False), command=change_wrap)
107labWrap = Ntk.Label(rfr1, PACK, CENTER, FILL,
"80%", pad=(5, 0,10, 0))
108labWrap.config(anchor=NW)
111rfr2 = Ntk.RowFrame(vfr1, PACK, 0, FILL, FILL, content=
"Spinbox2")
112rfr2.config(bcolor=
"#FFFFA0", relief=RIDGE)
114spb2 = Ntk.Spinbox(rfr2, CENTER, 0,
"50%", FILL, pad=(0,3),
115 limits=(1.0, 10.0, 0.5), command=change_label)
118labSample = Ntk.Label(winMain, CENTER, PACK, 280, FILL, pad=(0, 5),
119 content=
"Try the spinboxes!")
120labSample.config(bcolor=
"pink", anchor=CENTER, font=(
"Arial", 16))
Definition: constants.py:1