Python Tkinter destroy label after the click of a button

前端 未结 1 932
春和景丽
春和景丽 2021-01-28 09:34

I have a label which appears after the click of a button, however after each click of the button the previous label remains in its position and a new one is created, I would lik

相关标签:
1条回答
  • 2021-01-28 09:44

    Instead of recreating that label every click, you can create it with empty text then change its content on every click.

    def helloCallBack():
        ...
        ...
        label2.configure(text="IPVoid: " + elem.text)
    
    label2 = tk.Label(root1, text="") 
    #or just label2 = tk.Label(root1) used that one to make it explicit right now
    label2.pack(side=tk.BOTTOM)
    
    0 讨论(0)
提交回复
热议问题