Exemplo n.º 1
0
    def add_service_dialog(self):
        dia = wx.Dialog(self, wx.ID_ANY, u'添加服务')

        sizer = wx.BoxSizer(wx.VERTICAL)

        bsizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(bsizer, 0, wx.ALL, 5)

        autil.new_inputctl(dia,
                           bsizer,
                           [[u'名称', (80, 25)],
                            {'type': 'entry',
                             'key': 'name',
                             'size': (100, 25)}])
        autil.new_inputctl(dia,
                           bsizer,
                           [[u'服务类型', (80, 25)],
                            {'type': 'select',
                             'key': 'type',
                             'size': (300, 25)}])
        for (k, v) in autil.yuns.items():
            dia.type.Append(v['name'], k)

        butsizer = dia.CreateButtonSizer(wx.OK | wx.CANCEL)
        sizer.AddSizer(butsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)

        dia.SetSizer(sizer)
        sizer.Fit(dia)
        sizer.SetSizeHints(dia)

        if dia.ShowModal() == wx.ID_OK:
            cid = dia.type.GetSelection()
            key = dia.type.GetClientData(cid)
            addservice(dia.name.GetValue(), key)
            self.__refresh(True)
Exemplo n.º 2
0
    def upload_dialog(self):
        if 'prep' not in self.__dict__:
            wx.MessageBox(u'请先选择服务', u'错误',
                          wx.ICON_ERROR)
            return

        dia = wx.Dialog(self, wx.ID_ANY, u'上传文件……')
        sizer = wx.BoxSizer(wx.VERTICAL)

        bsizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(bsizer, 0, wx.ALL, 5)

        autil.new_inputctl(dia, bsizer,
                           [[u'服务', (40, 25)],
                            {'type': 'static',
                             'key': 'serv',
                             'size': (200, 25),
                             'default': self.prep['key']},
                            [u'上传路径', (80, 25)],
                            {'type': 'static',
                             'key': 'path',
                             'size': (400, 25),
                             'default': self.path.GetValue()}])

        dia.list = wx.ListCtrl(dia, wx.ID_ANY,
                               wx.DefaultPosition,
                               (720, 420),
                               wx.LC_REPORT)
        dia.list.InsertColumn(0, u'文件名', wx.LIST_FORMAT_LEFT, 300)
        dia.list.InsertColumn(1, u'大小', wx.LIST_FORMAT_LEFT, 120)
        dia.list.InsertColumn(2, u'路径', wx.LIST_FORMAT_LEFT, 280)
        imagelist = wx.ImageList(48, 48, 1)
        fileicon = wx.Icon(os.path.join(autil.ResDir, '48x48', 'file.png'),
                           wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(fileicon)
        foldericon = wx.Icon(os.path.join(autil.ResDir, '48x48', 'folder.png'),
                             wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(foldericon)
        dia.list.AssignImageList(imagelist, wx.IMAGE_LIST_SMALL)

        sizer.Add(dia.list)

        self.dialog = dia
        dia.file = {}

        butsizer = dia.CreateButtonSizer(wx.OK | wx.CANCEL)
        bfile = wx.Button(dia, wx.ID_ANY, u'追加文件')
        bfile.Bind(wx.EVT_BUTTON, self.uploadFileDialog)
        butsizer.Add(bfile)
        bfolder = wx.Button(dia, wx.ID_ANY, u'追加目录')
        bfolder.Bind(wx.EVT_BUTTON, self.uploadFolderDialog)
        butsizer.Add(bfolder)
        sizer.AddSizer(butsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)

        dia.SetSizer(sizer)
        sizer.Fit(dia)
        sizer.SetSizeHints(dia)

        if dia.ShowModal() == wx.ID_OK:
            self.upload(dia.file)
Exemplo n.º 3
0
    def _uiInit(self):
        sizer = wx.BoxSizer(wx.VERTICAL)

        autil.new_inputctl(self, sizer,
                           [[u'过滤', (80, 25)],
                            {'type': 'entry',
                             'key': '_pathfilter',
                             'size': (100, 25)},
                            [u'', (1, 25)],
                            {'type': 'checkbox',
                             'key': '_autoremove',
                             'label': u'自动清除完成任务',
                             'size': (200, 25)}])

        list = wx.ListCtrl(self,
                           wx.ID_ANY,
                           wx.DefaultPosition,
                           wx.DefaultSize,
                           wx.LC_REPORT)

        self._load_ui()

        k = self._column.keys()
        k.sort()
        for x in k[:-1]:   # Skip the taskid
            v = self._column[x]
            list.InsertColumn(int(x), v[0], wx.LIST_FORMAT_LEFT, v[1])

        self._autoremove.SetValue(self._autoremove_value)

        sizer.Add(list, 1, wx.EXPAND | wx.ALL, 0)

        imagelist = wx.ImageList(32, 32, 1)
        uploadicon = wx.Icon(os.path.join(
            autil.ResDir, '32x32', 'upload.png'), wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(uploadicon)
        downloadicon = wx.Icon(os.path.join(
            autil.ResDir, '32x32', 'download.png'), wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(downloadicon)
        list.AssignImageList(imagelist, wx.IMAGE_LIST_SMALL)

        self.SetSizer(sizer)
        sizer.Fit(self)
        sizer.SetSizeHints(self)

        self._list = list

        self._ui_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self._ui_refresh, self._ui_timer)
        self._ui_timer.Start(5000, False)

        self._pathfilter.Bind(wx.EVT_TEXT_ENTER, self._pathFiltered)
        self._autoremove.Bind(wx.EVT_CHECKBOX, self._autoremoveClicked)

        self._list.Bind(wx.EVT_LIST_COL_CLICK, self._sort_ui)
        self._list.Bind(wx.EVT_MOUSEWHEEL, self._scrollwheel_ui)
        self._list.Bind(wx.EVT_LIST_COL_END_DRAG, self._drag_ui)
        self._list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._ui_activated)
        self._list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self._ui_list_rightclick)
Exemplo n.º 4
0
    def addDialog(self, servname, remote, local=None, interval=None):
        dia = wx.Dialog(self, wx.ID_ANY, u'添加同步')
        sizer = wx.BoxSizer(wx.VERTICAL)
        bsizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(bsizer, 0, wx.ALL, 5)

        autil.new_inputctl(dia, bsizer,
                           [[u'名称', (100, 25)],
                            {'type': 'entry',
                             'key': 'name',
                             'size': (200, 25)}])
        autil.new_inputctl(dia, bsizer,
                           [[u'服务', (100, 25)],
                            {'type': 'static',
                             'key': 'serv',
                             'default': servname,
                             'size': (200, 25)}])

        autil.new_inputctl(dia, bsizer,
                           [[u'远程路径', (100, 25)],
                            {'type': 'static',
                             'key': 'remote',
                             'default': remote,
                             'size': (600, 25)}])
        autil.new_inputctl(dia, bsizer,
                           [[u'本地路径', (100, 25)],
                            {'type': 'dirpicker',
                             'key': 'local',
                             'size': (600, 25)}])
        autil.new_inputctl(dia, bsizer,
                           [[u'同步频率(分钟)', (200, 25)],
                            {'type': 'entry',
                             'key': 'interval',
                             'default': interval or '0',
                             'size': (200, 25)}])

        butsizer = dia.CreateButtonSizer(wx.OK | wx.CANCEL)
        sizer.AddSizer(butsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)

        dia.SetSizer(sizer)
        sizer.Fit(dia)
        sizer.SetSizeHints(dia)

        if dia.ShowModal() == wx.ID_OK:
            name = dia.name.GetValue()
            local = dia.local.GetPath()
            interval = dia.interval.GetValue()
            if len(name) == 0 or len(local) == 0:
                wx.MessageBox(u'错误', u'输入不完整', wx.ICON_ERROR)
                return

            self.add(name, servname,
                     remote, local,
                     int(interval))
Exemplo n.º 5
0
    def __init__(self, parent,
                 wid=wx.ID_ANY,
                 pos=wx.DefaultPosition, size=wx.DefaultSize,
                 style=wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_CHILDREN):
        wx.Panel.__init__(self, parent, wid, pos, size, style)
        sizer = wx.BoxSizer(wx.VERTICAL)
        serv = [x for x in autil.Config if x != '_']

        autil.new_inputctl(self, sizer,
                           [[u'服务', (80, 25)],
                            {'type': 'select',
                             'key': 'servname',
                             'size': (300, 25),
                             'selects': serv}])
        autil.new_inputctl(self, sizer,
                           [[u'当前路径', (80, 25)],
                            {'type': 'combobox',
                             'key': 'path',
                             'size': (400, 25)}])
        self.pathcombo = {}

        self._list = wx.ListCtrl(self, wx.ID_ANY,
                                 wx.DefaultPosition, wx.DefaultSize,
                                 wx.LC_REPORT)
        self._list.InsertColumn(0, u'文件名',
                                wx.LIST_FORMAT_LEFT, 400)
        self._list.InsertColumn(1, u'大小',
                                wx.LIST_FORMAT_LEFT, 100)
        self._list.InsertColumn(2, u'创建时间',
                                wx.LIST_FORMAT_LEFT, 200)
        self._sort_column = 0
        self._column = [False, False, False]

        imagelist = wx.ImageList(32, 32, True)
        fileicon = wx.Icon(os.path.join(autil.ResDir, '32x32',
                                        'file.png'),
                           wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(fileicon)
        foldericon = wx.Icon(os.path.join(autil.ResDir, '32x32',
                                          'folder.png'),
                             wx.BITMAP_TYPE_PNG)
        imagelist.AddIcon(foldericon)
        self._list.AssignImageList(imagelist, wx.IMAGE_LIST_SMALL)

        sizer.Add(self._list, True, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(sizer)
        sizer.Fit(self)
        sizer.SetSizeHints(self)

        self.servname.Bind(wx.EVT_CHOICE, self.changeService)
        self.path.Bind(wx.EVT_TEXT, self.changepath)
        self._list.Bind(wx.EVT_LIST_COL_CLICK, self._listSortCallback)
        self._list.Bind(wx.EVT_MOUSEWHEEL, self._listMouseWheel)
        self._list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._activated)
        self._list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self._listRightclick)

        self.itemDataMap = []

        if self.servname.GetCount() > 0:
            self.changeService()