events without redraw

i want to have more fine control over panda rendering loop.
i want to process all events without delay but only re render screen when i need too. So i need it to act very much like a standard GUI application (i will just redraw the entire screen when i need to refresh small part of it)

this is what i got so far:

      taskMgr.remove("igLoop") # the render task
      while True:
            if self.redrawNow:
                base.graphicsEngine.renderFrame()
                self.redrawNow = False
            taskMgr.step()

the problem is that unless i actualy do a renderFrame every frame i cant get any events even though i do taskMgr.step() … its probably to late and i missed some thing but please help me


angelIDE :: when IDE’s conquer the GPU!

If you take a look in ShowBase.py you see how igLoop works:

self.taskMgr.add(self.__igLoop, 'igLoop', priority = 50)


    def __igLoop(self, state):
        # We render the watch variables for the onScreenDebug as soon
        # as we reasonably can before the renderFrame().
        onScreenDebug.render()

        if self.recorder:
            self.recorder.recordFrame()

        # Finally, render the frame.
        self.graphicsEngine.renderFrame()
        if self.clusterSyncFlag:
            self.graphicsEngine.syncFrame()
        if self.multiClientSleep:
            time.sleep(0)

        # We clear the text buffer for the onScreenDebug as soon
        # as we reasonably can after the renderFrame().
        onScreenDebug.clear()

        if self.recorder:
            self.recorder.playFrame()

        if self.mainWinMinimized:
            # If the main window is minimized, slow down the app a bit
            # by sleeping here in igLoop so we don't use all available
            # CPU needlessly.

            # Note: this isn't quite right if multiple windows are
            # open.  We should base this on whether *all* windows are
            # minimized, not just the main window.  But it will do for
            # now until someone complains.
            time.sleep(0.1)

        # Lerp stuff needs this event, and it must be generated in
        # C++, not in Python.
        throwNewFrame()
        return Task.cont

thank you pro-rsoft!

I just noticed, that igLoop is not the only loop defined in ShowBase:

        # __resetPrevTransform goes at the very beginning of the frame.
        self.taskMgr.add(
            self.__resetPrevTransform, 'resetPrevTransform', priority = -51)
        # give the dataLoop task a reasonably "early" priority,
        # so that it will get run before most tasks
        self.taskMgr.add(self.__dataLoop, 'dataLoop', priority = -50)
        # spawn the ivalLoop with a later priority, so that it will
        # run after most tasks, but before igLoop.
        self.taskMgr.add(self.__ivalLoop, 'ivalLoop', priority = 20)
        # make the collisionLoop task run before igLoop,
        # but leave enough room for the app to insert tasks
        # between collisionLoop and igLoop
        self.taskMgr.add(self.__collisionLoop, 'collisionLoop', priority = 30)
        # do the shadowCollisionLoop after the collisionLoop and
        # befor the igLoop:
        self.taskMgr.add(
            self.__shadowCollisionLoop, 'shadowCollisionLoop', priority = 45)
        # give the igLoop task a reasonably "late" priority,
        # so that it will get run after most tasks
        self.taskMgr.add(self.__igLoop, 'igLoop', priority = 50)
        # the audioLoop updates the positions of 3D sounds.
        # as such, it needs to run after the cull traversal in the igLoop.
        self.taskMgr.add(self.__audioLoop, 'audioLoop', priority = 60)

there is also an eventMgr, which is separate from taskMgr.

HTH

i know there is more taks but i dont turn them off. I still cant get it running. Any one have example suggestions?

You might try a different approach entirely. Use base.win.setActive(false) to turn off rendering. Then turn it back on briefly when you want to do a refresh.

I’m not sure what’s going on exactly, but this works too :
call this once :

base.startTk()

and then close the Tk window.
tkLoop must keep running.

Josh Yelon, your solution worked nicely

base.win.setActive(True)
        base.graphicsEngine.renderFrame()
        base.win.setActive(False)

:slight_smile:

ynjh_jo, well see i am using this app to expand my own panda gui library i dont think base.startTk() will help because its all rendered in panda window.

thanks all!