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