WxPython: text alignment not working

For some reason, wx.ALIGN_ * does not align anything on Ubuntu, but 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 this could be?

Update:. This has been tested 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 on Debian 6.0.3 using wxPython 2.8.12.1

Update 3:. All of the above have been tested using Python 2.6.

+1
source share
1 answer

I am testing this piece of code in Win 7, there is one error about using the argument: 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) 

Because you used two args keywords ("pos" and "size") before wx.ALIGN_CENTER, which is not the arg keyword. I think changing wx.ALIGN_CENTER to style = wx.ALIGN_CENTER can solve your problem?

0
source

Source: https://habr.com/ru/post/904447/


All Articles