Exemple #1
0
    def __init__(self, url):
        QWidget.__init__(self, None, Qt.ToolTip)
        self.url = url
        
        self.font = QFont(QApplication.font(self))
        self.font.setPointSize(8)
        
        desktop = QApplication.desktop().availableGeometry(self)
        cursor = QCursor.pos()
        rect = QRect(cursor + QPoint(-10, 10), QSize(240,180 + QFontMetrics(self.font).height()))
        if rect.left() < desktop.left():
            rect.moveLeft(desktop.left())
        if rect.right() > desktop.right():
            rect.moveRight(cursor.x() - 10)
        if rect.bottom() > desktop.bottom():
            rect.moveBottom(cursor.y() - 10)
        self.setGeometry(rect)
        
        self.pixmap = None
        self.progress = 0
        self.title = unicode(self.url)

        self.webView = QWebView()
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        self.webView.resize(1024,768)
        self.webView.load(QUrl(url))
        
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL("timeout()"), self.refresh)
        self.timer.start(3000)
        
        self.connect(self.webView, SIGNAL("loadFinished(bool)"), self.refresh)
        self.connect(self.webView, SIGNAL("loadProgress(int)"), self.updateProgress)
        self.connect(self.webView, SIGNAL("urlChanged(const QUrl&)"), self.newUrl)
        self.connect(self.webView, SIGNAL("titleChanged(const QString&)"), self.newTitle)