简体   繁体   中英

wxPython: text alignment does not work

For some reasons the wx.ALIGN_* does not align anything on Ubuntu, while it works on Mac OS X:

self.static_text = wx.StaticText(self, -1, 'hello, world', pos=(0,0), 
                                 size=(300,30), style=wx.ALIGN_CENTER)

Any idea, what could it be?

Update: This was tried with wxPython 2.8.12.1 on Mac OS X 10.7.2. wxPython 2.8.11.0 on Ubuntu 11.10.

Update 2: Does not work either on Debian 6.0.3 with wxPython 2.8.12.1

Update 3: All of the above was tested with Python 2.6

I have test this code snippet in Win 7 environment, one error is surfaced about the argument usage: SyntaxError: non-keyword arg after keyword arg

self.static_text = wx.StaticText(self, -1, 'hello, world', pos=(0,0), size=(300,30), style = wx.ALIGN_CENTER)

Cause you have used two keyword args ("pos" and "size") in front of wx.ALIGN_CENTER, which is non-keyword arg. I guess that change wx.ALIGN_CENTER into style = wx.ALIGN_CENTER may solve your problem ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM