コード例 #1
0
ファイル: util.py プロジェクト: Luojiahong/psysmon
def _pydate2wxdate(date):
    if date is None:
        return None

    assert isinstance(date, UTCDateTime)
    tt = date.timetuple()
    dmy = (tt[2], tt[1] - 1, tt[0])
    return DateTimeFromDMY(*dmy)
コード例 #2
0
    def Flip(self, delta):
        dates = self.dates
        date  = self.date

        try:
            foundIndex = dates.index(date) + delta
        except ValueError:
            alldates = [DateTimeFromDMY(1, 1, 1900)] + dates + [DateTimeFromDMY(20, 10, 3000)]
            foundIndex = len(dates) - 1
            for i in xrange(1, len(alldates)):
                if date.IsStrictlyBetween(alldates[i-1], alldates[i]):
                    foundIndex = i-2 if delta < 0 else i
                    break

        foundIndex = max(0, min(len(dates) - 1, foundIndex))

        self.cal.SetDate(dates[foundIndex])
        self.OnCalChange()
コード例 #3
0
def GetDates(logdir):
    dates = []
    append = dates.append

    for logfile in logdir.files():
        datestring = logfile.name

        try:
            y, m, d = datestring[:datestring.rfind('.')].split('-')
            y, m, d = int(y), int(m)-1, int(d)
        except Exception:
            pass # ignore non-logfiles...
        else:
            append(DateTimeFromDMY(d, m, y))

    return sorted(dates)
コード例 #4
0
        def OnAcct(*a):
            '''
            Handle selection of a new account from the Account drop down
            '''
            if self.GroupChatsSelected():
                from collections import defaultdict
                self.groupchats = defaultdict(list)
                for g in GetGroupChats():
                    d = g['time']
                    key = DateTimeFromDMY(d.day, d.month-1, d.year)
                    self.groupchats[key].append(g)

                #dates = sorted((g['date'], g) for g in
                self.dates = sorted(self.groupchats.keys())
                UpdateCal()
                self.buddies_panel.SetTitle(_('Chats'))
            else:
                buddylist.SetList(GetBuddies(acctcombo.Value.id), BuddyRenderer())
                OnBuddy()
                self.buddies_panel.SetTitle(_('Buddy'))
コード例 #5
0
    def OnButton(self, evt):
        self.pop = CalendarPopup(self)
        txtValue = self.GetValue()
        dmy = txtValue.split('.')
        didSet = False
        if len(dmy) == 3:
            d = int(dmy[0])
            m = int(dmy[1]) - 1
            y = int(dmy[2])
            if d > 0 and d < 31:
                if m >= 0 and m < 12:
                    if y > 1000:
                        self.pop.cal.SetDate(DateTimeFromDMY(d, m, y))
                        didSet = True
        if not didSet:
            self.pop.cal.SetDate(DateTime_Today())

        pos = self.ClientToScreen((0, 0))
        display_size = wx.GetDisplaySize()
        popup_size = self.pop.GetSize()
        control_size = self.GetSize()

        pos.x -= (popup_size.x - control_size.x) / 2
        if pos.x + popup_size.x > display_size.x:
            pos.x = display_size.x - popup_size.x
        if pos.x < 0:
            pos.x = 0

        pos.y += control_size.height
        if pos.y + popup_size.y > display_size.y:
            pos.y = display_size.y - popup_size.y
        if pos.y < 0:
            pos.y = 0
        self.pop.MoveXY(pos.x, pos.y)
        wx.calendar.EVT_CALENDAR_DAY(self, self.pop.cal.GetId(),
                                     self.OnCalSelected)
        self.pop.Popup()