Python Forum
Hide button when clicked
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hide button when clicked
self.w3=Button(self.root,text="This must dissapear when clicked ",font="Arial 12",bg="#d9d9d9",command=self.check)
This button calls a an other function called "check",but how can i make it so when it gets clicked,it dissapears?
I am reading about binds and the "configure" method right now.Any ideas?
since you didn't specify which GUI you were using, and it looks like tkinter, I will assume that is the case.
You should also post at minimum a snippet that will run, and any errors encountered (verbatim)

try in check routine (untested as not enough code to run):
def check(self):
to make it re-appear self.w3.lift()
Hello!.I am using tkinter,you are correct.I tried your code but did not make it work. This a snippet.Enough to fix the issue,i guess.

def start(self):
        self.w=Label(self.root,text="Πρόσθεση πινάκων παραδείγματα",font="Arial 12")
        self.w1=Label(self.root,text="Διάλεξε τις διαστάσεις του πρώτου πίνακα",font="Arial 12")
        self.s1=Label(self.root,text="X:",font="Arial 10")
        self.entry1=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.s2=Label(self.root,text="Y:",font="Arial 10")
        self.entry2=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.w2=Label(self.root,text="Διάλεξε τις διαστάσεις του δεύτερου πίνακα",font="Arial 12")
        self.s3=Label(self.root,text="X:",font="Arial 10")
        self.entry3=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.s4=Label(self.root,text="Y:",font="Arial 10")
        self.entry4=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.w3=Button(self.root,text="Must be gone when clicked",font="Arial 12",bg="#d9d9d9",command=self.multi)
the self.multi command is this def
    def multi(self):
        self.check() #verifies some variables,ignore
        self.w3.lower()# tries to minimize the button

def multi(self):
        self.w3['state']=DISABLED ##lockes the button upon click!
Managed to do it!.I locked it.Its ok and works. Thanks!

Possibly Related Threads…
Thread Author Replies Views Last Post
  [tkinter] not getting checkbutton value when clicked OogieM 5 742 Sep-20-2020, 04:49 PM
Last Post: deanhystad
  [PyQt] Avoid clicked event from button when button is not physically selected and clicked mart79 2 589 May-05-2020, 12:54 PM
Last Post: mart79
  [Tkinter] Displaying Data from a database and run a function when clicked? PythonNPC 1 576 Mar-11-2020, 08:16 PM
Last Post: Larz60+
  tkinter button not accessing the command when clicked jhf2 1 861 Nov-23-2019, 10:17 PM
Last Post: DT2000
  [Tkinter] How to check after 30 minutes if Buttons have been clicked? bmghafoor 1 709 Aug-09-2019, 04:57 PM
Last Post: Yoriz
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 1,879 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [PyQt] Hide Dock Icon for QSystemTrayIcon App AeglosGreeenleaf 0 1,202 Jun-20-2019, 07:21 PM
Last Post: AeglosGreeenleaf
  General help with hide show status bar for a begineer in python ArakelTheDragon 0 1,002 Mar-17-2019, 11:58 AM
Last Post: ArakelTheDragon
  [PyGUI] Hi All, how to hide/mask user input in PySimpleGUI nmrt 1 5,805 Sep-21-2018, 09:59 AM
Last Post: nmrt
  [PYQT5] Crashing when using .hide() and .show() aking76 0 4,116 Sep-18-2018, 02:09 PM
Last Post: aking76

Forum Jump:

User Panel Messages

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