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

resultCallback capability missing from runJavaScript function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.9
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:

      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

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

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              esuyb Angus Melville
            • Votes:
              4 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes