skip to Main Content

I’m trying to print out information into this window and not in the console. How do I do this?

from tkinter import *

print("Hello")
gui = Tk(className='StreetView Map')
# set window size
gui.geometry("500x200")

gui.mainloop()

I tried using the print function but nothing showed up in the window.

2

Answers


  1. You can create a Label.

    Label(gui, text="Hello").pack()
    
    Login or Signup to reply.
  2. You need to Create a Text widget where you can insert the test on GUI on Tkinter.

    Given your code it would have to be done like this.

    from tkinter import *
    
    gui = Tk(className='StreetView Map')
    
    # set window size
    gui.geometry("500x200")
    
    T = Text(root, height = 5, width = 52)
    T.pack()
    
    #insert the string in Text Widget
    T.insert(tk.END, "hello")
    
    gui.mainloop()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search