Python Forum
[Tkinter] Command button, then more command buttons
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Command button, then more command buttons
#4
Dear Python Users:

I've added some submenus to the option buttons.

1) First start the program.
2) Press the red "Press here to start button"
5 option buttons will come up.
3) Press option1. 3 finalsel buttons come up (but the options buttons don't disappear).

In the "final function" there are 5 commented out commands at the beginning of the function.
I am a beginner but I am sure these commands don't work because of namespace and/or scope issues.

Is there a way to get the option buttons to disappear without using global variables?

import tkinter as tk
root = tk.Tk()
root.geometry("800x800")


#Secondmenu brings up a second set of buttons.  How do I make the "Press here to starbutton" disappear before this second set of buttons come up

def secondmenu():
    start.pack_forget()

    Option1  = tk.Button(root, text="Option1", bg="white", \
                            fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack()

    Option2  = tk.Button(root, text="Option2", bg="white", \
                            fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack()

    Option3  = tk.Button(root, text="Option3", bg="white", \
                            fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack()

    Option4  = tk.Button(root, text="Option4", bg="white", \
                            fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack()

    Option5  = tk.Button(root, text="Option5", bg="white", \
                            fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack()

def final ():
    
    #Option1.pack_forget()
    #Option2.pack_forget()
    #Option3.pack_forget()
    #Option4.pack_forget()
    #Option5.pack_forget()
    finalsel1= tk.Button(root, text="finalsel1", bg="white", \
                        fg="firebrick", relief="groove", font="Helvitica 30", ).pack()

    finalsel2 = tk.Button(root, text="finalsel2", bg="white", \
                        fg="firebrick", relief="groove", font="Helvitica 30", ).pack()

    finalsel3 = tk.Button(root, text="finalsel3", bg="white", \
                        fg="firebrick", relief="groove", font="Helvitica 30", ).pack()


#This is the button you will see when you start the program

start = tk.Button(root, text="Press here to start", bg="red", fg="black", font = "Helvitica 30",command = secondmenu)

start.pack()

root.mainloop()
Reply


Messages In This Thread
RE: Command button, then more command buttons - by Heyjoe - Aug-08-2020, 01:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm trying to create a GUI in Python which would accept a bash command max22 1 724 Nov-13-2023, 04:40 AM
Last Post: deanhystad
  [PyGUI] Invalid command error with Entry object eliqm 8 2,255 May-18-2023, 10:14 PM
Last Post: eliqm
  tkinter.TclError: can't invoke "canvas" command cybertooth 8 6,094 Feb-23-2023, 06:58 PM
Last Post: deanhystad
  [PyQt] command require close window Krissstian 14 3,043 Nov-19-2022, 04:18 PM
Last Post: Krissstian
  [Tkinter] Scrollable buttons with an add/delete button Clich3 5 3,504 Jun-16-2022, 07:19 PM
Last Post: rob101
  [Tkinter] Button 'command' Argument Confusion gw1500se 11 5,944 Nov-11-2021, 08:45 PM
Last Post: menator01
  [Tkinter] Extracting Data from a Command Subroutine gw1500se 0 1,115 Nov-11-2021, 08:02 PM
Last Post: gw1500se
  [Tkinter] _tkinter.TclError: can't invoke "destroy" command: application has been destroyed knoxvilles_joker 6 15,768 Apr-25-2021, 08:41 PM
Last Post: knoxvilles_joker
  Continue command in python tkinter? MLGpotato 7 8,559 Mar-27-2021, 04:59 AM
Last Post: deanhystad
  [PyGUI] My GUI crashes after command MLGpotato 1 1,918 Feb-21-2021, 03:17 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020