Question. Timer Callback

AlexanderMAlexanderM Posts: 129 ✭✭

Is there any option to register timer callback (like qt timers) ?

Let's say NO to Autodesk®Fabric®

Comments

  • jcgagnonjcgagnon Fabric Employee Posts: 95 Fabric Employee

    You mean, from KL? In KL, there is no such feature. Having a timer requires an external call from C++, either from a custom EDK extension that you build, or by modifying the canvas.py or Maya C++ plugin code. I agree however that having this can be valuable in various applications.

    OR: maybe you can play with the async KL construct, which executes an operator asynchronously (on a background thread), in combination with the "MicroSleepWait( microSecs )" util function from the Synchrnization extension. You should be able to build a timer with these. But of course, it can be relatively dangerous to have KL code execution kicking in at any moment, so you have to be very careful in adding various logical safeguards around this kind of things (potentially by putting states in Singleton etc).

    Jerome Couture-Gagnon

  • jcgagnonjcgagnon Fabric Employee Posts: 95 Fabric Employee
    edited March 14

    Re-reading youe post, the "async" solution is probably not what you want, since it would run on another thread, and you probably want something that runs from the "main" thread.

  • AlexanderMAlexanderM Posts: 129 ✭✭
    edited March 14

    For example, it needs to get intermediate result from c++ loop not as log, but as data to draw it in Canvas. Is there a quick way to do it, like some EDK function?

    Let's say NO to Autodesk®Fabric®

  • jcgagnonjcgagnon Fabric Employee Posts: 95 Fabric Employee

    I think that this would need you to modify the Canvas app so it requests a redraw (get the OGL viewport widget and call update() on it) from a timer. I don't know if that is feasible by only modifying the Python app files, hopefully it is. But I can't go into more details since it would require more in depth investigations.

  • scaronscaron Posts: 163

    I have been hacking in some changes to the canvas.py lately and I believe calling methods on the viewport widget is doable in python. I recently accessed the viewport widget quickly (not the most robust way) by calling centralWidget() on the CanvasWindow...

    https://github.com/fabric-engine/FabricUI/blob/chagall/Python/canvas.py#L74

    mainWin = CanvasWindow(settings, unguarded, noopt) print(mainWin.centralWidget())

    from there you should be able to connect to signals and call methods.

Sign In or Register to comment.