[PyQt] Re: TextEdit background color
Lee Harr
missive at hotmail.com
Wed Dec 9 22:59:20 GMT 2009
> I use TextEdit widget, and i want that it's background color will
> black (for example)
>
> I tried to use TextEdit.setTextBackgroundColor but only background
> of text painted by black color.
>
> How can i color all TextEdit area by any color?
I have a QTextEdit subclass with black background, python syntax
highlighting and line numbers here:
http://code.google.com/p/pybotwar/source/browse/editor.py
But for just the background part:
from PyQt4 import QtGui
class TE(QtGui.QTextEdit):
def __init__(self):
QtGui.QTextEdit.__init__(self)
pal = QtGui.QPalette()
bgc = QtGui.QColor(0, 0, 0)
pal.setColor(QtGui.QPalette.Base, bgc)
textc = QtGui.QColor(255, 255, 255)
pal.setColor(QtGui.QPalette.Text, textc)
self.setPalette(pal)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
widget = TE()
widget.show()
sys.exit(app.exec_())
_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
More information about the PyQt
mailing list