Нужно сделать программу как на картинке картинку цветочков можете брать любую другую рандомную
Ответы
Ответ:
from tkinter import *
def happy(name):
lb1['text'] = f'{name.get()}, с днём рождения!'
et_bg = Label(window, image = pi)
et_bg.place(relx=0.5, rely=0.78 ,height=210, width=210, anchor = 'c')
window = Tk()
window.title("С днём рождения!")
window.geometry('640x480')
lb = Label(window, justify = 'center', text = 'Ваше имя', font = 'Verdana 10')
lb.place(relx=0.3, rely=0.2 ,height=25, width=100, anchor = 'center')
et_string = StringVar()
et = Entry(window, justify = 'center', textvariable=et_string, font = 'Verdana 10')
et.place(relx=0.7, rely=0.2 ,height=25, width=100, anchor = 'c')
btn = Button(window, text = 'Привет', font = 'Verdana 10')
btn.place(relx=0.3, rely=0.4 ,height=60, width=100, anchor = 'c')
btn.config(command = lambda:(happy(et_string)))
btn1 = Button(window, text = 'Выход', font = 'Verdana 10')
btn1.place(relx=0.7, rely=0.4 ,height=60, width=100, anchor = 'c')
btn1.config(command = lambda:(window.destroy()))
lb1 = Label(window, justify = 'center', text = '', font = 'Verdana 10')
lb1.place(relx=0.375, rely=0.5 ,height=25, width=300, anchor = 'center')
pi = PhotoImage(file = './image.png')
window.mainloop()
Объяснение:
Размер изображения используйте 200 на 200 px. Либо сами поменяйте параметры. Имя изображения должно быть image.png, либо поменяйте на свое в это строке pi = PhotoImage(file = './image.png')