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
|
import tkinter as tk
from tkinter import *
master = tk.Tk()
master.geometry("800x600+165+0")
master.config(bg = "#B0C4DE")
def enter_widget(event):
event.widget["bg"] = "yellow"
def leave_widget(event):
event.widget["bg"] = "gainsboro"
def affich(a,b,c):
t2['text']=a['text']
t3['text']=b['text']
t1['text']=c['text']
liste = [['1','BAUDELAIRE', 'Charles'],
['2','HUGO', 'Victor'],
['3','RIMBAUD', 'Arthur'],
['4','VILLON','François']]
j=0
while j<4:
lb2=tk.Label(master, text=liste[j][1],font=('Tahoma', 9), width="12", bg='white', height="1", bd=2, relief=('ridge'),anchor=CENTER)
lb2.grid(row=j+1, column=1, padx=1, pady=1)
lb3=tk.Label(master, text=liste[j][2],font=('Tahoma', 9), width="12", bg='white', height="1", bd=2, relief=('ridge'),anchor=CENTER)
lb3.grid(row=j+1, column=2, padx=1, pady=1)
lb1=tk.Button(master, text=liste[j][0],font=('Tahoma', 9), width="4", bg='gainsboro', height="1", bd=2, relief=('raised'),anchor=CENTER,\
command=lambda:affich(lb2,lb3,lb1))
lb1.grid(row=j+1, column=0, padx=1, pady=1)
lb1.bind("<Enter>", enter_widget)
lb1.bind("<Leave>", leave_widget)
j=j+1
b1=tk.Label(master, text='Rang',font=('Tahoma', 9),bg='gainsboro',bd=2, relief=('ridge'),anchor=CENTER)
b1.place (x=355, y= 5, width=40, height=20)
t1=tk.Label(master, text='',font=('Tahoma', 9),bg='white',bd=2, relief=('ridge'),anchor=CENTER)
t1.place (x=355, y= 30, width=40, height=20)
b2=tk.Label(master, text='NOM',font=('Tahoma', 9),bg='gainsboro',bd=2, relief=('ridge'),anchor=CENTER)
b2.place (x=400, y= 5, width=100, height=20)
t2=tk.Label(master, text='',font=('Tahoma', 9),bg='white',bd=2, relief=('ridge'),anchor=CENTER)
t2.place (x=400, y= 30, width=100, height=20)
b3=tk.Label(master, text='PRENOM',font=('Tahoma', 9),bg='gainsboro', bd=2, relief=('ridge'),anchor=CENTER)
b3.place (x=505, y= 5, width=100, height=20)
t3=tk.Label(master, text='',font=('Tahoma', 9),bg='white',bd=2, relief=('ridge'),anchor=CENTER)
t3.place (x=505, y= 30, width=100, height=20)
master.mainloop() |
Partager