installing pyqt on linux

Linux at SCAD SFDM for those who use it!

installing pyqt on linux

Postby jspada20 on Aug 1st, '14, 11:56

1. Download and Install SIP ... ownloading

These are librarys that will be needed for installing pyqt.

2. Download and Install Qt

Will install to /opt/Qt
If you are installing somewhere else note the location
Select tools and the latest version

3.Download and Install PyQt ... ation.html

In the untared folder, Run "python -q /opt/Qt/5.3/gcc_64/bin/qmake"
If you did not install to /Opt/Qt, replace with your path

Run "make" in the downloaded folder. Will take a little bit of time to build everything. Took me about 10 minutes!

Run "make install" This is much quicker.

4. Finally Test it! I attached a python script. If done correctly, when you run it (python <path to file>), it should build and bring up a window with a button in it! AMAZING!

Forum will not let me attach a python file so copy this code into an empty doc and add a py extension to it. Note that indentation is required and important!
Code: Select all
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import sys
from PyQt4.Qt import *

class MyPopup(QWidget):
    def __init__(self):

    def paintEvent(self, e):
        dc = QPainter(self)
        dc.drawLine(0, 0, 100, 100)
        dc.drawLine(100, 0, 0, 100)

class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args) = QWidget(self)
        self.btn1 = QPushButton("We did it Dan! All Hale Systems! Bringers of Python!",
        self.btn1.setGeometry(QRect(0, 0, 500, 30))
        self.connect(self.btn1, SIGNAL("clicked()"), self.doit)
        self.w = None

    def doit(self):
        print "Opening a new popup window..."
        self.w = MyPopup()
        self.w.setGeometry(QRect(100, 100, 400, 200))

class App(QApplication):
    def __init__(self, *args):
        QApplication.__init__(self, *args)
        self.main = MainWindow()
        self.connect(self, SIGNAL("lastWindowClosed()"), self.byebye )

    def byebye( self ):

def main(args):
    global app
    app = App(args)

if __name__ == "__main__":

5. Add the following lines to where the env var PYTHONPATH is set. This will let applications find the module by default.

User avatar
Posts: 14
Joined: Oct 19th, '13, 16:33

Return to Linux

Who is online

Users browsing this forum: No registered users and 1 guest