Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-643

resultCallback capability missing from runJavaScript function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • 6.7
    • 5.9
    • PySide

    Description

      The current PySide2 5.9 branch (5.9.0a1 - built on Windows via https://codereview.qt-project.org/pyside/pyside-setup on 20 April 2018) contains the QWebEnginePage.runJavaScript() function.

      This function works fine with a single argument containing a string of JavaScript code.  However, there is no ability to return a 'resultCallback' as in the original Qt function:
      https://doc.qt.io/qt-5.9/qwebenginepage.html#runJavaScript-2

      The following, for example:

      class Browser(QtWebEngineWidgets.QWebEngineView):
          def _init_(self, main, mainWin, centralWidget):
              super()._init_()

          def buttonPushed(self):
              self.page().runJavaScript('hello', self.printResult)

          def printResult(self, result):
             print(result)

      generates:
      TypeError: 'PySide2.QtWebEngineWidgets.QWebEnginePage.runJavaScript' called with wrong argument types:
        PySide2.QtWebEngineWidgets.QWebEnginePage.runJavaScript(str, method)
      Supported signatures:
        PySide2.QtWebEngineWidgets.QWebEnginePage.runJavaScript(unicode)
        PySide2.QtWebEngineWidgets.QWebEnginePage.runJavaScript(unicode, unsigned int)

      Are their plans to update this function to return callback results?

      (I am aware that it is possible to work around this by getting JavaScript to create a console message, which can then be filtered by overriding QWebEnginePage.consoleMessage.  But, it would be nice to be able to exploit the full capability of the original runJavaScript function.)

      Thanks.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              esuyb Angus Melville
              Votes:
              6 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes