ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxPython-users
wxPython-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved