我正在尝试编写一些Python代码来与thorlabsapt ActiveX控件对话。我的代码基于找到的代码on this page,但尝试使用pyqt4activex容器而不是wxpythonactivex容器。它适用于一个非常简单的ActiveX方法,但是,当我试图调用一个带参数的方法时,我得到了一个错误。在
此代码工作并显示Thorlabs APT的“关于”框:
import sys
from ctypes import *
from PyQt4 import QtGui
from PyQt4 import QAxContainer
class APTSystem(QAxContainer.QAxWidget):
def __init__(self, parent):
self.parent = parent
super(APTSystem, self).__init__()
self.setControl('{B74DB4BA-8C1E-4570-906E-FF65698D632E}')
# calling this method works
self.AboutBox()
app = QtGui.QApplication(sys.argv)
a = APTSystem(app)
当我将self.AboutBox()
替换为带有参数的方法时,例如:
我得到一个错误:TypeError: unable to convert argument 1 of APTSystem.GetNumHWUnitsEx from 'CArgObject' to 'int&'
我假定参数类型需要是ctypes类型。有没有一些ctypes魔法可以解决这个问题?在
结果我把语法搞错了,通过使用
generateDocumentation()
函数as mentioned here和一些参数helpfrom here来解决它。工作代码如下:args
列表中的第二项包含正确的值,但是num
永远不会被调用更新。在相关问题 更多 >
编程相关推荐