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
[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

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