I'm trying to write some Python code to talk to the Thorlabs APT ActiveX control. I'm basing my code on the code found on this page, but trying to use PyQt4 ActiveX container instead of the wxPython ActiveX container. It works for a very simple ActiveX methods, however, I get an error when trying to call a method that takes arguments.
This code works and shows the about box for 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)
When I replace self.AboutBox()
with a method with arguments e.g.:
num_units = c_int()
self.GetNumHWUnitsEx(21, byref(num_units))
I get an error: TypeError: unable to convert argument 1 of APTSystem.GetNumHWUnitsEx from 'CArgObject' to 'int&'
I presume the argument type needs to be a ctypes type. Is there some ctypes magic that can solve this?