[wxPython-users] Question re right-aligned text control
by Frank Millman other posts by this author
Apr 15 2003 3:16PM messages near this date
[wxPython-users] Re: wxGlade and Events. HOW?!
|
Re: [wxPython-users] Question re right-aligned text control
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? Is there any workaround?
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 !
If this problem will disappear when we move to GTK 2, I don't mind waiting a
few weeks.
Any assistance will be much appreciated.
Frank Millman
---------------------------------------------------------------------
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
|