ogl.DrawnShape reshape problem

Stef Mientki s.mientki at ru.nl
Sun Sep 2 14:38:28 PDT 2007


hello,

I've derived a component from ogl.DrawnShape,
consisting of a circle and an arc,
so I get some kind of round speed meter.

In fact it stands for an electronic push-button with a LED inside,
and the intensity of the LED is indicated by the angle of the arc.

Now when the push button is pressed, by a mouse click,
I need some indication that it's pressed (it's released by the program 
after some virtual time).
To indicate that the button is pressed,
I redraw the  complete shape, but use a large penwidth for the circle,
this works well.
But when the button is released I've to redraw the circle with penwidth 1,
well this doesn't work,
and it seems that I get a penwidth of about half the large penwidth.

Any ideas ?
Below is the code, which is also use in the initialization section of my 
object,
and there it can draw with a penwidth of 1.

thanks,
Stef Mientki


  def _Redraw (self):
    if self.On:
      color_active = self.Color_On
      w = 7
    else:
      color_active = self.Color_Off
      w = -1

    dc = wx.ClientDC ( self.my_Container )
    self.my_Container.PrepareDC ( dc )

    r = self.Size[0] / 2
    self.shape.SetDrawnPen ( wx.Pen ( self.Color_On, width = w ) )
    self.shape.SetDrawnBrush ( wx.Brush ( self.Color_Off ) )
    self.shape.DrawEllipse ( ( -r, -r, 2*r, 2*r ) )
    self.shape.SetDrawnPen ( wx.Pen ( self.Color_On, width = w ) )

    circ = 2* pi * self.Value / 360
    rx =   r * sin ( circ )
    ry = - r * cos ( circ )
    self.shape.SetDrawnBrush ( wx.Brush ( self.Color_On ) )
    self.shape.DrawArc ( (0, 0), ( rx, ry ), (0, -r) )

    # Make sure to call CalculateSize when all drawing is done
    self.shape.CalculateSize()
    self.my_Container.Redraw ( dc )





More information about the wxpython-users mailing list