Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling python functions from dynamically created objects #68

Open
MRZA-MRZA opened this issue May 22, 2016 · 0 comments
Open

Calling python functions from dynamically created objects #68

MRZA-MRZA opened this issue May 22, 2016 · 0 comments

Comments

@MRZA-MRZA
Copy link

I have QML files File1.qml, File2.qml and PythonStuff.qml.

In PythonStuff.qml I declare

Python{
    id: python
    //functions, handlers, etc
}

I can call functions in FileN.qml by adding

PythonStuff{
   id: pythonStuff
}

to them and everything works perfectly.

But I need to create objects dynamically and call functions from PythonStuff.qml from them.
I create objects using CreateObject.js

var createdPages = []; 

function createPageObjects(jid){
    var component;
    var page;
    component = Qt.createComponent("DynPage.qml");
    page = component.createObject("dynPage", {"header": header});

    if(page == null){
        console.log("Error creating DynPage object");
    }
    return page
}�

I also have

PythonStuff{
   id: pythonStuff
}

in DynPage.qml to be able to call functions from PythonStuff.qml
It works, but when I call any function from any of FileN.qml or dynamically created objects, functions in my python script executes (1+number of created objects) times!
If I have

function disconnect(){
    console.log("disconnect()")
    call("pythonsript.con.disconnect", [], function(){})
}�

in PythonStuff.qml
and

def disconnect(self):
    pyotherside.send("log", "disconnected")�

in pythonscript.py
I have "disconnected()" message printed once and "disconnected" printed (1+number of created objects) time.
Is it some kind of flaw in pyotherside or I just do it incorrectly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant