本文整理汇总了Python中lib.db.DB.backup_messages方法的典型用法代码示例。如果您正苦于以下问题:Python DB.backup_messages方法的具体用法?Python DB.backup_messages怎么用?Python DB.backup_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.db.DB
的用法示例。
在下文中一共展示了DB.backup_messages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryWindow
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import backup_messages [as 别名]
#.........这里部分代码省略.........
if self.order == const.ASC:
runs.sort(key=lambda x : x.start_time_str, reverse=False)
self.txtOrder.SetLabel("Order: Oldest First")
else:
runs.sort(key=lambda x : x.start_time_str, reverse=True)
self.txtOrder.SetLabel("Order: Newest First")
self.lstRuns.DeleteAllColumns()
self.lstRuns.DeleteAllItems()
self.lstRuns.InsertColumn(0, _("Name"), wx.LIST_FORMAT_LEFT)
self.lstRuns.InsertColumn(1, _("Type"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(2, _("Time"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(3, _("Status"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(4, _("Files"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(5, _("Folders"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(6, _("Size"), wx.LIST_FORMAT_CENTER)
self.itemDataMap = {}
idx = 0
for run in runs:
row = [run.name, run.type, run.start_time_str, run.status, str(run.nfiles), str(run.nfolders), utils.readable_form(run.size)]
self.lstRuns.Append(row)
self.lstRuns.SetItemData(idx, run.run_id)
self.itemDataMap[idx + 1] = row
idx = idx + 1
self.itemIndexMap = self.itemDataMap.keys()
self.lstRuns.SetColumnWidth(0, 100)
self.lstRuns.SetColumnWidth(1, 50)
self.lstRuns.SetColumnWidth(2, wx.LIST_AUTOSIZE)
self.lstRuns.SetColumnWidth(3, 80)
self.lstRuns.SetColumnWidth(4, 120)
self.lstRuns.SetColumnWidth(5, 100)
self.lstRuns.SetColumnWidth(6, wx.LIST_AUTOSIZE)
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetListCtrl(self):
return self.lstRuns
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetSortImages(self):
return (self.img_down, self.img_up)
def onColClick(self, event):
event.Skip()
def update_messages(self):
self.lstMessages.DeleteAllColumns()
self.lstMessages.DeleteAllItems()
self.lstMessages.InsertColumn(0, _("Time"))
self.lstMessages.InsertColumn(1, _("Message"))
if self.cboBackup.GetSelection() == 0:
messages = self.db.messages()
else:
backup_name = self.cboBackup.GetStringSelection()
messages = self.db.backup_messages(backup_name)
if self.order == const.ASC:
messages.sort(reverse=False, key=lambda msg: msg.time)
else:
messages.sort(reverse=True, key=lambda msg: msg.time)
for msg in messages:
item = (msg.time, msg.message)
self.lstMessages.Append(item)
self.lstMessages.SetColumnWidth(0, wx.LIST_AUTOSIZE)
self.lstMessages.SetColumnWidth(1, wx.LIST_AUTOSIZE)
def onBackup(self, event):
self.update_data()
def onRefresh(self, event):
self.update_data()
def onDetails(self, event):
# Get the selected item
sel = self.lstRuns.GetFirstSelected()
if sel == -1:
return
run_id = self.lstRuns.GetItemData(sel)
# Will raise an exception if no run
run = self.db.run_details(run_id)
RunDetailsWindow(self, run)
def onLeftDClick(self, event):
self.onDetails(event)
def onOrder(self, event):
if self.order == const.ASC:
self.order = const.DESC
else:
self.order = const.ASC
self.update_data()