[PyQt] Importing Css file
uahmed
gleam.uahmed at gmail.com
Wed Nov 30 20:29:21 GMT 2011
Thanks Scott it works for me . just one typo mistake in ur code
css = QtCore.QFile(':/my_stylesheet.css')
css.open(QtCore.QIODevice.ReadOnly)
if css.isOpen():
self.setStyleSheet(QtCore.QVariant(*css*.readAll()).toString())
css.close()
Thank you for your help
On Thu, Dec 1, 2011 at 1:10 AM, Scott Ballard <scott at scottballard.net>wrote:
> Give this a try, It works for me in my application. I'm able to embed the
> css file into the resources file.
>
> css = QtCore.QFile(':/my_stylesheet.css')
> css.open(QtCore.QIODevice.ReadOnly)
> if css.isOpen():
> self.setStyleSheet(QtCore.QVariant(qss.readAll()).toString())
> css.close()
>
> Cheers,
> -Scott
>
>
> On Wed, Nov 30, 2011 at 11:14 AM, uahmed <gleam.uahmed at gmail.com> wrote:
>
>> Hi
>>
>> Now i am getting this error on following code
>>
>> *Error : Could not parse stylesheet of widget 0x9743b58*
>>
>> Code :
>>
>>
>> #!/usr/bin/python
>> import os ,sys
>> from PyQt4.QtCore import *
>> from PyQt4.QtGui import *
>> file_path = QString("./css_file.css")
>> app =QApplication(sys.argv)
>> label = QLabel("message")
>> label.setStyleSheet(file_path)
>> label.show()
>> app.exec_()
>>
>> Css File
>>
>> QLabel#label {
>> color: red;
>> padding: 3px;
>> }
>> #label {
>> color: red;
>> padding: 3px;
>> }
>> label {
>> color: red;
>> padding: 3px;
>> }
>> .label {
>> color: red;
>> padding: 3px;
>> }
>>
>> Can anyone please help me in it :(
>>
>>
>>
>> On Tue, Nov 29, 2011 at 8:11 PM, uahmed <gleam.uahmed at gmail.com> wrote:
>>
>>> Hi ,
>>>
>>> I want to include a css file to pyqt application , i wrote the following
>>> code , but it is not effecting the properties of label
>>>
>>> my python code is this
>>>
>>> #!/usr/bin/python
>>> import os ,sys
>>> from PyQt4.QtCore import *
>>> from PyQt4.QtGui import *
>>> file_path = QString("css_file.qss")
>>> app =QApplication(sys.argv)
>>> label =QLabel("message")
>>> label.setStyleSheet(file_path)
>>> label.show()
>>> app.exec_()
>>>
>>> and "css_file.qss" containing this text
>>>
>>> .QLabel {
>>> font-weight: bold;
>>> font-size: 15px;
>>> color : green;
>>> }
>>>
>>>
>>
>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20111201/fa38313e/attachment-0001.html>
More information about the PyQt
mailing list