[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] QWebView events usage
From:       laurlaur <tmlazarmarius () gmail ! com>
Date:       2009-06-30 11:11:38
Message-ID: 24270048.post () talk ! nabble ! com
[Download RAW message or body]


Hi,
Please help me with the following problem.
I want to have two QWebView windows which will be scrolled in the same time.
Basically my code looks like this:

import sys
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4 import QtGui

class Wpage(QWebView):
    def __init(self,parent =None):
        QWebView.__init__(self,parent)
#***********************************
#here I should add the normally the event handlers
# 
    def wheelEvent(self,event):
        print "test"


class main(QtGui.QMainWindow,Wpage) :      
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        page1 =Wpage(self)

        path =r"F:\test_compare\Qt_compare\immob_shutdown_Report.html"
        page1.load(QUrl(path))
        page1.setGeometry(10,50,600,700)
        self.xp =page1.page().mainFrame()
        page1.show()

        page2 =Wpage(self)

        path1 =r"F:\test_compare\Qt_compare\immob_shutdown_Report.html"
        page2.load(QUrl(path1))
        page2.setGeometry(620,50,600,700)
        self.xp1 =page2.page().mainFrame()
        page2.show()   
if __name__ =="__main__":
    app = QtGui.QApplication(sys.argv)
    mainwindow=main()
    mainwindow.setGeometry(5,5,1210,700)
    mainwindow.show()
    sys.exit(app.exec_())

I don't know how to use the scrollBarValue inside the events declared in the
Wpage class. At the first side it looks impossible to me.
Another solution which is working but it is very slow is to  declare a
general handling event inside the main class like this:
class main(QtGui.QMainWindow,Wpage) :      
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        #source code
    def event(self, event):

   
        global old_val
        try:
             
            self.val_scr_x_vrt =self.xp.scrollBarValue(Qt.Vertical)
            if old_val!=self.val_scr_x_vrt:
                u =self.x1_pos_prev+(self.val_scr_x_vrt-old_val)

                self.xp1.setScrollBarValue(Qt.Vertical,u)
                self.val_scr_x_hor =self.xp.scrollBarValue(Qt.Horizontal)
                self.xp1.setScrollBarValue(Qt.Horizontal,self.val_scr_x_hor)
                old_val=self.val_scr_x_vrt
                
            else:
                pass
            self.x1_pos_prev =self.xp1.scrollBarValue(Qt.Vertical) 
        except:
            pass
        return 0

This is working but It is very slow. Every html page requires an extra 10
seconds to load and if for example I want to search something in the page ,
the page will not be correctly refreshed.



-- 
View this message in context: http://www.nabble.com/QWebView-events-usage-tp24270048p24270048.html
Sent from the PyQt mailing list archive at Nabble.com.

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic