Попробуйте это.
import wx
class UpperTextCtrl(wx.TextCtrl):
def __init__(self, *args, **kwargs):
super(UpperTextCtrl, self).__init__(*args, **kwargs)
self.Bind(wx.EVT_TEXT, self.on_text)
def on_text(self, event):
event.Skip()
selection = self.GetSelection()
value = self.GetValue().upper()
self.ChangeValue(value)
self.SetSelection(*selection)
class Frame(wx.Frame):
def __init__(self):
super(Frame, self).__init__(None, -1, 'Uppercase Text Control')
panel = wx.Panel(self, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
text = UpperTextCtrl(panel, -1, style=wx.TE_MULTILINE)
# change the font
font = text.GetFont()
font.SetPointSize(12)
text.SetFont(font)
sizer.Add(text, 1, wx.EXPAND|wx.ALL, 10)
panel.SetSizer(sizer)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = Frame()
frame.Show()
app.MainLoop()