Home > database >  how to add a button within a button on tkinter?
how to add a button within a button on tkinter?

Time:10-30

i have a button in grid, and it already has one command, which just prints text. However i want a button to pop up as well as the text. so long story short, i'm just trying to add a button within a button. (multiple functions within one button basically) This is what i have so far.

def myClick():
    myLabel = Label(text="Hello "   e.get()   "...    text  ", bg='black')
    myLabel.grid(row=60, column=0)

myButton = Button(window, bg='black', text="next", command=myClick)
myButton.grid(row=0, column=13)

CodePudding user response:

Glad to answer your question once again. Comments in the code will explain some stuff you may ask.

def myClick():
    # clearing up the window
    for widget in window.winfo_children():
        widget.destroy()
    
    # creating a new page
    myLabel = Label(text="Hello "   e.get()   "...    text  ", bg='black')
    myLabel.grid(row=60, column=0)
    
    newButton = Button(window, bg='black', text="Some button you want to appear")
    newButton.grid(row=60, column=13)

myButton = Button(window, bg='black', text="next", command=myClick)
myButton.grid(row=0, column=13)
  • Related