- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetFocusAndDisableWidget.py
More file actions
Latest commit
28 lines (21 loc) · 674 Bytes
/
Copy pathSetFocusAndDisableWidget.py
File metadata and controls
28 lines (21 loc) · 674 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
importtkinterastk
fromtkinterimportttk
win=tk.Tk()
win.title('Set Focus and Disable Widgets')
aLabel=ttk.Label(win, text='A label')
aLabel.grid(column=0, row=0)
# Modified Button Click Function
defclickMe():
action.configure(text='Hello '+name.get())
# Changing the label
ttk.Label(win, text='Enter a name:').grid(column=0,row=0)
# Adding a Textbox Entry widget
name=tk.StringVar()
nameEntered=ttk.Entry(win, width=12,textvariable=name)
nameEntered.grid(column=0,row=1)
# Adding a Button
action=ttk.Button(win, text='Click Me!', command=clickMe)
action.configure(state='disabled')
action.grid(column=1,row=1)
nameEntered.focus()
win.mainloop()