error drawing

Hi list,

maybe I’m blind or something but I don’t understand what happens, why are the “buttons” drawn differently?

Drawing happens around line 145, the rest is just copy paste of some code needed for the sample

Also, is there an official (and easy) way in wx to convert between RGB and HSB/HSV ?
I’ve seen something around wx.Image BUT it seams to be broken. I got a:

swig/python detected a memory leak of type ‘wxImage_HSVValue *’, no destructor found.

Thank you for your time.
Peter

P.S.
system: wxpython 2.8.4.0 on py 2.5.1 on winXP SP2

gc_error.py (5.34 KB)

Clipboard01.png

···


There is NO FATE, we are the creators.

Here's what it looks like under OS-X -- I think it's right.

Maybe that will help isolate the bug.

-Chris

gcTest.png

···

--
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@noaa.gov

Peter Damoc wrote:

Also, is there an official (and easy) way in wx to convert between RGB and HSB/HSV ?

Look in the colorsys.py module in Python's standard library.

I've seen something around wx.Image BUT it seams to be broken. I got a:

swig/python detected a memory leak of type 'wxImage_HSVValue *', no destructor found.

Thanks. It's a harmless warning, I'll get it fixed in the next release though. BTW, after I added the RGB/HSV conversions in wxImage a little profiling showed that it was faster to do the conversions with the colorsys module since it didn't have to make the round trip to C++.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks Chris,

I think I will go the wxGraphicsContext way :slight_smile:

Peter

···

On 8/29/07, Chris Mellon <arkanes@gmail.com > wrote:

On 8/29/07, Peter Damoc <pdamoc@gmail.com > > wrote:

Hi list,

maybe I’m blind or something but I don’t understand what happens, why are
the “buttons” drawn differently?

Drawing happens around line 145, the rest is just copy paste of some code

needed for the sample

Also, is there an official (and easy) way in wx to convert between RGB and
HSB/HSV ?
I’ve seen something around wx.Image BUT it seams to be broken. I got a:

swig/python detected a memory leak of type ‘wxImage_HSVValue *’, no
destructor found.

Thank you for your time.
Peter

P.S.
system: wxpython
2.8.4.0
on py 2.5.1 on winXP SP2

There is NO FATE, we are the creators.

Looks like a bug in the gradient fill - theres a white line at the
bottom. It could be in the wxGCDC wrapper, in wxGraphicsContext, or in

GDI+. Initial suspicion falls on wxGCDC.

It’s being complicated by the drawing of the border - it’s there on
the first one but anti-aliasing of the border fuzzes it out. If you
comment out the border drawing or draw the border before the contents

you can see that.

I found that fiddling with the exact size of the rect would mask the
artifact better. It’s still there - if you blow it way up with
SetUserScale you can see it - but it’s invisible at the regular size.

Here’s the relevant bit of OnPaint that works for me (but it might not
work in the general case - I suspect the artifact is caused by
floating point rounding):

        rect = wx.Rect(x,y,w,h)

gc.SetPen(self.border_pen)
rect.Deflate(1,1)
gc.GradientFillLinear(rect, HSBtoRGB(“0.0.100”),
HSBtoRGB(“0.0.70”), wx.SOUTH)
rect.Inflate(1,1)

gc.DrawRoundedRectangleRect(rect,2)

If possible, I’d suggest using wxGraphicsContext directly for this -
you can create a gradient brush and fill the stroked rectangle. It’s
less code and the brush fills up the rounded corners all the way,

unlike the rectangular based wxDC api.

here’s the OnPaint using wxGC (panel background excluded for clarity):

def OnPaint(self, evt):
    wx.PaintDC(self)
    gc = wx.GraphicsContext_Create

(self)
for button in self.buttons:
w, h = 50, 25
x, y = 50+60*self.buttons.index(button), (48-h)/2
brush = gc.CreateLinearGradientBrush(
x,y,x,y+h,HSBtoRGB("
0.0.100"), HSBtoRGB(“0.0.70”)
)
gc.SetBrush(brush)
gc.SetPen(self.border_pen)
gc.DrawRoundedRectangle(x,y,w,h,2)


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org


There is NO FATE, we are the creators.