2015年10月20日 星期二

Color of QTextEdit

Palett = QtGui.QPalette()
Palett.setColor(QtGui.QPalette.Base,  QtCore.Qt.black)
Palett.setColor(QtGui.QPalette.Text, QtCore.Qt.white)
self.setPalette(Palett)

QT use palett to set color of widget, and Base mean base color of widget
this is different with background

PyQt5 install

Install PyQt5.5 on Macos

Macos: 10.10.5
Python: 3.4.3
PyQt: 5.5
https://riverbankcomputing.com/software/pyqt/download5
download source
http://sourceforge.net/projects/pyqt/files/sip/sip-4.16.9/sip-4.16.9.tar.gz/download

install Qt5
add qmake path
sudo vi /etc/paths
add '/Users/xxx/Qt5.5.0/5.5/clang_64/bin

cd Path/of/PyQt
python3 configure.py
make
make install
(install to /Library/Frameworks/Python.framework)


#! /Library/Frameworks/Python.framework/Versions/3.4/bin/python3
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class Editor(QMainWindow):
    def __init__(self, parent=None):
        super(Editor, self).__init__(parent)
        self.text = QTextEdit(self)
        self.setCentralWidget(self.text)
        self.setWindowTitle("PyEditor")

if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)

    mainWindow = Editor()
    mainWindow.show()

    sys.exit(app.exec_())