![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,248
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
PyQt help re: QWebView widget, please
I'm trying to experiment with the QWebView widget and having trouble getting to grips with the settings.setUserStyleSheetUrl option.
With this simple example: Code:
self.webview = QWebView() self.webview.setHtml(u'<body><p>This is a simple test</p></body>') self.webview.settings().setUserStyleSheetUrl(QUrl(u'p {color:red;}')) Edit: Nevermind, I think I finally figured it out ![]() This seems to work: Code:
from base64 import b64encode self.webview = QWebView() self.webview.setHtml(u'<body><p>This is a simple test</p></body>') self.webview.settings().setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64," + b64encode('body {color: red}'.encode('utf-8')))) Last edited by jackie_w; 10-27-2013 at 03:42 PM. Reason: think I've got it now |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,190
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
As you figured out, you have to use a data URL, see set_user_stylesheet() in documentview.py for an example.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,248
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Thanks for the example
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem loading widget | oldyellr | Kobo Tablets | 1 | 08-23-2012 10:30 AM |
Anyone know how to write a widget? | NDRisk | Kobo Tablets | 9 | 11-27-2011 10:20 AM |
Pi Chart Battery Widget | aglick | enTourage eDGe | 2 | 09-18-2011 06:03 PM |
PyQT warning... | alexxxm | Calibre | 1 | 07-28-2008 04:18 AM |
iLiad Widget style | tomchek | iRex Developer's Corner | 5 | 08-02-2007 11:16 AM |