In this article we will see how to hide the push button. When we design a GUI (Graphical User Interface) we create push button in it which do some task when they are pressed. But some time their is a need to hide the button if task is completed, in order to hide the button we will use hide method.
Syntax : button.hide()
Argument : It takes no argument.
Action performed : It hides the push button
Code :
Python3
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 600 , 400 )
self .button = QPushButton( "CLICK" , self )
self .button.setGeometry( 200 , 150 , 200 , 40 )
self .button.clicked.connect( self .clickme)
self .show()
def clickme( self ):
self .button.hide()
print ( "pressed" )
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :

When click button is pressed, output will generate and button will get hidden.
pressed

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!