I am trying to build an application using Tkinter library. When I am creating labels pervious label doesn't show window and last label also showing wrong label name. Right now my python version is 3.9 and tkinter version 8.6 . I went through all the question related to issue, but couldn't find any solution at stack overflow forum. Below I am pasting my dummy code. Kindly help me debugging my code.
'''
from tkinter import *
window = Tk()
window.title("Window") ## giving window a name
window.geometry("600x600")
window.resizable(False,False)
Label(window,text="Name",font="10").place(x=30,y=110)
Label(window,text="Place",font="10").place(x=30,y=110)
Label(window,text="Age",font="10").place(x=30,y=110)
mainloop()
'''
CodePudding user response:
You have placed the labels at the same coordinates so they will be placed on top of each other. Try with different x & y parameters to separate them:
from tkinter import *
window = Tk()
window.title("Window") ## giving window a name
window.geometry("600x600")
window.resizable(False,False)
Label(window,text="Name",font="10").place(x=30,y=110) # Diffterent
Label(window,text="Place",font="10").place(x=30,y=130) # vertical
Label(window,text="Age",font="10").place(x=30,y=150) # placement
mainloop()
CodePudding user response:
You have placed all the labels at the same location (30,110). That's the reason why the content of the labels overlap and "Age e" is displayed. As "Age" is the last label you add to the screen, it is displayed on top of the other two labels.
If you give the labels different locations, you will be able to view all the labels correctly.