Invisible button (using pack_forget) still occupies space
Question: I use pack_forget() to make a button invisible. But when i subsequently create
a label, it appears bellow the invisible button. How can i avoid this
displacement?

The following sample code demonstrates the issue:

    
    
    from tkinter import *
    
    class Application(Frame):
        def secondwidget(self):
            self.b.pack_forget()
            self.l = Label(text="Lowered Label :(")
            self.l.pack()
    
        def firstwidget(self):
            self.b = Button(self)
            self.b["text"] = "Button"
            self.b["command"] = self.secondwidget
            self.b.pack()
    
        def __init__(self, master=None):
            Frame.__init__(self, master)
            self.pack()
            self.firstwidget()
    
    root = Tk()
    app = Application(master=root)
    app.mainloop()
    root.destroy()
    

EDIT: I use python 3.2


Answer: You forgot to set parent for label:

    
    
    self.l = Label(text="Lowered Label :(")
    print(self.l.winfo_parent() == str(self))
    >>> False
    

Compare:

    
    
    self.b = Button(self)
    print(self.b.winfo_parent() == str(self))
    >>> True
    

