<div dir="ltr">Thanks Scott it works for me . just one typo mistake in ur code <br><br><div>css = QtCore.QFile(':/my_stylesheet.css')</div><div>css.open(QtCore.QIODevice.ReadOnly)</div>
<div>if css.isOpen():</div><div> self.setStyleSheet(QtCore.QVariant(<b>css</b>.readAll()).toString())</div><div>css.close()</div><br>Thank you for your help<br><br><div class="gmail_quote">On Thu, Dec 1, 2011 at 1:10 AM, Scott Ballard <span dir="ltr"><<a href="mailto:scott@scottballard.net">scott@scottballard.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div>Give this a try, It works for me in my application. I'm able to embed the css file into the resources file.</div>
<div><br></div><div>css = QtCore.QFile(':/my_stylesheet.css')</div><div>css.open(QtCore.QIODevice.ReadOnly)</div>
<div>if css.isOpen():</div><div> self.setStyleSheet(QtCore.QVariant(qss.readAll()).toString())</div><div>css.close()</div></div>
<div><br></div>Cheers,<div>-Scott</div><div><br><div><br><div class="gmail_quote"><div><div class="h5">On Wed, Nov 30, 2011 at 11:14 AM, uahmed <span dir="ltr"><<a href="mailto:gleam.uahmed@gmail.com" target="_blank">gleam.uahmed@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div class="h5"><div dir="ltr">Hi <br><br>Now i am getting this error on following code <br>
<br><b>Error : Could not parse stylesheet of widget 0x9743b58</b><br>
<br>Code :<div><br><br>#!/usr/bin/python<br>import os ,sys<br>from PyQt4.QtCore import * <br>
from PyQt4.QtGui import *<br></div>file_path = QString("./css_file.css")<br>app =QApplication(sys.argv)<br>label = QLabel("message")<br>label.setStyleSheet(file_path)<br>label.show()<br>app.exec_()<br>
<br>Css File <br>
<br>QLabel#label {<br> color: red;<br> padding: 3px;<br> }<br>#label {<br> color: red;<br> padding: 3px;<br> }<br>label {<br> color: red;<br> padding: 3px;<br> }<br>
.label {<br> color: red;<br> padding: 3px; <br> }<br><br>Can anyone please help me in it :(<div><div><br><br><br><div class="gmail_quote">On Tue, Nov 29, 2011 at 8:11 PM, uahmed <span dir="ltr"><<a href="mailto:gleam.uahmed@gmail.com" target="_blank">gleam.uahmed@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">Hi , <br><br>I want to include a css file to pyqt application , i wrote the following code , but it is not effecting the properties of label <br>
<br>my python code is this<br><br>#!/usr/bin/python<br>import os ,sys<br>
from PyQt4.QtCore import *<br>from PyQt4.QtGui import *<br>file_path = QString("css_file.qss")<br>app =QApplication(sys.argv)<br>label =QLabel("message")<br>label.setStyleSheet(file_path)<br>label.show()<br>
app.exec_()<br><br>and "css_file.qss" containing this text<br><br>.QLabel {<br>font-weight: bold;<br>font-size: 15px;<br>color : green;<br>}<br><br></div>
</blockquote></div><br></div></div></div>
<br></div></div>_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div></div>
</blockquote></div><br></div>