def CreatePanel(self): self.list = BetterListCtrl(self) self.list.InsertColumn(0, 'Name') self.list.InsertColumn(1, 'Up', wx.LIST_FORMAT_RIGHT) self.list.setResizeColumn(0) return self.list
class TopContributorsPanel(HomePanel): def __init__(self, parent): HomePanel.__init__(self, parent, 'Top Contributors' , LIST_BLUE) self.Layout() self.peerdb = PeerDBHandler.getInstance() self.barterdb = BarterCastDBHandler.getInstance() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self._onTimer, self.timer) self.timer.Start(10000, False) self.RefreshList() def CreatePanel(self): self.list = BetterListCtrl(self) self.list.InsertColumn(0, 'Name') self.list.InsertColumn(1, 'Up', wx.LIST_FORMAT_RIGHT) self.list.setResizeColumn(0) return self.list def _onTimer(self, event): if self.IsShownOnScreen(): self.RefreshList() def RefreshList(self): def db_callback(): topTen = self.barterdb.getTopNPeers(10) self._RefreshList(topTen) startWorker(None, db_callback, uId ="TopContributorsPanel_RefreshList") @forceWxThread def _RefreshList(self, topTen): self.list.Freeze() self.list.DeleteAllItems() for item in topTen['top']: name = self.peerdb.getPeer(item[0], 'name') if name: pos = self.list.InsertStringItem(sys.maxint, name) self.list.SetStringItem(pos, 1, self.guiutility.utility.size_format(item[1], 1)) self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) self.list.Layout() self.list.Thaw() def OnDoubleClick(self, event): pass
class TopContributorsPanel(HomePanel): def __init__(self, parent): HomePanel.__init__(self, parent, 'Top Contributors', LIST_BLUE) self.Layout() self.peerdb = PeerDBHandler.getInstance() self.barterdb = BarterCastDBHandler.getInstance() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self._onTimer, self.timer) self.timer.Start(10000, False) self.RefreshList() def CreatePanel(self): self.list = BetterListCtrl(self) self.list.InsertColumn(0, 'Name') self.list.InsertColumn(1, 'Up', wx.LIST_FORMAT_RIGHT) self.list.setResizeColumn(0) return self.list def _onTimer(self, event): if self.IsShownOnScreen(): self.RefreshList() def RefreshList(self): def db_callback(): topTen = self.barterdb.getTopNPeers(10) self._RefreshList(topTen) startWorker(None, db_callback, uId="TopContributorsPanel_RefreshList") @forceWxThread def _RefreshList(self, topTen): self.list.Freeze() self.list.DeleteAllItems() for item in topTen['top']: name = self.peerdb.getPeer(item[0], 'name') if name: pos = self.list.InsertStringItem(sys.maxint, name) self.list.SetStringItem( pos, 1, self.guiutility.utility.size_format(item[1], 1)) self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) self.list.Layout() self.list.Thaw() def OnDoubleClick(self, event): pass