]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxCalendarCtrl.py
Merged wxPython 2.4.x to the 2.5 branch (Finally!!!)
[wxWidgets.git] / wxPython / demo / wxCalendarCtrl.py
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
13 cal = wxCalendarCtrl(self, -1, wxDateTime_Now(), pos = (25,50),
14 style = wxCAL_SHOW_HOLIDAYS | wxCAL_SUNDAY_FIRST)
15
16 EVT_CALENDAR(self, cal.GetId(), self.OnCalSelected)
17
18 b = wxButton(self, -1, "Destroy the Calendar", pos = (250, 50))
19 EVT_BUTTON(self, b.GetId(), self.OnButton)
20 self.cal = cal
21
22 # Set up control to display a set of holidays:
23 EVT_CALENDAR_MONTH(self, cal.GetId(), self.OnChangeMonth)
24 self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around)
25 self.OnChangeMonth()
26
27 def OnButton(self, evt):
28 self.cal.Destroy()
29 self.cal = None
30
31 def OnCalSelected(self, evt):
32 self.log.write('OnCalSelected: %s\n' % evt.GetDate())
33
34 def OnChangeMonth(self, evt=None):
35 cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12
36 for month, day in self.holidays:
37 if month == cur_month:
38 self.cal.SetHoliday(day)
39
40 #----------------------------------------------------------------------
41
42 def runTest(frame, nb, log):
43 win = TestPanel(nb, -1, log)
44 return win
45
46 #----------------------------------------------------------------------
47
48
49 overview = """\
50 <html><body>
51 <h2>wxCalendarCtrl</h2>
52
53 Yet <i>another</i> calendar control. This one is a wrapper around the C++
54 version described in the docs. This one will probably be a bit more efficient
55 than the one in wxPython.lib.calendar, but I like a few things about it better,
56 so I think both will stay in wxPython.
57 """