#! /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()
|