PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 3, 2022

[FIXED] how to add a button within a button on tkinter?

 November 03, 2022     button, function, lambda, python, tkinter     No comments   

Issue

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)

Solution

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)


Answered By - stysan
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing