Skip to content
Related Articles

Related Articles

Improve Article
PySide2 – How to create window?
  • Last Updated : 18 Aug, 2020

PySide2 is one of the most famous libraries in python for building GUI applications. In this article, we will build an empty window using PySide2 Library.

Steps to create empty window :

1. Import PySide2 in your code
2. Create QApplication object
3. Create object for QWideget
4. Increase the size of the window.
4. Show window using show() function

Python3




# import system module
import sys
  
# import PySide2 modules
from PySide2.QtWidgets import QApplication, QWidget
  
# create new app
app = QApplication(sys.argv)
  
# create main window
mainwindow = QWidget()
  
# resize window to 550 * 400
mainwindow.resize(550, 400)
  
# set title to the window frame
mainwindow.setWindowTitle('GeeksForGeeks')
  
# invoke show function
mainwindow.show()
  
# to kee in loop invoke exec_() function
app.exec_()

As we execute this program, a new empty window of size 550*400 will pop up on your screen with a label ‘GeeksforGeeks’.

Output:

 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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :