How to Open Second Window with PyQt5

In this PyQt5 article we want to learn How to Open Second Window with PyQt5, so PyQt5 is  a set of Python bindings for Qt v5. it is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android. PyQt5 is used to write all kinds of GUI applications, from accounting applications, to visualization tools used by scientists and engineers.



You can install PyQt5 using pip like this.



This is the complete code for this article

In the above example we have created two windows, Window1 and Window2. Window1 contains a button that when we click on that, it opens Window2. open_window2 method creates new instance of Window2 and shows it using the show method, also in Window2 we have added QLabel in the window.

Make sure to import both windows in your main file, and create an instance of the first window to show it. after that when you run your program, both windows will be displayed and you can click the button in Window1 to open Window2.




Run the complete code and this will be the result

How to Open Second Window with PyQt5
How to Open Second Window with PyQt5



Learn More on Python GUI

Leave a Comment