• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from Tkinter import *
2
3# shows how to make a slider, set and get its value under program control
4
5
6class Test(Frame):
7    def print_value(self, val):
8        print "slider now at", val
9
10    def reset(self):
11        self.slider.set(0)
12
13    def createWidgets(self):
14        self.slider = Scale(self, from_=0, to=100,
15                            orient=HORIZONTAL,
16                            length="3i",
17                            label="happy slider",
18                            command=self.print_value)
19
20        self.reset = Button(self, text='reset slider',
21                            command=self.reset)
22
23        self.QUIT = Button(self, text='QUIT', foreground='red',
24                           command=self.quit)
25
26        self.slider.pack(side=LEFT)
27        self.reset.pack(side=LEFT)
28        self.QUIT.pack(side=LEFT, fill=BOTH)
29
30    def __init__(self, master=None):
31        Frame.__init__(self, master)
32        Pack.config(self)
33        self.createWidgets()
34
35test = Test()
36test.mainloop()
37