0
votes

Here is the code,

from tkinter import *
root = Tk()

update_button = Button(root, text='Update')
update_button.pack()


def button():
    frame1 = Frame(root)
    frame1.pack()

    button1 = Button(frame1, text="Button 1")
    button1.pack(side=LEFT)

    button2 = Button(frame1, text="Button 2")
    button2.pack(side=LEFT)


button()

root.mainloop()

I want button1 to be stacked upon button2 when I click update button. Help please.

Simply call pack_forget() on the buttons and then pack() again to the way you want. - acw1668
Hey thanks for the reply, but could you please tell me how to use pack_forget() in the above code so that I can understand it better, please. - Milind Khobragade
Are you aware that you can set the side to "top" to arrange widgets in a vertical stack? - Bryan Oakley
yes I am aware. But I want those 2 buttons at "top" in one condition and at the "left" in another. - Milind Khobragade