]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxCalendarCtrl.py
reSWIGged
[wxWidgets.git] / wxPython / demo / wxCalendarCtrl.py
CommitLineData
8fa876ca
RD
1# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
f6bcfd97 5
8fa876ca
RD
6import wx
7import wx.lib.calendar as calendar
f6bcfd97
BP
8
9#----------------------------------------------------------------------
10
8fa876ca 11class 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
49def runTest(frame, nb, log):
50 win = TestPanel(nb, -1, log)
51 return win
52
53#----------------------------------------------------------------------
54
55
56overview = """\
57<html><body>
58<h2>wxCalendarCtrl</h2>
59
60Yet <i>another</i> calendar control. This one is a wrapper around the C++
61version described in the docs. This one will probably be a bit more efficient
62than the one in wxPython.lib.calendar, but I like a few things about it better,
63so I think both will stay in wxPython.
64"""
1fded56b
RD
65
66
67
68
69if __name__ == '__main__':
70 import sys,os
71 import run
72 run.main(['', os.path.basename(sys.argv[0])])
73