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
| from tkinter import *
import tkinter.ttk as ttk
# -*- coding:Utf8 -*-
def foncBoutProf():
lstCode = ["aa", "aa2"]
objListDeroul = ttk.Combobox(objFrame3, values=lstCode, width=16)
# Le problème est à la ligne ci-dessus : lstCode est bien changé mais la liste : objListDeroul ne change pas
# ********************
# Créations des objets
# ********************
# 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 renseignements
objLabel3 = Label(objFrame1,height=1,width=48, text="Renseignements", bg="Sea Green")
objLabel3.grid(row=2,column=0, padx=5, columnspan=2, sticky=W, pady=(15,0))
objRenseig = Label(objFrame1,height=5,width=48, 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()
boutProf = Radiobutton(objFrame3, text="Professionnel", variable=varChoixList, value=1, bg="Sea Green", command=foncBoutProf)
boutProf.grid(row=0,column=0, sticky=W)
boutJMA = Radiobutton(objFrame3, text="JMA", variable=varChoixList, value=2, bg="Sea Green")
boutJMA.grid(row=0,column=1, sticky=W)
boutFamily = Radiobutton(objFrame3, text="Famille", variable=varChoixList, value=3, bg="Sea Green")
boutFamily.grid(row=1,column=0, sticky=W)
boutAmis = Radiobutton(objFrame3, text="Amis", variable=varChoixList, value=4, bg="Sea Green")
boutAmis.grid(row=1,column=1, sticky=W)
boutProf.select() # Bouton qui doit être coché de base
# Créa objet liste déroulante
# Création liste pour la liste déroulante
lstCode=["a", "b", "c"]
# Création dictionnaire pour affichage selon choix de la liste
DictCodes={"chemise":3, "pantalon":6, "tee-shirt":7}
# liste déroulante
objListDeroul = ttk.Combobox(objFrame3, values=lstCode, width=16)
objListDeroul.grid(row=0,column=2, sticky=E, padx=(30,0))
# Création des objets hors frame
# Créa bouton New
bouNew=Button(fen1, text="New",activebackground="Dark Olive Green")
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)
# ****************************
# Choix de la liste déroulante
# ****************************
# **********************
# Réception d'événements
# **********************
fen1.mainloop() |
Partager