button.py :  » GUI » PAGE » page » examples » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » PAGE 
PAGE » page » examples » button.py
#! /usr/bin/env python
# -*- python -*-

import sys

py2 = py30 = py31 = False
version = sys.hexversion
if version >= 0x020600F0 and version < 0x03000000 :
    py2 = True    # Python 2.6 or 2.7
    from Tkinter import *
    import ttk
elif version >= 0x03000000 and version < 0x03010000 :
    py30 = True
    from tkinter import *
    import ttk
elif version >= 0x03010000:
    py31 = True
    from tkinter import *
    import tkinter.ttk as ttk
else:
    print ("""
    You do not have a version of python supporting ttk widgets..
    You need a version >= 2.6 to execute PAGE modules.
    """)
    sys.exit()



'''

    If you use the following functions, change the names 'w' and
    'w_win'.  Use as a template for creating a new Top-level window.

w = None
def create_Button_Example ()
    global w
    global w_win
    if w: # So we have only one instance of window.
        return
    w = Toplevel (root)
    w.title('Button Example')
    w.geometry('600x450+650+150')
    w_win = Button_Example (w)

   Template for routine to destroy a top level window.

def destroy():
    global w
    w.destroy()
    w = None
'''

def vp_start_gui():
    global val, w, root
    root = Tk()
    root.title('Button_Example')
    root.geometry('600x450+650+150')
    w = Button_Example (root)
    init()
    root.mainloop()



def init():
    pass

def quit() :
    sys.exit()





class Button_Example:
    def __init__(self, master=None):
        # Set background of toplevel window to match
        # current style
        style = ttk.Style()
        theme = style.theme_use()
        default = style.lookup(theme, 'background')
        master.configure(background=default)

        self.but33 = Button (master)
        self.but33.place(relx=0.32,rely=0.29)
        self.but33.configure(activebackground="#009999")
        self.but33.configure(activeforeground="#ffffff")
        self.but33.configure(command=quit)
        self.but33.configure(compound="top")
        self._img1 = PhotoImage(file="stop.gif")
        self.but33.configure(image=self._img1)
        self.but33.configure(text="Push to Stop")







if __name__ == '__main__':
    vp_start_gui()




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.