]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import wx | |
3 | import wx.calendar | |
4 | ||
5 | #---------------------------------------------------------------------- | |
6 | ||
7 | class TestPanel(wx.Panel): | |
8 | def __init__(self, parent, ID, log): | |
9 | wx.Panel.__init__(self, parent, ID) | |
10 | self.log = log | |
11 | ||
12 | cal = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(), pos = (25,50), | |
13 | style = wx.calendar.CAL_SHOW_HOLIDAYS | |
14 | | wx.calendar.CAL_SUNDAY_FIRST | |
15 | | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION | |
16 | ) | |
17 | self.cal = cal | |
18 | self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId()) | |
19 | ||
20 | # Set up control to display a set of holidays: | |
21 | self.Bind(wx.calendar.EVT_CALENDAR_MONTH, self.OnChangeMonth, cal) | |
22 | self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around) | |
23 | self.OnChangeMonth() | |
24 | ||
25 | cal2 = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(), pos = (325,50)) | |
26 | ||
27 | ||
28 | def OnCalSelected(self, evt): | |
29 | self.log.write('OnCalSelected: %s\n' % evt.GetDate()) | |
30 | ||
31 | def OnChangeMonth(self, evt=None): | |
32 | cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12 | |
33 | for month, day in self.holidays: | |
34 | if month == cur_month: | |
35 | self.cal.SetHoliday(day) | |
36 | ||
37 | #---------------------------------------------------------------------- | |
38 | ||
39 | def runTest(frame, nb, log): | |
40 | win = TestPanel(nb, -1, log) | |
41 | return win | |
42 | ||
43 | #---------------------------------------------------------------------- | |
44 | ||
45 | ||
46 | overview = """\ | |
47 | <html><body> | |
48 | <h2>CalendarCtrl</h2> | |
49 | ||
50 | Yet <i>another</i> calendar control. This one is a wrapper around the C++ | |
51 | version described in the docs. This one will probably be a bit more efficient | |
52 | than the one in wxPython.lib.calendar, but I like a few things about it better, | |
53 | so I think both will stay in wxPython. | |
54 | """ | |
55 | ||
56 | ||
57 | if __name__ == '__main__': | |
58 | import sys,os | |
59 | import run | |
60 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
61 |