Python GUI How To Create AboutBox In Pyside2

In this Python GUI Development i want to show you How To Create AboutBox In Pyside2, basically we are using QMessageBox class for AboutBox creation.

 

Check Python GUI Development With Pyside2

 

1: Getting Started With Pyside2 | Qt For Python 

2: Pyside2 GUI Creating First Window 

3: Pyside2 GUI Creating Window Icon

4: Pyside2 GUI How To Create Icon Modes

5: Pyside2 GUI How To Create Tooltip

6: Pyside2 GUI QPushButton With Signal And Slot

7: Pyside2 GUI Making Center The Window 

 

So now this is the complete code for Python GUI How To Create AboutBox In Pyside2

 

OK in the above code  first we have imported our classes from Pyside2 library

 

And this is our main window class that inherits from QWidget, in that class we are going to add the window title , window geometry and minimum width and height for the window.

also you can check Python Object Oriented Programming Articles in this link. Python Object Oreinted Programming. also we have added the setIcon() and pushButton() methods in this class.

 

 

 

and also this method is for setting our window icon

 

 

OK now this is the method for creation of QPushButton, because in this example we are going to use from Signal And Slots mechanism and we want to connect aboutBox() slot or method to the clicked() signal of the QPushButton.

 

 

 

And this is the aboutBox() method or slot, basically we are using QMessageBox class in this example.

 

 

What is QMessageBox ?

A message box displays a primary text to alert the user to a situation, an informative text to further explain the alert or to ask the user a question, and an optional detailed text to provide even more data if the user requests it. A message box can also display an icon and standard buttons for accepting a user response.

 

 

So in here every Pyside2 application must create an application object. The sys.argv parameter is a list of arguments from a command line.

Python scripts can be run from the shell. It is a way how we can control the startup of our scripts.

 

 

 

Finally, we enter the mainloop of the application. The event handling starts from this point. The mainloop receives events from the window system and dispatches them to the application widgets. The mainloop ends if we call the exit() method or the main widget is destroyed. The sys.exit() method ensures a clean exit. The environment will be informed how the application ended.

The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.

 

 

 

Now run the complete code and this will be the result

Python GUI How To Create AboutBox In Pyside2
Python GUI How To Create AboutBox In Pyside2

 

 

Also you can watch the complete video for this article

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×