0

I am trying to create an app that generates images with some arguments. I have compiled some information and created the code, but the image generator doesn't work when I use show(event). It shows up as a blank rectangle. However, it works without using show(event).

Here is the code I have written:

#libraries
from tkinter import *
from PIL import Image, ImageTk, ImageFont, ImageDraw

win=Tk()
win.geometry("700x550")

#files
thusday=Image.open("E:\спм суд\ЧТ.png")
olus=Image.open('E:\спм суд\ОЛУС.png')

#command
def show(event):
    if clicked.get()=='ОЛУС':
        Label(win, text='ОЛУСС').pack()
        img=Image.alpha_composite(olus, thusday)
        new_width  = int(500)
        new_height = int(new_width * 1080 / 1920) 

        resized_image=img.resize((new_width,new_height), Image.LANCZOS)
        img = ImageTk.PhotoImage(resized_image)
        Label(win,image=img).pack(pady=20)
    Label(win, text=clicked.get()).pack()

#info
cities=[
    'ОЛУС', 
    'БАРСЕЛОНА', 
    'СПАВН', 
    'НЕГОРОД КВАТОСА'
]      

day=[
    'Четверг', 
    'Воскресенье'
]
    
#dropmenu
clicked=StringVar()
clicked.set('город проведения')
drop=OptionMenu(win, clicked, *cities, command=show)
drop.pack()

click=StringVar()
click.set('день недели')
drop=OptionMenu(win, click, *day)
drop.pack()

#buttons
##Boobs=Button(win, text="GENERATE", command=show).pack()

Here is a screenshot of the app with the show(event) function:

Here is the working code:

thusday=Image.open("E:\спм суд\ЧТ.png")
olus=Image.open('E:\спм суд\ОЛУС.png')

img=Image.alpha_composite(olus, thusday)
new_width  = int(500)
new_height = int(new_width * 1080 / 1920) 
resized_image=img.resize((new_width,new_height), Image.LANCZOS)
img = ImageTk.PhotoImage(resized_image)
Label(win,image=img).pack(pady=20)
  • quick comment to avoid wildcard imports: https://stackoverflow.com/questions/73698351/is-anyone-know-how-to-connect-tkinter-webcam-to-yolov5/73712541#73712541 – D.L Jun 17 '23 at 09:07
  • @D.L i try do this, but my problem don't resolve, thx for answer – kakashechka Jun 17 '23 at 11:21

0 Answers0