|
|
#1 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,272
Karma: 16544702
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 04:42 PM. Reason: think I've got it now |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,650
Karma: 28549046
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,272
Karma: 16544702
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Thanks for the example
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem loading widget | oldyellr | Kobo Tablets | 1 | 08-23-2012 11:30 AM |
| Anyone know how to write a widget? | NDRisk | Kobo Tablets | 9 | 11-27-2011 11:20 AM |
| Pi Chart Battery Widget | aglick | enTourage eDGe | 2 | 09-18-2011 07:03 PM |
| PyQT warning... | alexxxm | Calibre | 1 | 07-28-2008 05:18 AM |
| iLiad Widget style | tomchek | iRex Developer's Corner | 5 | 08-02-2007 12:16 PM |