Python Tkinter Label in Frame

后端 未结 2 1787
刺人心
刺人心 2021-01-25 07:33

I want to place a label inside a frame in tkinter, but I can\'t figure out how to actually get it inside.

import tkinter
from tkinter import *

W=tkinter.Tk()
W.         


        
2条回答
  •  遇见更好的自我
    2021-01-25 08:00

    I think it's because you're assigning FRAME to Frame(W, width=100, height =50).place(x=700,y=0), as opposed to just the actual frame, and according to the Place Manager reference, there doesn't seem to be a return value. Try this:

    import tkinter
    from tkinter import *
    
    W=tkinter.Tk()
    W.geometry("800x850+0+0")
    W.configure(background="lightblue")
    
    FRAME=Frame(W, width=100, height =50)
    FRAME.place(x=700,y=0)
    
    LABEL=Label(FRAME, text="test").pack()
    
    W.mainloop()
    

提交回复
热议问题