Scale Demo: get scale value and open different dialogs : Scale « GUI Tk « Python

Python
1. 2D
2. Application
3. Buildin Function
4. Class
5. Data Structure
6. Data Type
7. Development
8. Dictionary
9. Event
10. Exception
11. File
12. Function
13. GUI Pmw
14. GUI Tk
15. Language Basics
16. List
17. Math
18. Network
19. String
20. System
21. Thread
22. Tuple
23. Utility
24. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Python » GUI Tk » ScaleScreenshots 
Scale Demo: get scale value and open different dialogs
Scale Demo: get scale value and open different dialogs


from Tkinter import *


from tkFileDialog   import askopenfilename        
from tkColorChooser import askcolor               
from tkMessageBox   import askquestion, showerror
from tkSimpleDialog import askfloat

from tkMessageBox import askokcancel           

class Quitter(Frame):                          
    def __init__(self, parent=None):           
        Frame.__init__(self, parent)
        self.pack()
        widget = Button(self, text='Quit', command=self.quit)
        widget.pack(expand=YES, fill=BOTH, side=LEFT)
    def quit(self):
        ans = askokcancel('Verify exit', "Really quit?")
        if ans: Frame.quit(self)



demos = {
    'Open':  askopenfilename, 
    'Color': askcolor,
    'Query': lambda: askquestion('Warning', 'query'),
    'Error': lambda: showerror('Error!', "Error"),
    'Input': lambda: askfloat('Entry', 'Input')
}

class Demo(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        self.pack()
        Label(self, text="Scale demos").pack()
        self.var = IntVar()
        Scale(self, label='Pick demo number',
                    command=self.onMove,     
                    variable=self.var,       
                    from_=0, to=len(demos)-1).pack()
        Scale(self, label='Pick demo number',
                    command=self.onMove,     
                    variable=self.var,       
                    from_=0, to=len(demos)-1,
                    length=200, tickinterval=1,
                    showvalue=YES, orient='horizontal').pack()
        Quitter(self).pack(side=RIGHT)
        Button(self, text="Run demo", command=self.onRun).pack(side=LEFT)
        Button(self, text="State",    command=self.report).pack(side=RIGHT)
    def onMove(self, value):
        print 'in onMove', value
    def onRun(self):
        pos = self.var.get()
        print 'You picked', pos
        pick = demos.keys()[pos]    
        print demos[pick]()
    def report(self):
        print self.var.get()

if __name__ == '__main__': 
    print demos.keys()
    Demo().mainloop()

           
       
Related examples in the same category
1. Scale Demo: random choiceScale Demo: random choice
2. Use Scale
3. Bound Scale action with a canvasBound Scale action with a canvas
4. Scale widgetScale widget
5. Scale: get Scale valueScale: get Scale value
6. Scale used to control the size of a circleScale used to control the size of a circle
7. Canvas paint: controlled by ScaleCanvas paint: controlled by Scale
w__w___w__._ja_v__a2s___.c___o___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.