-
Notifications
You must be signed in to change notification settings - Fork 14
/
tkinter_extra_widgets.py
66 lines (50 loc) · 1.5 KB
/
tkinter_extra_widgets.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from tkinter import Tk,Frame,BOTH,LEFT,Listbox,Button,ANCHOR,X,Text
from tkinter.ttk import Combobox,Progressbar
def getValue():
print("Combo : "+str(combobox.get()))
print("Text : "+str(textbox.get("1.0","end-1c")))
print("List Box : "+str(listbox.get(ANCHOR)))
def onChangeValue(object):
print("Value "+str(combobox.get()))
def IncreaseValue():
progress['value']=progress['value']+1
def decreaseValue():
progress['value']=progress['value']-1
window=Tk()
#window.geometry("400x300")
window.title("Extra Widgets")
#combobox
frame=Frame(window)
frame.pack(fill=X)
combobox=Combobox(frame)
items=(1,2,3,"Hello","World")
combobox['values']=items
combobox.current(1)
combobox.bind("<<ComboboxSelected>>",onChangeValue)
combobox.pack(side=LEFT)
#end combo box
#listbox
listbox=Listbox(frame)
listbox.insert(0,"Rahul")
listbox.insert(1,"Rajiv")
listbox.insert(2,"Aman")
listbox.insert(3,"Vishal")
listbox.pack(side=LEFT)
textbox=Text(frame)
textbox.pack(side=LEFT)
button_get_value=Button(frame,text="Get Value",command=getValue)
button_get_value.pack(side=LEFT)
frame2=Frame(window)
frame2.pack()
progress=Progressbar(frame2,length=100)
progress.pack(side=LEFT)
progress['value']=50
#indeterminate progress
progress2=Progressbar(frame2,length=100, mode='indeterminate')
progress2.pack(side=LEFT)
progress2.start()
button1=Button(frame2,text="Increase",command=IncreaseValue)
button1.pack(side=LEFT)
button1=Button(frame2,text="Increase",command=decreaseValue)
button1.pack(side=LEFT)
window.mainloop()