[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Can't seem to send parameter by reference using PyQt
From:       Sam Myers <morefigs () gmail ! com>
Date:       2014-08-21 7:37:46
Message-ID: CADTxD1tsqi2VgsB=R2prpQRPaDm8CcSypchgRXE7uDu0EKF6bw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


It worked! Thanks, been trying every combo I could think of for two days!


On 21 August 2014 17:30, Phil Thompson <phil@riverbankcomputing.com> wrote:

> On 21/08/2014 1:50 am, Sam Myers wrote:
>
>> I'm having trouble sending a parameter by reference using dyncamicCall to
>> an ActiveX object. The command GetNumHWUnits should set the second
>> parameter to 2, but doesn't change it. The equivalent code works in
>> LabVIEW
>> so I'm reasonably confident in the command order. Any hints?
>>
>> import sys
>> from PyQt4 import QtGui
>> from PyQt4 import QAxContainer
>> from PyQt4.QtCore import QVariant
>> from PyQt4.QtGui import QMainWindow, QApplication
>>
>> class APTSystem(QMainWindow):
>>
>>     def __init__(self):
>>
>>         QMainWindow.__init__(self)
>>
>>         apt = QAxContainer.QAxWidget(self)
>>         self.setCentralWidget(apt)
>>
>>         apt.setControl('{B74DB4BA-8C1E-4570-906E-FF65698D632E}')   #
>> system
>>
>>         apt.dynamicCall('StartCtrl()')
>>
>>         typ = QVariant(6)
>>         num = QVariant(0)
>>
>>         apt.dynamicCall('GetNumHWUnits(int, int&)', [typ, num])
>>
>>         print num.toInt()   # value is always returned as zero, expecting
>> 2!
>>
>>         apt.dynamicCall('StopCtrl()')
>>
>> app = QtGui.QApplication(sys.argv)
>> a = APTSystem()
>> a.show()
>> app.exec_()
>>
>
> The list itself is modified, try...
>
> args = [typ, num]
> apt.dynamicCall('Get...', args)
> print args[1].toInt()
>
> Phil
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[Attachment #5 (text/html)]

<div dir="ltr">It worked! Thanks, been trying every combo I could think of for two \
days!</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 21 August \
2014 17:30, Phil Thompson <span dir="ltr">&lt;<a \
href="mailto:phil@riverbankcomputing.com" \
target="_blank">phil@riverbankcomputing.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 21/08/2014 1:50 am, \
Sam Myers wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> I&#39;m having trouble sending a \
parameter by reference using dyncamicCall to<br> an ActiveX object. The command \
GetNumHWUnits should set the second<br> parameter to 2, but doesn&#39;t change it. \
The equivalent code works in LabVIEW<br> so I&#39;m reasonably confident in the \
command order. Any hints?<br> <br>
import sys<br>
from PyQt4 import QtGui<br>
from PyQt4 import QAxContainer<br>
from PyQt4.QtCore import QVariant<br>
from PyQt4.QtGui import QMainWindow, QApplication<br>
<br>
class APTSystem(QMainWindow):<br>
<br>
      def __init__(self):<br>
<br>
            QMainWindow.__init__(self)<br>
<br>
            apt = QAxContainer.QAxWidget(self)<br>
            self.setCentralWidget(apt)<br>
<br>
            apt.setControl(&#39;{B74DB4BA-<u></u>8C1E-4570-906E-FF65698D632E}&#39;)   \
# system<br> <br>
            apt.dynamicCall(&#39;StartCtrl()&#39;)<br>
<br>
            typ = QVariant(6)<br>
            num = QVariant(0)<br>
<br>
            apt.dynamicCall(&#39;<u></u>GetNumHWUnits(int, int&amp;)&#39;, [typ, \
num])<br> <br>
            print num.toInt()     # value is always returned as zero, expecting \
2!<br> <br>
            apt.dynamicCall(&#39;StopCtrl()&#39;)<br>
<br>
app = QtGui.QApplication(sys.argv)<br>
a = APTSystem()<br>
a.show()<br>
app.exec_()<br>
</blockquote>
<br></div></div>
The list itself is modified, try...<br>
<br>
args = [typ, num]<br>
apt.dynamicCall(&#39;Get...&#39;, args)<br>
print args[1].toInt()<br>
<br>
Phil<br>
______________________________<u></u>_________________<br>
PyQt mailing list      <a href="mailto:PyQt@riverbankcomputing.com" \
target="_blank">PyQt@riverbankcomputing.com</a><br> <a \
href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" \
target="_blank">http://www.riverbankcomputing.<u></u>com/mailman/listinfo/pyqt</a></blockquote></div><br></div>



[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic