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

  • SEARCH
  • Home
  • 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 6072053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:07:02+00:00 2026-05-23T10:07:02+00:00

I am planning to use PyQt to control an embedded WebKit browser on the

  • 0

I am planning to use PyQt to control an embedded WebKit browser on the server side.

I have some inherit application logic in Javascript in the HTML page running inside WebKit.

How could I communicate from the host process (Python, PyQt) with Javascript, so that

  • I can call Javascript functions inside the page

  • Python methods are exposed to Javascript and can be called from the Javascript, with arguments

  • 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-05-23T10:07:03+00:00Added an answer on May 23, 2026 at 10:07 am

    The following source code should be helpful:

    import sys
    from PyQt4.QtCore import QObject, pyqtSlot
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView
    
    html = """
    <html>
    <body>
        <h1>Hello!</h1><br>
        <h2><a href="#" onclick="printer.text('Message from QWebView')">QObject Test</a></h2>
        <h2><a href="#" onclick="alert('Javascript works!')">JS test</a></h2>
    </body>
    </html>
    """
    
    class ConsolePrinter(QObject):
        def __init__(self, parent=None):
            super(ConsolePrinter, self).__init__(parent)
    
        @pyqtSlot(str)
        def text(self, message):
            print message
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        view = QWebView()
        frame = view.page().mainFrame()
        printer = ConsolePrinter()
        view.setHtml(html)
        frame.addToJavaScriptWindowObject('printer', printer)
        frame.evaluateJavaScript("alert('Hello');")
        frame.evaluateJavaScript("printer.text('Goooooooooo!');")
        view.show()
        app.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am planning to use SCTP for a embedded Linux project. Anybody has some
I am planning to use coverflow control in my Silverlight application, but I am
I am planning to use jQuery in my new website. I have some questions
I am planning to use php in an embedded environment. Our current web server
I have a very data-centric application, written in Python / PyQt. I'm planning to
I am planning to use EJBContext to pass some properties around from the application
Am planning to use cookies to communicate between two browser windows. Am wondering if
I was planning to use url routing for a Web Forms application. But, after
We're planning to use standard ASP.NET user authentication for our application. However, by default
I am planning to use serialization to do clone. I have to make my

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.