当前位置: 首页>>代码示例>>Python>>正文


Python DB.messages方法代码示例

本文整理汇总了Python中lib.db.DB.messages方法的典型用法代码示例。如果您正苦于以下问题:Python DB.messages方法的具体用法?Python DB.messages怎么用?Python DB.messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.db.DB的用法示例。


在下文中一共展示了DB.messages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HistoryWindow

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import messages [as 别名]
class HistoryWindow(gui.HistoryWindow):
    '''
    classdocs
    '''


    def __init__(self, parent, default_name=None):
        '''
        Constructor
        '''
        gui.HistoryWindow.__init__(self, parent)

        log.trace("Starting up a history panel")
        self.db = DB()
        self.config = Config.get_config()

        self.order = const.ASC
        
        self.update_data(default_name)

#        self.imgList = wx.ImageList(16, 16)
#        self.img_up = self.imgList.Add(wx.Bitmap("images/go-up.png", wx.BITMAP_TYPE_PNG))
#        self.img_down = self.imgList.Add(wx.Bitmap("images/go-down.png", wx.BITMAP_TYPE_PNG))
#        self.lstRuns.SetImageList(self.imgList, wx.IMAGE_LIST_SMALL)

        icon = wx.Icon(os.path.join(const.PixmapDir, "storage.png"), wx.BITMAP_TYPE_ANY)
        self.SetIcon(icon)

#        listmix.ColumnSorterMixin.__init__(self, 7)
#        self.Bind(wx.EVT_LIST_COL_CLICK, self.onColClick, self.lstRuns)

#        self.SortListItems(2, 1)

        #    Ensure the right page is showing
        self.nb_history.SetSelection(0)
        self.Show()


    def update_data(self, default_name = None):
        all = _("***All Backups***")
        if default_name:
            old_sel = default_name
        else:
            old_sel = self.cboBackup.GetStringSelection()
        if not old_sel:
            old_sel = all
        self.cboBackup.Clear()
        self.cboBackup.AppendItems([all])
        self.cboBackup.AppendItems(self.config.backups.keys())
        self.cboBackup.SetStringSelection(old_sel)

        self.update_runs()
        self.update_messages()

    def update_runs(self):
        if self.cboBackup.GetSelection() == 0:
            runs = self.db.runs()
        else:
            backup_name = self.cboBackup.GetStringSelection()
            runs = self.db.runs(backupname=backup_name)
            
        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

#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的lib.db.DB.messages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。