Python Forum

Full Version: Grid Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a grid problem. I could not add the image named "emptycart.gif" under the "SHOPPING CART" label.


from tkinter import *

root = Tk()
root.geometry("1600x800+200+0")
root.title("PROJECT")

clicks1 = 0

my_cart = ["emptycart.gif"]

global x
x = 1

def new_winB(): # new window definition
    newwin = Toplevel(root)
    newwin.geometry("1600x800+200+0")
    newwin.title("Shopping Cart")
    newwin.rowconfigure((0, 12), weight=50)
    newwin.columnconfigure((0, 12), weight=50)
    label_3 = Label(newwin, text="SHOPPING CART",  bg="gray94", height=3, width=180)
    label_3.grid(row=3, columnspan=8)
    photo1 = PhotoImage(file=my_cart[0])
    lbl1 = Label(newwin, image=photo1)
    lbl1.grid(row=4, columnspan=6)
 
button1 =Button(root, text ="open new window", command =new_winB)
button1.pack()

root.mainloop()
We can't tell anything because you code is not indented properly.
Quote:I have a grid problem
What does this mean?
Quote:I could not add the image named "emptycart.gif" under the "SHOPPING CART" label
Why not?

Read the text with the green background on this page
http://effbot.org/tkinterbook/photoimage.htm