Python PyQt on macOS Sierra

前端 未结 6 1332
忘了有多久
忘了有多久 2020-12-08 15:18

How can I get to work PyQt 4 or 5 on a Mac with OS X Sierra? It seems that I have to wait for a new version of PyQt but I am not sure if that is actually true.

6条回答
  •  旧巷少年郎
    2020-12-08 15:40

    1:

    brew install cartr/qt4/pyqt
    brew link qt@4
    

    2: go here and download https://riverbankcomputing.com/software/sip/download

    and do

    tar -xzvf sip-4.19.6.tar.gz
    cd sip-4.19.6
    python configure.py
    make
    make install
    

    3: go here and download : https://riverbankcomputing.com/software/pyqt/download

    and do

    tar -xzvf PyQt4_gpl_mac-4.12.1.tar.gz
    cd PyQt4_gpl_mac-4.12.1
    python configure.py
    make
    make install
    

    4: test in python:

    import sys;
    from PyQt4 import QtGui;
    
    def pyqtDemo():
        app = QtGui.QApplication(sys.argv);
    
        w = QtGui.QWidget();
        w.resize(250, 150);
        w.move(300, 300);
        w.setWindowTitle('Hello World');
        w.show();
    
        sys.exit(app.exec_());
    
    pyqtDemo()
    

提交回复
热议问题