| 1 |
############################################################################# |
| 2 |
## |
| 3 |
## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
## Contact: Qt Software Information (qt-info@nokia.com) |
| 5 |
## |
| 6 |
## This file is part of the Graphics Dojo project on Qt Labs. |
| 7 |
## |
| 8 |
## This file may be used under the terms of the GNU General Public |
| 9 |
## License version 2.0 or 3.0 as published by the Free Software Foundation |
| 10 |
## and appearing in the file LICENSE.GPL included in the packaging of |
| 11 |
## this file. Please review the following information to ensure GNU |
| 12 |
## General Public Licensing requirements will be met: |
| 13 |
## http:#www.fsf.org/licensing/licenses/info/GPLv2.html and |
| 14 |
## http:#www.gnu.org/copyleft/gpl.html. |
| 15 |
## |
| 16 |
## If you are unsure which license is appropriate for your use, please |
| 17 |
## contact the sales department at qt-sales@nokia.com. |
| 18 |
## |
| 19 |
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 20 |
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 21 |
## |
| 22 |
############################################################################# |
| 23 |
|
| 24 |
import sys |
| 25 |
|
| 26 |
from PyQt4.QtCore import * |
| 27 |
from PyQt4.QtGui import * |
| 28 |
from PyQt4.QtWebKit import * |
| 29 |
|
| 30 |
class Container(QWidget): |
| 31 |
|
| 32 |
def __init__(self): |
| 33 |
|
| 34 |
QWidget.__init__(self) |
| 35 |
|
| 36 |
self.view = QWebView(self) |
| 37 |
|
| 38 |
layout = QVBoxLayout(self) |
| 39 |
self.setLayout(layout) |
| 40 |
layout.addWidget(self.view) |
| 41 |
|
| 42 |
palette = self.view.palette() |
| 43 |
palette.setBrush(QPalette.Base, Qt.transparent) |
| 44 |
self.view.page().setPalette(palette) |
| 45 |
self.view.setAttribute(Qt.WA_OpaquePaintEvent, False) |
| 46 |
self.connect(self.view, SIGNAL("titleChanged(const QString&)"), |
| 47 |
self.setWindowTitle) |
| 48 |
|
| 49 |
self.view.load(QUrl("http://en.mobile.wikipedia.org/")) |
| 50 |
|
| 51 |
self.resize(320, 480) |
| 52 |
|
| 53 |
def paintEvent(self, event): |
| 54 |
|
| 55 |
QWidget.paintEvent(self, event) |
| 56 |
|
| 57 |
p = QPainter(self) |
| 58 |
p.fillRect(event.rect(), Qt.transparent) |
| 59 |
p.setPen(Qt.NoPen) |
| 60 |
p.setBrush(QColor(249, 247, 96)) |
| 61 |
p.setOpacity(0.6) |
| 62 |
p.drawRoundedRect(self.rect(), 10, 10) |
| 63 |
p.end() |
| 64 |
|
| 65 |
if __name__ == "__main__": |
| 66 |
|
| 67 |
app = QApplication(sys.argv) |
| 68 |
|
| 69 |
w = Container() |
| 70 |
w.setAttribute(Qt.WA_TranslucentBackground, True) |
| 71 |
w.setWindowFlags(Qt.FramelessWindowHint) |
| 72 |
w.show() |
| 73 |
|
| 74 |
sys.exit(app.exec_()) |