I have the following in my Python file:<br><br>import sys<br><br>from PyQt4.QtCore import QDateTime, QObject, QUrl, pyqtSignal<br>from PyQt4.QtGui import QApplication<br>from PyQt4.QtDeclarative import QDeclarativeView<br>
<br>#this class will emit success if photo is added to group<br>class updateGroup(QObject):<br>  <br>  now = pyqtSignal(int)<br>  <br>  def emit_now(self):<br>    number = 1<br>    self.now.emit(number)<br><br>app = QApplication(sys.argv)<br>
<br>update = updateGroup()<br><br>view = QDeclarativeView()<br>view.setSource(QUrl('flickrviews.qml'))<br>view.setResizeMode(QDeclarativeView.SizeRootObjectToView)<br><br>rootObject = view.rootObject()<br><br>rootObject.updateRequired.connect(update.emit_now) #sends signal<br>
<br>update.now.connect(rootObject.updateColor) #tells it which function in qml gets that signal<br><br>view.setGeometry(100, 100, 400, 240)<br>view.show()<br><br>app.exec_()<br><br>and the relevant parts in my QML file are:<br>
<br>signal updateRequired;<br>    <br>    function updateColor(number)<br>                {<br>                  if(number==1)<br>                  {<br>                    addtogroup.buttonColor="blue"<br>                  }<br>
                }<br><br>and later in the file:<br><br>   Button{<br>                id: addtogroup<br>                width: 200<br>                bLabel: "Add to Next Group"<br>                //onButtonClick: plasmoid.runCommand("/home/ermesa/bin/qml/plasmoids/flickrviews2/contents/ui/flickrhelpers/addtogroup.py", [photoID,nextphotogroup])<br>
                onButtonClick: updateRequired()<br>              }<br><br>Just curious about one thing:<br>1) With this framework I can get information from the python program to affect the QML (and change the button to a blue colour).  How do I get information to the python program?   In other words, if I have a python function that's function(int) -> how do I provide the int argument for the python FROM the QML?  <br>
<br>It's a little hard for me to figure out because this stuff is all indirect - in the QML the signal is referred to as if it were a function.  And the function gets the data from the signal, but it doesn't seem to make sense how that happens because there's no real link to it.  I kinda understand what I'm doing, but not enough to figure out how to get the into to python.<br>
<br>Thanks,<br clear="all">--<br>Eric Mesa<div><a href="http://about.me/ericmesa" target="_blank">http://about.me/ericmesa</a><br><a href="http://www.ericsbinaryworld.com" target="_blank">http://www.ericsbinaryworld.com</a></div>
<br>