Python Forum
[Tkinter] Grid Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Grid Problem
#1
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()
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grid data entry problem kenwatts275 3 2,300 Mar-22-2020, 03:13 PM
Last Post: kenwatts275

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020