]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/CalendarCtrl.py
check for wxHAS_HUGE_FILES
[wxWidgets.git] / wxPython / demo / CalendarCtrl.py
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
18 self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, id=cal.GetId())
19
20 b = wx.Button(self, -1, "Destroy the Calendar", pos = (275, 50))
21 self.Bind(wx.EVT_BUTTON, self.OnButton, id= b.GetId())
22 self.cal = cal
23
24 # Set up control to display a set of holidays:
25 self.Bind(wx.calendar.EVT_CALENDAR_MONTH, self.OnChangeMonth, cal)
26 self.holidays = [(1,1), (10,31), (12,25) ] # (these don't move around)
27 self.OnChangeMonth()
28
29 def OnButton(self, evt):
30 if self.cal is not None:
31 self.cal.Destroy()
32 self.cal = None
33
34 def OnCalSelected(self, evt):
35 self.log.write('OnCalSelected: %s\n' % evt.GetDate())
36
37 def OnChangeMonth(self, evt=None):
38 cur_month = self.cal.GetDate().GetMonth() + 1 # convert wxDateTime 0-11 => 1-12
39
40 for month, day in self.holidays:
41 if month == cur_month:
42 self.cal.SetHoliday(day)
43
44 #----------------------------------------------------------------------
45
46 def runTest(frame, nb, log):
47 win = TestPanel(nb, -1, log)
48 return win
49
50 #----------------------------------------------------------------------
51
52
53 overview = """\
54 <html><body>
55 <h2>CalendarCtrl</h2>
56
57 Yet <i>another</i> calendar control. This one is a wrapper around the C++
58 version described in the docs. This one will probably be a bit more efficient
59 than the one in wxPython.lib.calendar, but I like a few things about it better,
60 so I think both will stay in wxPython.
61 """
62
63
64 if __name__ == '__main__':
65 import sys,os
66 import run
67 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
68