Re: [wxPython-users] Question re right-aligned text control
by Robin Dunn other posts by this author
Apr 15 2003 9:26PM messages near this date
[wxPython-users] Question re right-aligned text control
|
[wxPython-users] A question on wxPython + PIL and a possible bug
Frank Millman wrote:
> Hi all,
>
> I am trying to use the right-aligned text control that was kindly
> contributed by Josu Oyanguren in one the earlier demos. It is a subclass of
> wxTextCtrl that traps an EVT_PAINT event, and then does the following -
>
> def OnPaint(self, event):
> dc = wxPaintDC(self)
> dc.SetFont(self.GetFont())
> dc.Clear()
> text = self.GetValue()
> textwidth, textheight = dc.GetTextExtent(text)
> dcwidth, dcheight = self.GetClientSizeTuple()
>
> y = (dcheight - textheight) / 2
> x = dcwidth - textwidth - 2
>
> dc.SetClippingRegion(0, 0, dcwidth, dcheight)
> dc.DrawText(text, x, y)
>
> Josu states that it only works on wxMSW, and he is correct. Under wxGTK, it
> seems that EVT_PAINT is never called from a text control. Does anyone know
> why?
In wxGTK many controls are not true windows but are just drawn directly
on their parent. I didn't think that wxTextCtrl was this way but it
could be.
> Is there any workaround?
Not that I know of, other than padding the value with leading spaces...
>
> I tried calling the routine from EVT_KILL_FOCUS, and I tried using
> wxClientDC instead of wxPaintDC. It half worked, but it cleared the entire
> panel and drew the text on the panel !
Yep, see above.
>
> If this problem will disappear when we move to GTK 2, I don't mind waiting a
> few weeks.
I think that the widget in GTK2 does support right-aligned text, but I
don't know if wxGTK2 is supporting it yet. Doesn't look like it is
doing anything with the wxTE_RIGHT style in the code. Enter a feature
request for it so it doesn't get lost.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Thread:
Eladio Ventura
Frank Millman
Chris Munchenberg
Eladio Ventura
Eladio Ventura
Robin Dunn
Chris Munchenberg
Eladio Ventura
Chris Munchenberg
Eladio Ventura
Eladio Ventura
Alberto Griggio
Frank Millman
Robin Dunn
|