Home > OS >  Why doesnt my label show up in the window?
Why doesnt my label show up in the window?

Time:01-29

This is the script #Imports import os import time from tkinter import * from tkinter import ttk

#ws
ws = Tk()
ws.title('JCHS Chat')
ws.geometry('600x1000')

ws.mainloop()

root = Tk()
#Label Widget
myLabel = Label(root, text="You smell like dust")

#Actually putting it in
myLabel.pack()

#Looping the script
root.mainloop()

CodePudding user response:

What is happening is your creating two windows instead of just one. you can fix this by change your code to this.

from tkinter import *

#ws
ws = Tk()
ws.title('JCHS Chat')
ws.geometry('600x1000')

#Label Widget
myLabel = Label(ws, text="You smell like dust")
#Actually putting it in
myLabel.pack()
ws.mainloop()

CodePudding user response:

You are using root instead of ws, here is a fix.

myLabel = Label(ws, text = "You smell like dust").pack()
  •  Tags:  
  • Related