wxPython: text alignment does not work

一曲冷凌霜 提交于 2020-01-05 08:45:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!