1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| from tkinter import *
import tkinter.ttk as ttk
# -*- coding:Utf8 -*-
def foncBoutProf():
lstCode = ["aa", "aa2"]
objListDeroul.configure(values=lstCode)
# en attente de codage
def foncBoutNewValid():
# Récupération des données
varLog = ObjNewNom.get()
varCode = ObjNewCode.get()
varRensei = objNewRenseig.get()
varTruq = 0
if varTr.get()==0:
varTruq=0
else:
varTruc=1
# Création de l'objet de classe Codes
Code01=Codes(varLog, varCode, varRensei, 0)
objLabelNew2.configure(text=varTruq)
def foncBoutNew():
# *********************************
# CREATION DES ELEMENTS FENETRE NEW
# *********************************
# Création de la fenêtre nouveau code
fenNew = Tk()
fenNew.title("Nouveau code")
fenNew.configure(bg="Royal Blue")
# Déclaration en global des variables de saisie
global ObjNewNom
global ObjNewCode
global objNewRenseig
global varTr
# Création de la frame
objFrameNew = LabelFrame(fenNew, text="Nouveau code", padx=5, pady=10, bg="Royal Blue")
objFrameNew.pack(fill="both", expand="yes", padx=5, pady=10)
# Créa objet nom
objLabelNew1 = Label(objFrameNew, height=1, width=20, text="Nom :", bg="Royal Blue")
objLabelNew1.grid(column=0, row=0, padx=10)
ObjNewNom = Entry(objFrameNew, width=24, bg="Cornflower Blue")
ObjNewNom.grid(column=0, row=1, padx=10, pady=(0,20))
# Créa objet Code
global objLabelNew2
objLabelNew2 = Label(objFrameNew, height=1, width=20, text="Code :", bg="Royal Blue")
objLabelNew2.grid(column=2, row=0, padx=5)
ObjNewCode = Entry(objFrameNew, width=24, bg="Cornflower Blue")
ObjNewCode.grid(column=2, row=1, padx=10, pady=(0,20))
# Créa objet bouton truquée
#varTruqueeNew_O_N = 10 # initialisation de la variable cochée ou pas
varBoutonNew1 = Checkbutton(objFrameNew, variable=varTr, bg="Royal Blue",text="Truquée ?", activebackground="Royal Blue") # varTruqueeNew_O_N : 0= décochée, 1=cochée
varBoutonNew1.grid(column=3, row=1, padx=(0, 5), pady=(0, 20))
# Créa objet renseignements
objLabelNew3 = Label(objFrameNew, height=1, width=40, text="Renseignements", bg="Royal Blue")
objLabelNew3.grid(column=0, row=3, columnspan=3)
objNewRenseig = Entry(objFrameNew, width=52, bg="Cornflower Blue")
objNewRenseig.grid(column=0, row=4, columnspan=3, padx=10, pady=(0,20))
# Créa bouton Validation
bouValidNew = Button(fenNew, text="Validation", activebackground="Slate Blue", command=foncBoutNewValid)
bouValidNew.pack(side=LEFT)
# Créa bouton Annuler
bouQuitNew = Button(fenNew, text="Annuler", command=fenNew.destroy, activebackground="Slate Blue")
bouQuitNew.pack(side=RIGHT)
# **********************************
# Réception d'événements pour fenNew
# **********************************
fenNew.mainloop()
class Codes:
def __init__(self, log, code, truquee, renseignement):
self.log=log
self.code = code
self.truquee=truquee
self.renseignement=renseignement
# ***************************************
# Créations des objets FENETRE PRINCIPALE
# ***************************************
# Créa fenêtre
fen1=Tk()
fen1.title("Codes")
fen1.configure(bg = "Sea Green")
# Créa frames
objFrame1 = LabelFrame(fen1, text="Résultat", padx=20, pady=5, bg="Sea Green")
objFrame1.pack(fill="both", expand="yes", padx=5, pady=5) # fill both : extension a yes donc both sinon que sur x ou y
objFrame2 = LabelFrame(fen1, text="Recherche et création", padx=20, pady=5, bg="Sea Green")
objFrame2.pack(fill="both", expand="yes", padx=5, pady=5)
# Créa frames dans frame objFrame2
objFrame3 = LabelFrame(objFrame2, text="Recherche", padx=20, pady=5, bg="Sea Green")
objFrame3.pack(fill="both", expand="yes")
# *******************************************
# Création des objets dans la frame objFrame1
# *******************************************
# Créa objet logging
objLabel1 = Label(objFrame1,height=1,width=20, text="logging", bg="Sea Green")
objLabel1.grid(row=0, sticky=W, padx=5, pady=(5,0))
objLogging = Label(objFrame1,height=1,width=20, bg="Medium Sea Green", relief=SUNKEN)
objLogging.grid(row=1, sticky=W, padx=5, pady=(0,5))
# Créa objet code
objLabel2 = Label(objFrame1,height=1,width=20, text="Code", bg="Sea Green")
objLabel2.grid(row=0,column=1, padx=(40,5), pady=(5,0))
objCode = Label(objFrame1,height=1,width=20, bg="Medium Sea Green", relief=SUNKEN)
objCode.grid(row=1,column=1, padx=(40,5), pady=(0,5))
# Créa objet bouton truquée
varTruqueeO_N=0 # initialisation de la variable cochée ou pas
varBouton1 = Checkbutton(objFrame1, variable=varTruqueeO_N, bg="Sea Green", text="Truquée ?", activebackground="Sea Green") #varTruqueeO_N : 0= décochée, 1=cochée
varBouton1.grid(row=1,column=2, padx=(0,5), pady=(0,5))
# Créa objet renseignements
objLabel4 = Label(objFrame1,height=1,width=47, text="Renseignements", bg="Sea Green")
objLabel4.grid(row=2,column=0, padx=5, columnspan=2, sticky=W, pady=(15,0))
objRenseig = Label(objFrame1,height=5,width=47, bg="Medium Sea Green", relief=SUNKEN)
objRenseig.grid(row=3,column=0, padx=5, columnspan=2, sticky=W, pady=(0,5))
# *******************************************
# Création des objets dans la frame objFrame3
# *******************************************
# Création des boutons poussoir
varChoixList = StringVar()
boutJMA = Radiobutton(objFrame3, text="JMA", variable=varChoixList, value=1, bg="Sea Green", command=foncBoutProf, activebackground="Sea Green")
boutJMA.grid(row=0,column=0, sticky=W)
boutProf = Radiobutton(objFrame3, text="Professionnel", variable=varChoixList, value=2, bg="Sea Green", activebackground="Sea Green")
boutProf.grid(row=0,column=1, sticky=W)
boutLiens = Radiobutton(objFrame3, text="Liens internet", variable=varChoixList, value=3, bg="Sea Green", activebackground="Sea Green")
boutLiens.grid(row=0,column=2, sticky=W)
boutFamily = Radiobutton(objFrame3, text="Famille", variable=varChoixList, value=4, bg="Sea Green", activebackground="Sea Green")
boutFamily.grid(row=1,column=0, sticky=W)
boutAmis = Radiobutton(objFrame3, text="Amis", variable=varChoixList, value=5, bg="Sea Green", activebackground="Sea Green")
boutAmis.grid(row=1,column=1, sticky=W)
boutAmis.select() # Bouton qui doit être coché de base
# Créa objet liste déroulante
# Création liste pour la liste déroulante
lstCode=[]
# Création dictionnaire pour affichage selon choix de la liste
DictCodes={}
# liste déroulante
objListDeroul = ttk.Combobox(objFrame3, values=lstCode, width=16)
objListDeroul.grid(row=0,column=3, sticky=E, padx=(30,0))
# Création des objets hors frame
# Créa bouton New
bouNew=Button(fen1, text="New",activebackground="Dark Olive Green", command=foncBoutNew)
bouNew.pack(side=LEFT)
# Créa bouton Modif
bouNew=Button(fen1, text="Modif",activebackground="Dark Olive Green", state="disabled") #disabled, "active" = pointeur sur bouton, "normal" = ben normal
bouNew.pack(side=LEFT)
# Créa bouton Sup
bouNew=Button(fen1, text="Sup",activebackground="Dark Olive Green", state="disabled")
bouNew.pack(side=LEFT)
# Créa bouton Quitter
bouQuit=Button(fen1, text="Quitter", command=fen1.destroy,activebackground="Dark Olive Green")
bouQuit.pack(side=RIGHT)
# **********************
# Réception d'événements
# **********************
fen1.mainloop() |
Partager