I’m drawing a 3d function graph using .poly() something, and when I tried to draw a series, where consecutive graphs differ by slight change of the PoV, the old graph doesn’t vanish, actually don’t know how to do that.
There’s a lot of flicker, because the polygons (actually just 4-point) overlap, depending on the function. I wanted to pause drawing until all 160 of them are drawn, and found that I should use .Freeze() and .Thaw(). However, these don’t work, and the last discussion on these functions is 15+ years old.
This is way too little information. On what type of window are you drawing? Are you drawing in a wx.EVT_PAINT event handler? What platform, Python/wxPython version? What is “poly”? Do you mean DrawPolygon()?
It goes without saying that Freeze() and Thaw() work perfectly fine.
You should show us what you’re doing (in a small, runnable sample code), because as of now it’s completely unclear.
Um, yes, I see how what I wrote can be confusing, partly because I had two questions.
how to erase all drawing objects and start from a blank panel
how to postpone the drawing of all the 160 polygons until they’re all done, to avoid flicker.
I wrote .poly() because I wasn’t sure of the actual name in wx, I’m using dabo wrapper classes, but it’s only one call away from .DrawPolygon().
As for versions, 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1, python 3.10, Linux Mint 21.3 Cinnamon.
The relevant bit of code is like this
for i in range(self.dim-1):
for j in range(self.dim-1):
vr=self.niz[i,j][2]
rgb=(64, 220, 220) if vr > 0 else (32,110,110)
poly=self.drawPolygon([aTačke[i,j], aTačke[i+1,j], aTačke[i+1,j+1], aTačke[i,j+1]], fillColor=rgb, persist=False)
The object where this code resides is a panel.
Is there a way to just create the drawing objects, without them showing up immediately, and when they’re all instantiated, show them all at once? I tried by issuing self.Freeze() before this, and self.Thaw() after, to no effect.
If my memory serves there is an example of using Polygons in the dabo/ui/grid.py file. That said, I do not recall ever using DrawPolyon() (that is in pem_mixin.py).
BTW Dabo does not prevent you from using any of the wxPython classes directly in your code. Normally the difference in the call is only the case of the first letter of the class. Example self.freeze() would be wxPython and self.Freeze() would be Dabo.
Dabo does have self.Freeze and self.Thaw.
I didn’t know Dabo was still alive… good! That said, I know nothing about Dabo.
The code you posted does not shed any light. You haven’t said whether the drawing is done as a part of a wx.EVT_PAINT event handler or not. If it’s not, it should. You shouldn’t draw stuff on a window outside of a wx.EVT_PAINT handler.
200 objects is a tiny thing to draw for any machine I know of - beside possibly a Raspberry - and the drawing should be basically instantaneous.
Same applies for erasing: you erase stuff from a window by calling Refresh() (and sometimes Update()) on it, so that the window is cleared and stuff is redrawn.
Please see the wxPython demo: there’s plenty of material to show ho to handle drawing on a window.
I stopped using Dabo earlier this year. The project was not updated for many years but I was able to get it working with python 3.12.x. However, one of the original authors has taken up the project again (Ed Leaf). Ed has been making changes to Dabo.
The nice thing about Dabo was how easy it was to use a database. The authors followed the FoxPro example and that was very cool.
I never had need to create any sort of polygons for anything. But if I did - I think I would have used wxPython/Numpy to do the work.
I did exactly that, and more or less the only reason I inserted dabo here was to use some buttons that I subclassed from its dButton, and to reuse few other bits of code. And yes, I’m using dabo simply because I did 30 years of Foxpro :).
Now I’ll have to dive into moving my code into .paint() handler… see you around in a few days.