Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # test1.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()
- def vp_start_gui():
- '''Starting point when module is the main routine.'''
- global val, w, root
- root = Tk()
- root.title('Test_Form')
- root.geometry('280x186+474+263')
- w = Test_Form (root)
- init()
- root.mainloop()
- w = None
- def create_Test_Form (root):
- '''Starting point when module is imported by another program.'''
- global w, w_win
- if w: # So we have only one instance of window.
- return
- w = Toplevel (root)
- w.title('Test_Form')
- w.geometry('280x186+474+263')
- w_win = Test_Form (w)
- init()
- return w_win
- def destroy_Test_Form ():
- global w
- w.destroy()
- w = None
- def Button1Click(p1) :
- sys.exit()
- def init():
- pass
- class Test_Form:
- 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.Button1 = Button (master)
- self.Button1.place(relx=0.43,rely=0.38,height=27,width=49)
- self.Button1.configure(activebackground="#f9f9f9")
- self.Button1.configure(text='''Exit''')
- self.Button1.bind('<Button-1>',Button1Click)
- if __name__ == '__main__':
- vp_start_gui()
- #############################################
- # demos.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()
- def vp_start_gui():
- '''Starting point when module is the main routine.'''
- global val, w, root
- root = Tk()
- root.title('Demos')
- root.geometry('510x230+283+147')
- set_Tk_var()
- w = Demos (root)
- init()
- root.mainloop()
- w = None
- def create_Demos (root):
- '''Starting point when module is imported by another program.'''
- global w, w_win
- if w: # So we have only one instance of window.
- return
- w = Toplevel (root)
- w.title('Demos')
- w.geometry('510x230+283+147')
- set_Tk_var()
- w_win = Demos (w)
- init()
- return w_win
- def destroy_Demos ():
- global w
- w.destroy()
- w = None
- def set_Tk_var():
- # These are Tk variables used passed to Tkinter and must be
- # defined before the widgets using them are created.
- global rbc1
- rbc1 = StringVar()
- global rbc2
- rbc2 = StringVar()
- def btnExitClicked(p1) :
- sys.exit()
- def btnNormalClicked(p1) :
- print "Normal Button Clicked"
- def btnSunkenClicked(p1) :
- print "Sunken Button Clicked"
- def init():
- pass
- class Demos:
- 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.Frame1 = Frame (master)
- self.Frame1.place(relx=0.02,rely=0.04,relheight=0.33,relwidth=0.97)
- self.Frame1.configure(relief=GROOVE)
- self.Frame1.configure(borderwidth="2")
- self.Frame1.configure(relief="groove")
- self.Label1 = Label (self.Frame1)
- self.Label1.place(relx=0.02,rely=0.13,height=19,width=51)
- self.Label1.configure(activebackground="#f9f9f9")
- self.Label1.configure(text='''Buttons''')
- self.Button1 = Button (self.Frame1)
- self.Button1.place(relx=0.34,rely=0.4,height=27,width=69)
- self.Button1.configure(activebackground="#f9f9f9")
- self.Button1.configure(text='''Normal''')
- self.Button1.bind('<Button-1>',btnNormalClicked)
- self.Button2 = Button (self.Frame1)
- self.Button2.place(relx=0.61,rely=0.4,height=27,width=72)
- self.Button2.configure(activebackground="#f9f9f9")
- self.Button2.configure(text='''Sunken''')
- self.Button2.bind('<Button-1>',btnSunkenClicked)
- self.Frame2 = Frame (master)
- self.Frame2.place(relx=0.02,rely=0.39,relheight=0.33,relwidth=0.97)
- self.Frame2.configure(relief=GROOVE)
- self.Frame2.configure(borderwidth="2")
- self.Frame2.configure(relief="groove")
- self.Radiobutton1 = Radiobutton (self.Frame2)
- self.Radiobutton1.place(relx=0.32,rely=0.13,relheight=0.28
- ,relwidth=0.14)
- self.Radiobutton1.configure(activebackground="#f9f9f9")
- self.Radiobutton1.configure(text='''radio 1''')
- self.Radiobutton1.configure(value="0")
- self.Radiobutton1.configure(variable=rbc1)
- self.Radiobutton2 = Radiobutton (self.Frame2)
- self.Radiobutton2.place(relx=0.32,rely=0.4,relheight=0.28,relwidth=0.14)
- self.Radiobutton2.configure(activebackground="#f9f9f9")
- self.Radiobutton2.configure(text='''radio 2''')
- self.Radiobutton2.configure(value="1")
- self.Radiobutton2.configure(variable=rbc1)
- self.Radiobutton3 = Radiobutton (self.Frame2)
- self.Radiobutton3.place(relx=0.61,rely=0.13,relheight=0.28
- ,relwidth=0.14)
- self.Radiobutton3.configure(activebackground="#f9f9f9")
- self.Radiobutton3.configure(text='''radio 3''')
- self.Radiobutton3.configure(value="0")
- self.Radiobutton3.configure(variable=rbc2)
- self.Radiobutton4 = Radiobutton (self.Frame2)
- self.Radiobutton4.place(relx=0.61,rely=0.4,relheight=0.28,relwidth=0.14)
- self.Radiobutton4.configure(activebackground="#f9f9f9")
- self.Radiobutton4.configure(text='''radio 4''')
- self.Radiobutton4.configure(value="1")
- self.Radiobutton4.configure(variable=rbc2)
- self.Label2 = Label (self.Frame2)
- self.Label2.place(relx=0.02,rely=0.13,height=19,width=88)
- self.Label2.configure(activebackground="#f9f9f9")
- self.Label2.configure(text='''Radio Buttons''')
- self.Button3 = Button (master)
- self.Button3.place(relx=0.45,rely=0.83,height=27,width=49)
- self.Button3.configure(activebackground="#f9f9f9")
- self.Button3.configure(text='''Exit''')
- self.Button3.bind('<Button-1>',btnExitClicked)
- if __name__ == '__main__':
- vp_start_gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement