[wxPython-users] Is this possible ?

Christopher Barker Chris.Barker at noaa.gov
Fri Dec 21 15:12:14 PST 2007


C M wrote:
>     Is there a way to draw some lines on the panel ?

> wxStaticLine?

good point. I"d tend to either use StaticText and StaticLIne, or bite 
the bullet and draw your text and everything else with DCs. Another 
option is to use a higher level widget, like RichText or FloatCanvas (or 
OGL?)

But, as for your code:

> def OnPaint(self, event):
>    event.Skip()

I think you wan to put the Skip() at the end of the method, though you 
probably don't need it at all.

>    dest = self.panel

something is odd here -- you're trying to write to a panel, when the 
Parent is Painted??? I think you want this in the Panel's Paint handler.

>    Size  = dest.GetClientSize()
>    self._Buffer = wx.EmptyBitmap ( *Size )
>    dc = wx.BufferedDC ( wx.ClientDC ( dest ), self._Buffer )

No need to create a buffer if you're going to create it empty on each 
Paint. See the wiki under DoubleBufferedDrawing.

>    dc.EndDrawing()
>    dest.Refresh()

You've just called Refresh(), which means -- "go repaint yourself" -- on 
a Panel you just drew something on -- that's going to clear what you 
just drew.

Take a look in the Wiki for the Drawing examples -- they should help you 
figure out what all these different DCs are for.

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list