TextCtrl borders

My last question of the day ;).

With deriving the draw calls on generic buttons, we've been able to
change the look and feel of the buttons in our application, drawing a
different border around each type of button, and using it for choice
boxes, etc.) which is fantastic. The textctrl's that we use, however,
are still the native wx.TextCtrl and I was wondering if it there is a
way to customize the border draw around a textctrl similar to the work
around a generic button. There's no such thing as a generic textctrl
is there?

I've read posts on this from 2005 about why this might not be
possible, but 5 years later, I'm wondering if there is a way to do
this :). Any help is appreciated! :slight_smile:

My last question of the day ;).

With deriving the draw calls on generic buttons, we've been able to
change the look and feel of the buttons in our application, drawing a
different border around each type of button, and using it for choice
boxes, etc.) which is fantastic. The textctrl's that we use, however,
are still the native wx.TextCtrl and I was wondering if it there is a
way to customize the border draw around a textctrl similar to the work
around a generic button. There's no such thing as a generic textctrl
is there?

No, but it wouldn't be a huge task to implement one, at least for single line text fields with no colors, word-wrap or vertical scrolling to deal with.

I've read posts on this from 2005 about why this might not be
possible, but 5 years later, I'm wondering if there is a way to do
this :). Any help is appreciated! :slight_smile:

There's one way to do it without making a custom textctrl that comes to mind. Use wx.BORDER_NONE on the textctrl, and place it on a small wx.PyPanel that is just a few pixels larger than the textctrl on all sides. Then you can handle the paint event for the panel and draw your border in the few pixels on all sides that are not covered by the text widget. I mention using wx.PyPanel so you can override things like DoGetBestSize and others that are typically done when creating a custom control class using wx.PyControl, but using a panel instead of a control will automatically handle tab traversal to and from the nested text widget as expected.

···

On 4/9/11 7:28 AM, srbshawker wrote:

--
Robin Dunn
Software Craftsman

Thanks Robin! The PyPanel alternative was easy and, although I'm sure
it isn't too challenging to build a simple TextCtrl, it seems a bit
daunting to get it all right to me and the NO_BORDER tc with the PAINT
event was the sort of solution I was hoping for. Works great :slight_smile: