问题
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
回答1:
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 ?
来源:https://stackoverflow.com/questions/8587060/wxpython-text-alignment-does-not-work