PyQt5 – Hide push button on click

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.

Acton performed : It hides the push button

Code :





# importing libraries
from PyQt5.QtWidgets import * 
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys
class Window(QMainWindow):
    def __init__(self):
        # setting title
        self.setWindowTitle("Python ")
        # setting geometry
        self.setGeometry(100, 100, 600, 400)
        # creating a button
        self.button = QPushButton("CLICK", self)
        # setting up the geometry
        self.button.setGeometry(200, 150, 200, 40)
        # connecting method when button get clicked
        # showing all the widgets
    # action method
    def clickme(self):
        # hiding the button
        # printing pressed
# create pyqt5 app
App = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# start the app


Output :

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


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.