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

QAxWidget.dynamicCall has unexpected behavior if arguments are passed as list type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.15.1
    • Documentation, PySide
    • None
    • Windows 10 64bit
      Anaconda3 Python 3.8.3 64bit
      PySide2 5.15.1
      PyQt5 5.15.1
    • Windows
    • 27aa24e589ca293298f88f3fd0d027d9f95dedc5 (pyside/pyside-setup/dev) 90c19c81fa9de2bc300ef4692b820dbccee6f428 (pyside/pyside-setup/5.15)

    Description

      I cannot find a way to invoke this overloaded case of dynamicCall, with list type argument:
      https://doc.qt.io/qt-5/qaxbase.html#dynamicCall-1

      Besides, no api docs available on QtAxContainer, about how to use dynamicCall, possibly with the new flags argument:
      https://doc.qt.io/qtforpython/modules.html

      Below is a script that I used for testing Pyside2's behavior:
      PyQt5 worked as expected on case 2, while PySide2 does not...

      import os
      import sys
      
      if False:
          from PyQt5.QtWidgets import QApplication
          from PyQt5.QAxContainer import QAxWidget
      else:
          import PySide2
      
          # fix for the case that anaconda qt 5.9.7 is in PATH
          if hasattr(PySide2, '__file__') and 'QT_QPA_PLATFORM_PLUGIN_PATH' not in os.environ:
              qt_qpa_platform_plugin_path = os.path.join(os.path.dirname(PySide2.__file__), 'plugins', 'platforms')
              os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = qt_qpa_platform_plugin_path
      
          from PySide2.QtWidgets import QApplication
          from PySide2.QtAxContainer import QAxWidget
      
      app = QApplication(sys.argv)
      excel = QAxWidget('Excel.Application')
      
      excel.setProperty('Visible', True)
      workbooks = excel.querySubObject('WorkBooks')
      workbooks.dynamicCall('Add')
      workbook = excel.querySubObject('ActiveWorkBook')
      
      help(QAxWidget.dynamicCall) # PySide2 gives:
      """
      Help on method_descriptor:
      
      dynamicCall(...)
          dynamicCall(self, name: bytes, v1: typing.Any = Invalid(typing.Any), v2: typing.Any = Invalid(typing.Any), v3: typing.Any = Invalid(typing.Any), v4: typing.Any = Invalid(typing.Any), v5: typing.Any = Invalid(typing.Any), v6: typing.Any = Invalid(typing.Any), v7: typing.Any = Invalid(typing.Any), v8: typing.Any = Invalid(typing.Any)) -> typing.Any
          dynamicCall(self, name: bytes, vars: typing.Sequence[typing.Any]) -> typing.Any
          dynamicCall(self, name: bytes, vars: typing.Sequence[typing.Any], flags: int) -> typing.Any
      """
      
      # check method usage: https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.saveas
      sig = 'SaveAs(QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant)'
      args = [
          os.path.join(os.getcwd(), 'filename.xlsx'),
          51,
          '',
          '',
          False,
          False,
          1,
          2,
          False,
          False,
          False,
          False,
      ]
      flags = 0 # just setting to 0 since I have no idea
      
      # 1) too many arguments error, due to: https://doc.qt.io/qt-5/qaxbase.html#dynamicCall
      # workbook.dynamicCall(sig, *args)
      
      # 2) unexpected behavior, works as if it was:
      #
      # for arg in args:
      #     workbook.dynamicCall(sig, arg)
      #
      # but expected to behave like: https://doc.qt.io/qt-5/qaxbase.html#dynamicCall-1
      workbook.dynamicCall(sig, args)
      
      # 3) similar behavior like previous case:
      #
      # for arg in args:
      #     workbook.dynamicCall(sig, arg, flags)
      #
      # also cannot find documentation on how to properly set flags???
      workbook.dynamicCall(sig, args, flags)
      
      

      Attachments

        1. pyside1410_diag.diff
          2 kB
        2. pyside1410_log.txt
          2 kB
        3. pyside1410.py
          2 kB

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              elbakramer Yunseong Hwang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes