Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx
- # Test wx.TextCtrl for preexisting textctrl.value limit.
- # 2011-Sep-09
- # used tab char not 4 spaces
- class Frame(wx.Frame):
- def __init__(self, parent=None, inc=100, *args, **kwargs):
- super(Frame,self).__init__(parent, *args, **kwargs)
- self.tc = wx.TextCtrl(self, style=wx.TE_MULTILINE)
- #tc.Bind(wx.EVT_COMMAND_TEXT_MAXLEN, self.OnHitMax)
- self.tc.Bind(wx.EVT_TEXT_MAXLEN, self.OnHitMax)
- self.Bind(wx.EVT_CLOSE, self.OnClose)
- self.Bind(wx.EVT_IDLE, self.OnIdle)
- self.text = '123456789 ' * inc
- #self.text = '123456789 ' * 10000
- self.appendMore = True
- self.Show()
- def OnHitMax(self, event):
- print( 'Length: %d' % len(self.tc.GetValue()))
- self.appendMore = False
- event.Skip()
- def OnIdle(self, event):
- print( 'Length: %d' % len(self.tc.GetValue()))
- if self.appendMore:
- self.tc.AppendText(self.text)
- event.Skip()
- def OnClose(self, event):
- self.Destroy()
- print('\n')
- print('Look what happens at 30000 and 62000')
- print('To speed it up wiggle mouse over window.')
- print('Note that on Windows Xp Pro SP3 32bit idle event happens once a sec.')
- print("Tested on wxPython '2.8.11.0 (msw-unicode)'")
- print('Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32')
- print('\n')
- app = wx.App(0)
- frame = Frame(None, 100, title='Test wx.TextCtrl maxium limit')
- app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement