On 06/17/2010 07:52 PM, Darryl Wallace wrote:
Hello

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Robin Wittler
Sent: June-17-10 1:22 PM
To: [email protected]
Subject: [PyQt] newbie question about slots and signals

Hi,

i am totaly new to pyqt4 and it seems that i have a problem to
understand how signals and slots working.
First i thought this is all clear to me, but then i wrote this little
code snippet and - surprise surprise - it didn't work.
The moep method where never called. I've tried it with the
QtCore.pyqtSlot dekorator, but this didn't work neither.
So what am i doing wrong? What have i missunderstud?

cheers,
robin



#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4 import QtWebKit
from PyQt4 import QtSvg
from PyQt4 import QtNetwork

class Browser(QtWebKit.QWebView):
      def __init__(self, **kargs):
          QtWebKit.QWebView.__init__(self)
          self.manager = QtNetwork.QNetworkAccessManager()
          self.proxy = self.manager.proxy()
          self.proxy.setHostName('127.0.0.1')
          self.proxy.setPort(8080)
          self.proxy.setType(self.proxy.HttpProxy)
          self.manager.setProxy(self.proxy)
          self._page = self.page()
          self._page.setNetworkAccessManager(self.manager)
          self.connect(
                  self._page,
                  QtCore.SIGNAL('loadFinished(bool)'),
                  self.moep
          )

      def run(self):
          self._page.mainFrame().load(QtCore.QUrl('http://google.de'))

      def moep(self):
          print "load finished"


if __name__ == '__main__':
      app = QtGui.QApplication([])
      b = Browser()
      b.showFullScreen()
      b.run()
      sys.exit(app.exec_())


----------------------
The signal/slot connection seems to be working properly for me as "load
finished" appears in my console.  The webpage, however, didn't load.

Though, I would recommend a simpler example to learn the use of signals
and slots.  Why not just make a widget with a QPushButton and connect the
button's "clicked()" signal to a slot.

Darryl

Thanks for the quick answer.
The page doesn't load because of the proxy settings.
In my enviroment the page loads (because of the existing proxy)
but "load finished" is not printed. ;)

With a stopped proxy (but enabled proxy settings) the "load finished" string
will be printed (and the page will not load). If i start the proxy ,the
string will
not be printed (but the page loads).

wtf? :)

cheers,
Robin
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to