Python GUI with PyQT : Create Window

Install Python 3.7 (current version)

Before you go any further, make sure you have Python and that the expected version is available from your command line. You can check this by running:

python --version

You should get some output like Python 3.7.2.

install python 3.7

Install PyQT5 using
pip install pyqt5
Command

install pyqt 5

After the installation, start writing your programs

import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
class App(QWidget):
      def __init__(self):
              super().__init__()
              self.title='My First Window'
              self.left=200
              self.top=200
              self.width=500
              self.height=500
              self.initUI()
      def initUI(self):
              self.setWindowTitle(self.title)
              self.setGeometry(self.left,self.top,self.width,self.height)
              self.show()
if __name__=='__main__':
        app=QApplication(sys.argv)
        ex=App()
        sys.exit(app.exec_())

 

CODE IN IDLE

code in python idle

 

Output

output