Python Forum
Hide button when clicked
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hide button when clicked
#1
self.w3=Button(self.root,text="This must dissapear when clicked ",font="Arial 12",bg="#d9d9d9",command=self.check)
self.w3.grid(row=8,column=1)
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?
Reply
#2
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):
   ...
   self.w3.lower()
to make it re-appear self.w3.lift()
Reply
#3
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.w.grid(row=1,column=1)
        self.w1=Label(self.root,text="Διάλεξε τις διαστάσεις του πρώτου πίνακα",font="Arial 12")
        self.w1.grid(row=2,column=1)
        self.s1=Label(self.root,text="X:",font="Arial 10")
        self.entry1=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.entry1.grid(row=3,column=1)
        self.s2=Label(self.root,text="Y:",font="Arial 10")
        self.s2.grid(row=4,column=1)
        self.entry2=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.entry2.grid(row=4,column=1)
        self.w2=Label(self.root,text="Διάλεξε τις διαστάσεις του δεύτερου πίνακα",font="Arial 12")
        self.w2.grid(row=5,column=1)
        self.s3=Label(self.root,text="X:",font="Arial 10")
        self.s3.grid(row=6,column=1)
        self.entry3=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.entry3.grid(row=6,column=1)
        self.s4=Label(self.root,text="Y:",font="Arial 10")
        self.s4.grid(row=7,column=1)
        self.entry4=Entry(self.root,font="Arial 12",bg="#d9d9d9",width=5)
        self.entry4.grid(row=7,column=1)
        self.w3=Button(self.root,text="Must be gone when clicked",font="Arial 12",bg="#d9d9d9",command=self.multi)
        self.w3.grid(row=8,column=1)
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.check()
        self.w3['state']=DISABLED ##lockes the button upon click!
Managed to do it!.I locked it.Its ok and works. Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Button clicked not working catlessness 10 8,085 Oct-21-2021, 12:36 PM
Last Post: catlessness
  [Tkinter] Hide clicked buttons Rubberduck 6 3,447 Jun-02-2021, 12:44 PM
Last Post: Rubberduck
  [tkinter] not getting checkbutton value when clicked OogieM 5 5,884 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 2,309 May-05-2020, 12:54 PM
Last Post: mart79
  [Tkinter] Displaying Data from a database and run a function when clicked? PythonNPC 1 2,024 Mar-11-2020, 08:16 PM
Last Post: Larz60+
  tkinter button not accessing the command when clicked jhf2 1 3,502 Nov-23-2019, 10:17 PM
Last Post: DT2000
  [Tkinter] How to check after 30 minutes if Buttons have been clicked? bmghafoor 1 2,077 Aug-09-2019, 04:57 PM
Last Post: Yoriz
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 4,949 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [PyQt] Hide Dock Icon for QSystemTrayIcon App AeglosGreeenleaf 0 3,264 Jun-20-2019, 07:21 PM
Last Post: AeglosGreeenleaf
  General help with hide show status bar for a begineer in python ArakelTheDragon 0 2,752 Mar-17-2019, 11:58 AM
Last Post: ArakelTheDragon

Forum Jump:

User Panel Messages

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