[RESOLVED] Problem with DirectWIdgtes update

Hi Panda People!!!

Long time since I didn"t post any question here. This time I’ve been using DirectWidgets to add some GUI.
It works great but now I have some update problem. I want to display 1 DirectLabel and below it, a DirectWaitBar. They appear and I can update them in an outside test (nt that hard you’ll say).

Now I put it in my software and just after I draw them, I launch a heavy function which save lots of data in a file and can take up to 5 minutes.

My first problem was that my Widgets appeared only after this function ended. I hacked this with a

taskMgr.doMethodLater(0.5, myFunc)

to try and it worked.
But now the problem is that my heavy function changes the value of the WaitBar during its use but the Widgets" drawing won’t update until my function ends (so my bar’s value goes directly from 0 to 100). So it’s the same problem, my hack just delayed it.

I think that, during my function, I kinda freeze the PandaLoop so I understand that the Widgets don’t update.
So I’d like to force their drawing to refresh but I didn’t find anything for now. Does anyone have an idea? It it possible to refresh them, or the apesct2d or force a full frame refresh?

Thanks for your help.


This will render a frame immediately. Call it from time to time during your update function.

The other possibility is to yield your update function from time to time, for instance with a generator. There is a thread on this forum to integrate yield with the task manager. It will also be automatically integrated in future releases of Panda.


Thanks for the tips, I didn’t think about this.

But now I tried it and I can tell it doesn’t work, at least not for the DirectWidgets reparented to the aspect2d.
Are you sure this function doesn’t render only “render” and its children ?

For the yield solution, I will check. At first sight I’m not sure it will fit to what I want/need but I’m gonna test it today.

I assure you that it does work; we use that trick in our own loading bar code. Note that each call to renderFrame() will make visible the previous frame’s data. If it’s not updating at all, even after multiple calls, there may be something else that’s misleading you.


While testing more, I found something that ashamed me: when I tested the renderFrame, I put it at a wrong place … :blush:
So your solution was the one.
Thanks again.


Okay so now I saw it works, It is working in my software but I have some performances problems.
Without the WaitBar, my task takes 7 seconds, but with the bar and the updateFrame call, it takes 12 seconds (and to have this result, I hide render).

I think it comes from the large number of updateFrame calls but I thought that with render detached, I’d only loose a 1 or 2 seconds.

Do you know any trick to avoid this problem ? (except for the solution “decrease your calls number” that I’m currently digging)

Either decrease the number of calls to renderFrame(), or decrease the scene complexity while you do it (for instance, put up a splash screen on render2d, and hide render). Or both.


Hi and sorry for the long time since my last answer.

I decreased the number of calls and now it is much better. (profiling says 10% instead of the 60% I spent updating the bar before:-p).
I have the render hidden but not yet a splash on render2d
I have a label on aspect2d has some alpha that I gonne remove but I was wondering : will putting a splash on render2D or a plain label (or splash) on apsect2d have the same effect?


Um, yes? Not entirely sure what you’re asking. Why don’t you try it and see?


Is there any config variable to turn off this behavior? What would I lose if renderFrame would immediately make the frame data visible?
I ask this because in my opencvtexture+artoolkit application, the image always lags one frame behind.

Yes. You can config:

auto-flip 1

which will make renderFrame() flip at the end of its call instead of at the beginning, eliminating this one-frame latency. It may also reduce your frame rate a bit, depending on your scene and your hardware, because it eliminates the possibility of parallelism between your CPU and your GPU.