Creating a simple window
The QWidget
is the base class for all the user interface classes. A widget can be a top-level widget or a child widget contained in a top-level or parent widget. Now, let's create a top-level window using QWidget
. The constructor of the QWidget
class takes two optional parameters, parent
and flags
. The parent
parameter can be a QWidget
object and the flags
parameter can be a combination of PySide.QtCore.Qt.WindowFlags
, as follows:
# Import required modules import sys, time from PySide.QtGui import * from PySide.QtCore import * # Our main window class class SampleWindow(QWidget): # Constructor function def __init__(self): super(SampleWindow,self).__init__() self.initGUI() def initGUI(self): self.setWindowTitle("Sample Window") self.setGeometry(300, 300, 200, 150) self.setMinimumHeight(100) self.setMinimumWidth(250) self.setMaximumHeight(200) self.setMaximumWidth(800) ...