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
| from tkinter import Entry, Label, Tk, Scale, HORIZONTAL, Frame, Toplevel
from tkinter import Canvas, PhotoImage, Button, StringVar, IntVar
fen1 = Tk()
fen1.title("Retouche photo")
fen1.configure(bg = "ghost white")
fen1.geometry("400x100")
COLORS = ['snow', 'ghost white']
MAX_ROWS = 1 # Changé la valeur car COLORS = (0,1)
FONT_SIZE = 8 #...
def code_rgb(couleur):
return fen1.winfo_rgb(couleur)
def nom_cellule(nom):
global canaux
result = nom.cget("text")
# print(result,code_rgb(result)[0]/255,code_rgb(result)[1]/255,code_rgb(result)[2]/255)
canaux = ("%.2f,%.2f,%.2f" %(code_rgb(result)[0]/255,code_rgb(result)[1]/255,code_rgb(result)[2]/255))
txt1 = Label(fen1, text =canaux)
txt1.grid(row=4, column=7, sticky ='NESW')
print('nom_cellule',canaux)
return(canaux)
def coul():
fen2 = Toplevel()
r = 0
c = 0
for color in COLORS:
couleur = Button(fen2, text=color, width = 13, height = 2, bg=color,\
font=("Times", FONT_SIZE, "bold"))
couleur.config(command=lambda nom=couleur: nom_cellule(nom))
couleur.grid(row=r, column=c, padx=2, pady=2, sticky="NESW")
r += 1
if r > MAX_ROWS:
r = 0
c += 1
print('coul',color)
Button(fen1,text='Couleurs',command=coul).grid(row=5, column=6, sticky='NESW')
def bordure(canaux):
canaux_bis = canaux*10
print('canaux_bis',canaux_bis)
Bord=Label(fen1, text=" Bordure ")
Bord.grid(row=4, column=1, sticky='NESW')
val_bord = IntVar()
val_bord.set(0)
echelle_8 = Scale(fen1,length=200, orient=HORIZONTAL, troughcolor ='LightYellow2', \
sliderlength =20, showvalue =0,from_=0,to=50, resolution=5, tickinterval=5, \
command=lambda canaux=(0,0,0): bordure(canaux)) # width=10
echelle_8.set(0)
echelle_8.grid(row=4, column=3, columnspan=4, sticky='NESW')
Button(fen1,text='Quitter',command=fen1.destroy).grid(row=5, column=4,columnspan=2, sticky='NESW')
fen1.mainloop() |
Partager