- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateCheckButton.py
More file actions
Latest commit
48 lines (34 loc) · 1.21 KB
/
Copy pathCreateCheckButton.py
File metadata and controls
48 lines (34 loc) · 1.21 KB
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
importtkinterastk
fromtkinterimportttk
win=tk.Tk()
win.title('Create Checkbutton')
ttk.Label(win,text='Choose a number:').grid(column=0, row=0)
number=tk.StringVar()
numberChosen=ttk.Combobox(win, width=12,textvariable=number)
numberChosen['values'] = (1,2,4,42,100)
numberChosen.grid(column=1,row=1)
numberChosen.current(0)
# Create three checkbuttons
chVarDis=tk.IntVar()
check1=tk.Checkbutton(win,text='Disabled', variable=chVarDis, state='disabled')
check1.select()
check1.grid(column=0,row=4,sticky=tk.W)
chVarUn=tk.IntVar()
check2=tk.Checkbutton(win, text='UnChecked', variable=chVarUn)
check2.deselect()
check2.grid(column=1, row=4, sticky=tk.W)
chVarEn=tk.IntVar()
check3=tk.Checkbutton(win,text='Enabled', variable=chVarEn)
check3.select()
check3.grid(column=2,row=4,sticky=tk.W)
# We are hardcoding the width so the widget will not expand.
name=tk.StringVar()
nameEntered=ttk.Entry(win, width=12, textvariable=name)
nameEntered.grid(column=0,row=1)
# Adding a Button
nameEntered.focus()
defclickMe():
action.configure(text='Hello '+name.get() +' '+numberChosen.get())
action=ttk.Button(win, text='Click Me!', command=clickMe)
action.grid(column=2, row=1)
win.mainloop()