25def show_window(event):
26 """This is called by butShow and shows the secondary window."""
32def hide_window(event):
33 """This is called by butDel (or if you click the upperleft close
34 button): hides the secondary window and passes what we typed to
38 s = ent1.get_content()
40 labCont.set_content(
"You typed: " + s)
42 labCont.set_content(
"You don't type anything")
45def change_window(event):
46 """This is called by the radiobuttons and sets the secondary
47 window properties (normal, modal or persistent).
"""
48 winSec.set_modal(strType.get())
52winMain = Ntk.Main(200, 150, 600, 450,
"Main Window")
54rfr1 = Ntk.RowFrame(winMain, 0, 0,
"fill",
"fill")
55rfr1.config_children(
"all", fcolor=
"dark blue", font=(
"DefaultFont", 12))
56rfr1.config_children(Ntk.Label, bcolor=
"#E0E0A0", relief=
"ridge")
60butShow = Ntk.Button(rfr1,
"center",
"center",
"40%",
"80%", content=
"Show the window",
63strType = Ntk.StringVar()
67radNormal = Ntk.Radiobutton(rfr1, 20, 0, 120,
"fill", pad=(10, 10, 0, 10),
68 content=
" Normal ", command=change_window)
69radNormal.set_variable(strType,
"normal")
70labNormal = Ntk.Label(rfr1,
"pack", 0,
"fill",
"fill", pad=(5, 10, 20, 10),
71 content=
"The window will be a normal window")
75radModal = Ntk.Radiobutton(rfr1, 20, 0, 120,
"fill", pad=(10, 10, 0, 10),
76 content=
" Modal ", command=change_window)
77radModal.set_variable(strType,
"modal")
78labModal = Ntk.Label(rfr1,
"pack", 0,
"fill",
"fill", pad=(5, 10, 20, 10),
79 content=
"The window will always be visible, and mantain the focus until you close it")
83radPers = Ntk.Radiobutton(rfr1, 20, 0, 120,
"fill", pad=(10, 10, 0, 10),
84 content=
"Persistent", command=change_window)
85radPers.set_variable(strType,
"persistent")
86labPers = Ntk.Label(rfr1,
"pack", 0,
"fill",
"fill", pad=(5, 10, 20, 10),
87 content=
"The window will always be visible, but can lose the focus")
91labCont = Ntk.Label(rfr1,
"pack", 0,
"fill",
"fill", pad=(10, 10, 20, 10))
92labCont.config(anchor=
"center")
95winSec = Ntk.Window(
None, 220, 220, 300, 200,
"Secondary Window")
96lbl1 = Ntk.Label(winSec, 0, 0,
"fill",
"30%", pad=10, content=
"Type something below")
97lbl1.config(bcolor=
"#E0E0A0")
98ent1 = Ntk.Entry(winSec, 0,
"pack",
"fill",
"30%", pad=(30, 10))
99ent1.config(bcolor=
"#F0D0D0")
100butExit = Ntk.Button(winSec, 220, 160, 70, 30, content=
"Exit", command=hide_window)
102winSec.onclose(hide_window)