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 ou 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 ("""
- Votre version de Python ne supporte pas les widgets ttk...
- Il faut une version >= 2.6 pour executer les modules PAGE.
- """)
- sys.exit()
- def point_depart_graphique():
- '''Point de depart lorsque le module est la routine principale.'''
- global val, w, root
- root = Tk()
- root.title('Form_Test')
- root.geometry('280x186+474+263')
- w = Form_Test (root)
- init()
- root.mainloop()
- w = None
- def create_Form_Test (root):
- '''Point de depart lorsque le module est importe par un autre programme.'''
- global w, w_win
- if w: # on a une seule instance de fenetre
- return
- w = Toplevel (root)
- w.title('Form_Test')
- w.geometry('280x186+474+263')
- w_win = Form_Test (w)
- init()
- return w_win
- def destroy_Form_Test ():
- global w
- w.destroy()
- w = None
- def ClicBouton1(p1) :
- sys.exit()
- def init():
- pass
- class Form_Test:
- def __init__(self, principale=None):
- # regle le fond de fenetre pour correspondre au style actuel
- style = ttk.Style()
- theme = style.theme_use()
- default = style.lookup(theme, 'background')
- principale.configure(background=default)
- self.Bouton1 = Button (principale)
- self.Bouton1.place(relx=0.43,rely=0.38,height=27,width=49)
- self.Bouton1.configure(activebackground="#f9f9f9")
- self.Bouton1.configure(text='''Quitter''')
- self.Bouton1.bind('<Button-1>',ClicBouton1)
- if __name__ == '__main__':
- point_depart_graphique()
- #############################################
- # 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 point_depart_graphique():
- '''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__':
- point_depart_graphique()
- #############################################
- # 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 ou 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 ("""
- Votre version de Python ne supporte pas les widgets ttk...
- Il faut une version >= 2.6 pour executer les modules PAGE.
- """)
- sys.exit()
- def point_depart_graphique():
- '''Point de depart lorsque le module est la routine principale.'''
- global val, w, root
- root = Tk()
- root.title('Demos')
- root.geometry('510x230+283+147')
- regle_variables_Tk()
- w = Demos (root)
- init()
- root.mainloop()
- w = None
- def create_Demos (root):
- '''Point de depart lorsque le module est importe par un autre programme.'''
- global w, w_win
- if w: # on a une seule instance de fenetre
- return
- w = Toplevel (root)
- w.title('Demos')
- w.geometry('510x230+283+147')
- regle_variables_Tk()
- w_win = Demos (w)
- init()
- return w_win
- def destroy_Demos ():
- global w
- w.destroy()
- w = None
- def regle_variables_Tk():
- # Ce sont les variables Tk utilisees et passees a Tkinter
- # Elles doivent etre definies avant de creer les widgets qui les utilisent
- global rbc1
- rbc1 = StringVar()
- global rbc2
- rbc2 = StringVar()
- def ClicBtnQuitter(p1) :
- sys.exit()
- def clicBtnNormal(p1) :
- print "Clic bouton Normal"
- def clicBtnCreux(p1) :
- print "Clic bouton Creux"
- def init():
- pass
- class Demos:
- def __init__(self, principale=None):
- # regle le fond de fenetre pour correspondre au style actuel
- style = ttk.Style()
- theme = style.theme_use()
- default = style.lookup(theme, 'background')
- principale.configure(background=default)
- self.Fenetre1 = Frame (principale)
- self.Fenetre1.place(relx=0.02,rely=0.04,relheight=0.33,relwidth=0.97)
- self.Fenetre1.configure(relief=GROOVE)
- self.Fenetre1.configure(borderwidth="2")
- self.Fenetre1.configure(relief="groove")
- self.Label1 = Label (self.Fenetre1)
- self.Label1.place(relx=0.02,rely=0.13,height=19,width=51)
- self.Label1.configure(activebackground="#f9f9f9")
- self.Label1.configure(text='''Boutons''')
- self.Bouton1 = Button (self.Fenetre1)
- self.Bouton1.place(relx=0.34,rely=0.4,height=27,width=69)
- self.Bouton1.configure(activebackground="#f9f9f9")
- self.Bouton1.configure(text='''Normal''')
- self.Bouton1.bind('<Button-1>',clicBtnNormal)
- self.Bouton2 = Button (self.Fenetre1)
- self.Bouton2.place(relx=0.61,rely=0.4,height=27,width=72)
- self.Bouton2.configure(activebackground="#f9f9f9")
- self.Bouton2.configure(text='''Creux''')
- self.Bouton2.bind('<Button-1>',clicBtnCreux)
- self.Frame2 = Frame (principale)
- 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.BoutonRadio1 = Radiobutton (self.Frame2)
- self.BoutonRadio1.place(relx=0.32,rely=0.13,relheight=0.28
- ,relwidth=0.14)
- self.BoutonRadio1.configure(activebackground="#f9f9f9")
- self.BoutonRadio1.configure(text='''radio 1''')
- self.BoutonRadio1.configure(value="0")
- self.BoutonRadio1.configure(variable=rbc1)
- self.BoutonRadio2 = Radiobutton (self.Frame2)
- self.BoutonRadio2.place(relx=0.32,rely=0.4,relheight=0.28,relwidth=0.14)
- self.BoutonRadio2.configure(activebackground="#f9f9f9")
- self.BoutonRadio2.configure(text='''radio 2''')
- self.BoutonRadio2.configure(value="1")
- self.BoutonRadio2.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='''Boutons Radio''')
- self.Button3 = Button (principale)
- 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>',ClicBtnQuitter)
- if __name__ == '__main__':
- point_depart_graphique()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement