Ответ:
from tkinter import *
root = Tk()
l1 = Label(text='')
l1.pack()
e1 = Entry(width=19,justify=CENTER)
e1.pack()
k=['','#ff0000','#ff7d00','#ffff00','#00ff00','#007dff','#0000ff','#7d00ff']
a=['','красный', 'оранжевый', 'желтый', 'зеленый', 'голубой', 'синий', 'фиолетовый']
def i1():
e1.delete(0,END)
e1.insert(0, k[1])
l1.config(text=a[1])
b1 = Button(bg='#ff0000', width=15, command=i1)
b1.pack()
def i2():
e1.insert(0, k[2])
l1.config(text=a[2])
b2 = Button(bg='#ff7d00', width=15, command=i2)
b2.pack()
def i3():
e1.insert(0, k[3])
l1.config(text=a[3])
b3 = Button(bg='#ffff00', width=15, command=i3)
b3.pack()
def i4():
e1.insert(0, k[4])
l1.config(text=a[4])
b4 = Button(bg='#00ff00', width=15, command=i4)
b4.pack()
def i5():
e1.insert(0, k[5])
l1.config(text=a[5])
b5 = Button(bg='#007dff', width=15, command=i5)
b5.pack()
def i6():
e1.insert(0, k[6])
l1.config(text=a[6])
b6 = Button(bg='#0000ff', width=15, command=i6)
b6.pack()
def i7():
e1.insert(0, k[7])
l1.config(text=a[7])
b7 = Button(bg='#7d00ff', width=15, command=i7)
b7.pack()
root.mainloop()
Объяснение:
фото
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
from tkinter import *
root = Tk()
l1 = Label(text='')
l1.pack()
e1 = Entry(width=19,justify=CENTER)
e1.pack()
k=['','#ff0000','#ff7d00','#ffff00','#00ff00','#007dff','#0000ff','#7d00ff']
a=['','красный', 'оранжевый', 'желтый', 'зеленый', 'голубой', 'синий', 'фиолетовый']
def i1():
e1.delete(0,END)
e1.insert(0, k[1])
l1.config(text=a[1])
b1 = Button(bg='#ff0000', width=15, command=i1)
b1.pack()
def i2():
e1.delete(0,END)
e1.insert(0, k[2])
l1.config(text=a[2])
b2 = Button(bg='#ff7d00', width=15, command=i2)
b2.pack()
def i3():
e1.delete(0,END)
e1.insert(0, k[3])
l1.config(text=a[3])
b3 = Button(bg='#ffff00', width=15, command=i3)
b3.pack()
def i4():
e1.delete(0,END)
e1.insert(0, k[4])
l1.config(text=a[4])
b4 = Button(bg='#00ff00', width=15, command=i4)
b4.pack()
def i5():
e1.delete(0,END)
e1.insert(0, k[5])
l1.config(text=a[5])
b5 = Button(bg='#007dff', width=15, command=i5)
b5.pack()
def i6():
e1.delete(0,END)
e1.insert(0, k[6])
l1.config(text=a[6])
b6 = Button(bg='#0000ff', width=15, command=i6)
b6.pack()
def i7():
e1.delete(0,END)
e1.insert(0, k[7])
l1.config(text=a[7])
b7 = Button(bg='#7d00ff', width=15, command=i7)
b7.pack()
root.mainloop()
Объяснение:
фото