daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Jan 21st, 2018 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from __future__ import print_function, unicode_literals
  2.  
  3. import wx
  4.  
  5. class MyListCtrl ( wx.ListCtrl ):
  6.     def OnGetItemText ( self, item, column ):
  7.         ar = []
  8.         for i in range ( 200000 ):
  9.             ar.append ( i )
  10.         return '{}'.format ( len ( ar ) )
  11.  
  12. class MyFrame ( wx.Frame ):
  13.     lc = None
  14.     timer = None
  15.  
  16.     def __init__ ( self, *args, **kwargs ):
  17.         super ( MyFrame, self ).__init__ ( *args, **kwargs )
  18.         self.timer = wx.Timer ( self )
  19.         self.lc = MyListCtrl ( self, style=wx.LC_VIRTUAL|wx.LC_REPORT )
  20.         self.lc.InsertColumn ( 0, 'Count1', width=75 )
  21.         self.lc.InsertColumn ( 1, 'Count2', width=75 )
  22.         self.lc.InsertColumn ( 2, 'Count3', width=75 )
  23.         self.lc.InsertColumn ( 3, 'Count4', width=75 )
  24.         self.lc.SetItemCount ( 1 )
  25.         self.Bind ( wx.EVT_TIMER, self.on_timer, self.timer )
  26.         self.Bind ( wx.EVT_CLOSE, self.on_close )
  27.         self.timer.Start ( 1000 )
  28.  
  29.     def on_timer ( self, event ):
  30.         self.lc.Refresh()
  31.  
  32.     def on_close ( self, event ):
  33.         self.timer.Stop()
  34.         event.Skip()
  35.  
  36. if __name__=='__main__':
  37.     app = wx.App ( False )
  38.     frame = MyFrame ( None )
  39.  
  40.     frame.Show()
  41.     app.MainLoop()
  42.    
  43. Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
  44. Type "help", "copyright", "credits" or "license" for more information.
  45. >>> import wx
  46. >>> wx.version()
  47. '3.0.2.0 msw (classic)'
  48.  
  49. Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
  50. Type "help", "copyright", "credits" or "license" for more information.
  51. >>> import wx
  52. >>> wx.version()
  53. '3.0.3.dev2680+55dda48 msw (phoenix)'
  54.    
  55. from __future__ import print_function, unicode_literals
  56.  
  57. import wx
  58.  
  59. class MyListCtrl ( wx.ListCtrl ):
  60.     def OnGetItemText ( self, item, column ):
  61.         ar = []
  62.         for i in range ( 200000 ):
  63.             ar.append ( i )
  64.         return '{}'.format ( len ( ar ) )
  65.  
  66. class MyFrame ( wx.Frame ):
  67.     lc = None
  68.     timer = None
  69.  
  70.     def __init__ ( self, *args, **kwargs ):
  71.         super ( MyFrame, self ).__init__ ( *args, **kwargs )
  72.         self.timer = wx.Timer ( self )
  73.  
  74.         self.panel = wx.Panel(self, -1)
  75.         self.panel.SetDoubleBuffered(True)
  76.  
  77.         self.lc = MyListCtrl ( self.panel, style=wx.LC_VIRTUAL|wx.LC_REPORT )
  78.         self.lc.InsertColumn ( 0, 'Count1', width=75 )
  79.         self.lc.InsertColumn ( 1, 'Count2', width=75 )
  80.         self.lc.InsertColumn ( 2, 'Count3', width=75 )
  81.         self.lc.InsertColumn ( 3, 'Count4', width=75 )
  82.         self.lc.SetItemCount ( 1 )
  83.         self.Bind ( wx.EVT_TIMER, self.on_timer, self.timer )
  84.         self.Bind ( wx.EVT_CLOSE, self.on_close )
  85.  
  86.         self.Show(True)
  87.         self.timer.Start ( 1000 )
  88.  
  89.     def on_timer ( self, event ):
  90.         self.Freeze()
  91.         self.lc.Refresh()
  92.         self.Thaw()
  93.  
  94.     def on_close ( self, event ):
  95.         self.timer.Stop()
  96.         event.Skip()
  97.  
  98. if __name__=='__main__':
  99.     app = wx.App ( False )
  100.     frame = MyFrame ( None )
  101.  
  102.     frame.Show()
  103.     app.MainLoop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top