0

Im trying to use Tkinter to display an image and text like this Like this

however I do not know how to do it, any help would be appreciated.

I tried writing some code of my own, however the most I got is text displaying UNDER the image, not next to it like shown

1 Answers1

1

The anwser was in the explanation of grid geometry posted by figbeam.

The only thing I needed to do was add rowspan=2, columnspan=2

If someone wants to see the final code;

    from tkinter import *
    from PIL import ImageTk, Image
    
    root = Tk()
    root.geometry("800x500")
    img = ImageTk.PhotoImage(Image.open("img.png"))
    
    panel = Label(root, image = img)
    panel.grid(row=0,column=0, rowspan=2, columnspan=2)
    
    text1 = "Hello World"
    text2 = "Hello Again"
    
    l1 = Label(root, text = text1).grid(row = 0, column = 2, sticky=S)
    l2 = Label(root, text = text2).grid(row = 1, column = 2, sticky=N)
    
    
    root.mainloop()
  • Correct for row. l1 = Label(root, text = text1).grid(row = 0, column = 2, sticky=S) l2 = Label(root, text = text2).grid(row = 1, column = 2, sticky=N) – toyota Supra Feb 04 '23 at 19:55