I have a simple GUI tryout where I want to display few images on my screen. I start with setting the window with gray squares allover it and resizing the desired image and now I want to put it on the frame:
img = [img_resize(yellow_square, img_size), "text"]
base_panel = Label(root, image = img[0])
base_txt = Label(root, text = img[1])
base_panel.grid(row = x, column = y)
base_txt.grid (row = x, column = y)
...
for im in ls:
panel = Label(root, image = im[0])
panel.grid(row = x+im[1][1], column = y+im[1][2])
txt = Label(root, text = im[2])
txt.grid(row = x+im[1][1], column = y+im[1][2], sticky = 'S')
ls
is a list [image (using Image.open(img)
), location offset, text]
When I copy these lines to my main script, it all goes well and I get the desired
but when trying to do so from a function, I only get the text part to work
I guess something is wrong with my image = ...
but I don't understand what, as I have the code working after I just copied these lines to main. The main has another image, so maybe this is affecting somehow?
This is the code from main:
for im in background: # background is a list of gray squares
# some manipulation an a,b
panel = Label(root, image = im)
panel.grid(row = a, column = b)
Here should come the function call or the lines themselves