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
http://www.riverbankcomputing.com/software/sip/download
http://pyqt.sourceforge.net/Docs/sip4/i ... ownloading

These are librarys that will be needed for installing pyqt.

2. Download and Install Qt
http://qt-project.org/downloads

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
http://pyqt.sourceforge.net/Docs/PyQt4/ ... ation.html

In the untared folder, Run "python configure.py -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):
        QWidget.__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)
        self.cw = QWidget(self)
        self.setCentralWidget(self.cw)
        self.btn1 = QPushButton("We did it Dan! All Hale Systems! Bringers of Python!", self.cw)
        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))
        self.w.show()

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

    def byebye( self ):
        self.exit(0)

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

if __name__ == "__main__":
    main(sys.argv)



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

PYTHONPATH=/usr/lib64/python2.6/site-packages:$PYTHONPATH
PYTHONPATH=/usr/lib64/python2.6/site-packages/PyQt4:$PYTHONPATH
User avatar
jspada20
 
Posts: 14
Joined: Oct 19th, '13, 16:33

Return to Linux

Who is online

Users browsing this forum: No registered users and 1 guest