Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8830813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:10:43+00:00 2026-06-14T08:10:43+00:00

I’just started learning PyQt4, and playing with signals and slots, Please help me to

  • 0

I’just started learning PyQt4, and playing with signals and slots,
Please help me to fix my code in such a way that after site is fully downloaded, it will print html of this webpage. Right now it just stops after “load finished”

my code:

#! /usr/bin/env python2.7

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

class Browser(QObject):
    def __init__(self):
        QObject.__init__(self)
    def print_percent(self, percent):
        print percent
    def print_load_finished(self):
        print 'Load Finished'
        self.print_html
    def print_html(self, ok):
        frame = QWebView.page().mainFrame()
        print unicode(frame.toHtml()).encode('utf-8')

if __name__=='__main__':
    app = QApplication(sys.argv)
    view = QWebView()
    br = Browser()
    url = QUrl('http://python.org')
    view.loadFinished.connect(br.print_load_finished)
    view.loadProgress.connect(br.print_percent)
    view.load(url)
    view.show()
    app.exec_()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:10:44+00:00Added an answer on June 14, 2026 at 8:10 am

    You need to call print_html method e.g.

     def print_load_finished(self):
            print 'Load Finished'
            self.print_html()
    

    note () at the end of print_html

    BUT then it still won’t work anyway as your print_html doesn’t have access to view, you can pass view to it, but it not a right way to do Object oriented programming. You should be deriving Browser from may be QWebView and bind to events in __init__, so it should be something like this

    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4.QtWebKit import *
    import sys
    
    class Browser(QWebView):
        def __init__(self):
            super(Browser, self).__init__()
            self.loadFinished.connect(self.print_load_finished)
            self.loadProgress.connect(self.print_percent)
    
        def print_percent(self, percent):
            print percent
    
        def print_load_finished(self):
            print 'Load Finished'
            self.print_html()
    
        def print_html(self):
            frame = self.page().mainFrame()
            print unicode(frame.toHtml()).encode('utf-8')
    
    if __name__=='__main__':
        app = QApplication(sys.argv)
        br = Browser()
        url = QUrl('http://python.org')
        br.load(url)
        br.show()
        app.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.