aoloe / scribus-plugin-scripter

Development version of the new Scribus scripter
4 stars 4 forks source link

connect the c++/qt slots with a python function #7

Open aoloe opened 9 years ago

aoloe commented 9 years ago

in https://github.com/aoloe/scribus-plugin-scripter/blob/master/src/python/init_scripter.py#L98

Scripter.createMenu.connect(createMenu)

is strying to connect the c++ createMenu() slot with the python createMenu function.

since qt5 does not accept anymore connection made by passing a string, we have to correctly make the c++/qt slot available to python/pyqt.

in https://github.com/aoloe/scribus-plugin-scripter/blob/master/src/python/mikro.py#L391

for i in range(metaobject.methodCount()):
    meta_method = metaobject.method(i)

correctly sees the signal as a method, but i (we) could not yet find a way to make it available as a slot inside of pyqt.

any idea?

aoloe commented 9 years ago

mrb says: the scripter should probably request scribus create the menu item for you.. otherwise you will likely make a mess in the menus as Scribus does sometimes just rebuild them all on the fly to do retranslation or dynamic menus.. if the scripter tries to add them in, they will likely get wiped out at some point.

aoloe commented 8 years ago

ishitatsuyuki says on irc:

slot – the slot to connect to, either a Python callable or another bound signal.

Although PyQt5 allows any Python callable to be used as a slot when connecting signals, it is sometimes necessary to explicitly mark a Python method as being a Qt slot and to provide a C++ signature for it. PyQt5 provides thepyqtSlot() function decorator to do this.

http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html

aoloe commented 7 years ago

http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#connecting-slots-by-name ?

luzpaz commented 7 years ago

@QuLogic any possible help you can offer here ?

luzpaz commented 7 years ago

Qt tut on signals and slots https://nidomiro.de/2016/12/qt-signals-and-slots-how-they-work/