[wxPython-users] adding control captions on gradient buttonpanel

Andrea Gavana andrea.gavana at gmail.com
Tue Dec 18 13:19:48 PST 2007


Hi,

On Dec 18, 2007 8:14 AM, C M wrote:
> I'd like to try to use a ButtonPanel with a gradient to hold some controls,
> but I also would like to have static text near the controls to indicate
> their function or caption them.  But if I just add a wxStaticTextCtrl to the
> ButtonPanel, the background color of the statictext is used and of course it
> doesn't look quite right on the gradient (you can see the edges of the
> rectangle).
>
> But with ButtonPanel, there is a main caption text, as well as button
> captions, and both of these are done in such a way as they do not produce
> this problem--they just sit nicely over the gradient.  I don't understand
> how this is done because I don't yet understand how DC and drawing works.
>
> I was wondering if there is or could be a way to allow placement of text on
> a gradient ButtonPanel so that it looks good with the gradient? (the
> positioning itself may require sizers, but one thing at a time).  And can
> font and font size also be specified?

The only way I can see it right now is to hack the ButtonPanel source
code... the problem is, whatever you do with a wx.StaticText, it does
not let the underlying "theme" (or gradient) shine through it, it uses
its own background colour or the one inherited by its parent (if it is
a solid one). Have you tried doing something like:

yourStaticText.Bind(wx.EVT_ERASE_BACKGROUND, self.OnErase)

def OnErase(self, event):

    pass

? I don't know if this will change anything. If it doesn't, then you
might consider hacking the wx.lib.stattext code to try to let the
gradient shine through. It would be an easy task to solve if someone
could answer to this question:

Is there a way to ask a wx.lib.stattext *not* to paint its rectangular
background but let the underground colour (parent
colour/theme/gradient) shine through?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/




More information about the wxpython-users mailing list