How To Create Frame In PyQt5 (QFrame)

In this PyQt5 article  i want to show you How To Create Frame In PyQt5 (QFrame) with

QFrame class. also i want to show you how you can give stylesheet to your PyQt5 Window

and QFrame . The QFrame class is the base class of widgets that can have a frame. QMenu

uses this to “raise” the menu above the surrounding screen. QProgressBar has a “sunken”

look. QLabel has a flat look. The frames of widgets like these can be changed.

 

 

 

Also you can read more Python GUI articles in the below links

1: Kivy GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: Psyide2 GUI Development 

4: wxPython GUI Development Tutorials

5: PyQt5 GUI Development Tutorials

 

 

 

 

 

First we need some imports

 

 

 

 

 

After that we are going to create our main Window class that extends from QWidget. and in

the constructor of the class we need to add some requirements of the window like set window

title, window icon and window geometry.

 

 

 

 

 

You can change the color of your window by this code.

 

 

 

 

 

In here we create QPushButton object, also we want to set styleSheet fro our button.

 

 

 

 

 

This is for creating of our QFrame.

 

 

 

 

 

Also every PyQt5 application must create an application object.

 

 

 

 

Finally, we enter the mainloop of the application. The event handling starts from this point. 

 

 

 

 

 

 

Run the complete code and this will be the result

How To Create Frame In PyQt5 (QFrame)
How To Create Frame In PyQt5 (QFrame)

 

 

 

 

 

 

Complete source code for How To Create Frame In PyQt5 (QFrame)

 

 

 

 

 

 

Also you can watch the complete video for this article

Thank you for visiting my website! If you enjoyed this article, please consider supporting my works on Patreon.

Leave a Comment

Share via
Copy link
Powered by Social Snap