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