Centering wx.TextCtrl?

I'm having difficulty centering the text inside wx.TextCtrl (as shown in the image below). โ€œFor some reason, he always prints LEFT, not CENTERED.โ€

Illustration of desired output

Can someone tell me the right โ€œstylesโ€ or tell me what I'm doing wrong?

import wx class SimplePanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN) myTextCtrl = wx.TextCtrl(self, -1, style=wx.TE_CENTRE, size=(100, -1), pos=(10, 10)) if __name__ == '__main__': app = wx.App() frame = wx.Frame(None, -1, 'Simple Panel') myPanel = SimplePanel(frame, -1) frame.Show() app.MainLoop() 
+4
source share
2 answers

(Edited after clarification)

An error occurred in wxPython that broke TE_CENTRE for some OSs:

http://wxpython-users.1045709.n5.nabble.com/ANN-wxPython-2-8-9-1-td2367679.html

Try updating to the latest version.

+1
source

This works fine on Windows, but I used both OSX and Windows for development, and wx.TE_CENTRE does not seem to work on OSX. This was a bug reported many years ago ( http://trac.wxwidgets.org/ticket/10010 ).

+1
source

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


All Articles