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
|
from tkinter import ttk
from tkinter import *
fenetre=Tk()
fenetre.title("ESSAIS")
fenetre.geometry("1250x700+10+10")
#fenetre.update_idletask()
width = fenetre.winfo_width()
height = fenetre.winfo_height()
width = 1250
height = 700
x = (fenetre.winfo_screenwidth()//2)-(width//2)
y = (fenetre.winfo_screenheight()//2)-(height//2)
fenetre.geometry('{}x{}+{}+{}'.format(width,height,x,y))
class Saisie :
def __init__(self):
"""Constructeur de la fenêtre principale"""
#####################
# LISBOX
self.Frame1= Frame(fenetre,height=370,width=300,bg='red')
self.Frame1.grid(row=0, column=0,padx=10,pady=10 )
#####################
# LABEL SELECTION BENEFICIAIRE
self.Frame2= Frame(fenetre,padx =0, pady =5)
self.Frame2.grid(row=1, column=0,padx=10,pady=10 )
#####################
# LABEL ENTRY SOMME
self.Frame3= Frame(fenetre,padx =0, pady =5)
self.Frame3.grid(row=1, column=1 ,padx=10,pady=10 )
#####################
################# lISTBOX ##########################
self.barre = Scrollbar(self.Frame1, orient=VERTICAL)
self.lisbox = Listbox(self.Frame1,bg='bisque',height=18,width=20,
font=("arial",12,"bold italic"))
self.barre.config(command = self.lisbox.yview)
self.lisbox.config(yscrollcommand = self.barre.set, )
self.lisbox.grid(column=0, row=0)
self.barre.grid(column=1, row=0, sticky=S+N)
self.lisbox.bind("<<ListboxSelect>>", self.clic)
################### Selection Bénéficiaire #######################
self.label_selection = Label(self.Frame2,text= 'SELECTION',
font=("arial",12,"bold italic"),
width =15,fg='red',bg='yellow')
self.label_selection .grid( row=0,column=0,padx=0,pady=0)
# Initialise la variable
self.var_selection_Nouveau=StringVar()
self.entry_selection = Entry(self.Frame2,
textvariable = self.var_selection_Nouveau,width =20,bg='yellow',
font=("arial",12,"bold italic"),
disabledbackground ="yellow",disabledforeground ="black")
self.entry_selection.grid( row=1,column=0,padx=0,pady=5)
self.entry_selection.config(state=DISABLED)
########################## Somme ###############################
self.label_somme = Label(self.Frame3,text= 'SOMME',width =15,fg='red',
font=("arial",12,"bold italic"), bg='yellow')
self.label_somme .grid( row=0,column=0,padx=0,pady=0)
# Initialise la variable
self.var_somme_Nouveau=StringVar()
self.entry_somme = Entry(self.Frame3,
textvariable = self.var_somme_Nouveau,
font=("arial",12,"bold italic"),width =15,bg='yellow')
self.entry_somme .grid( row=1,column=0,padx=0,pady=5)
self.liste_beneficiaire=[5,10,15,20,50]
for x in self.liste_beneficiaire:
self.lisbox.insert('end',x)#rempli la liste
def clic(self,evt):# choix de la listbox BENEFICIAIRE
self.entry_selection.config(state=NORMAL)
self.entry_selection.delete(0,END)#vide entry BENEFICIARE
#récupere le nom du choix
self.recup_choix_liste = self.lisbox.get(self.lisbox.curselection())
# rempli entry type dépense
self.entry_selection.insert(0,self.recup_choix_liste)
self.entry_selection.config(state=DISABLED)
cl=Saisie() |
Partager