Package wx :: Module calendar :: Class CalendarCtrl
[frames | no frames]

Type CalendarCtrl

object --+                
         |                
    Object --+            
             |            
    EvtHandler --+        
                 |        
            Window --+    
                     |    
               Control --+
                         |
                        CalendarCtrl


The calendar control allows the user to pick a date interactively.

The CalendarCtrl displays a window containing several parts: the control to pick the month and the year at the top (either or both of them may be disabled) and a month area below them which shows all the days in the month. The user can move the current selection using the keyboard and select the date (generating EVT_CALENDAR event) by pressing <Return> or double clicking it.

It has advanced possibilities for the customization of its display. All global settings (such as colours and fonts used) can, of course, be changed. But also, the display style for each day in the month can be set independently using CalendarDateAttr class.

An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with SetAttr allows to modify its appearance. Just create a custom attribute object and set it for the day you want to be displayed specially A day may be marked as being a holiday, (even if it is not recognized as one by wx.DateTime) by using the SetHoliday method.

As the attributes are specified for each day, they may change when the month is changed, so you will often want to update them in an EVT_CALENDAR_MONTH event handler.

Window Styles

CAL_SUNDAY_FIRST Show Sunday as the first day in the week
CAL_MONDAY_FIRST Show Monday as the first day in the week
CAL_SHOW_HOLIDAYS Highlight holidays in the calendar
CAL_NO_YEAR_CHANGE Disable the year changing
CAL_NO_MONTH_CHANGE Disable the month (and, implicitly, the year) changing
CAL_SHOW_SURROUNDING_WEEKS Show the neighbouring weeks in the previous and next months
CAL_SEQUENTIAL_MONTH_SELECTION Use alternative, more compact, style for the month and year selection controls.

The default calendar style is CAL_SHOW_HOLIDAYS.

Events

EVT_CALENDAR A day was double clicked in the calendar.
EVT_CALENDAR_SEL_CHANGED The selected date changed.
EVT_CALENDAR_DAY The selected day changed.
EVT_CALENDAR_MONTH The selected month changed.
EVT_CALENDAR_YEAR The selected year changed.
EVT_CALENDAR_WEEKDAY_CLICKED User clicked on the week day header

Note that changing the selected date will result in one of EVT_CALENDAR_DAY, MONTH or YEAR events and an EVT_CALENDAR_SEL_CHANGED event.


Method Summary
CalendarCtrl __init__(self, parent, id, date, pos, size, style, name)
Create and show a calendar control.
bool Create(self, parent, id, date, pos, size, style, name)
Acutally create the GUI portion of the CalendarCtrl for 2-phase creation.
  EnableHolidayDisplay(self, display)
This function should be used instead of changing CAL_SHOW_HOLIDAYS style bit directly.
  EnableMonthChange(self, enable)
This function should be used instead of changing CAL_NO_MONTH_CHANGE style bit.
  EnableYearChange(self, enable)
This function should be used instead of changing CAL_NO_YEAR_CHANGE style bit directly.
CalendarDateAttr GetAttr(self, day)
Returns the attribute for the given date (should be in the range 1...31).
VisualAttributes GetClassDefaultAttributes(variant)
Get the default attributes for this class. (Static method)
DateTime GetDate(self)
Gets the currently selected date.
Colour GetHeaderColourBg(self)
Header colours are used for painting the weekdays at the top.
Colour GetHeaderColourFg(self)
Header colours are used for painting the weekdays at the top.
Colour GetHighlightColourBg(self)
Highlight colour is used for the currently selected date.
Colour GetHighlightColourFg(self)
Highlight colour is used for the currently selected date.
Colour GetHolidayColourBg(self)
Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).
Colour GetHolidayColourFg(self)
Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).
DateTime GetLowerDateLimit(self)
get the range in which selection can occur
Control GetMonthControl(self)
Get the currently shown control for month.
DateTime GetUpperDateLimit(self)
get the range in which selection can occur
Control GetYearControl(self)
Get the currently shown control for year.
(result, date, weekday) HitTest(pos)
Returns 3-tuple with information about the given position on the calendar control.
  PyGetDate(self)
returns datetime.date object
  PyGetLowerDateLimit(self)
returns datetime.date object
  PyGetUpperDateLimit(self)
returns datetime.date object
  PySetDate(self, date)
takes datetime.datetime or datetime.date object
  PySetDateRange(self, lowerdate, upperdate)
takes datetime.datetime or datetime.date objects
  PySetLowerDateLimit(self, date)
takes datetime.datetime or datetime.date object
  PySetUpperDateLimit(self, date)
takes datetime.datetime or datetime.date object
  ResetAttr(self, day)
Clears any attributes associated with the given day (in the range 1...31).
  SetAttr(self, day, attr)
Associates the attribute with the specified date (in the range 1...31).
  SetDate(self, date)
Sets the current date.
bool SetDateRange(self, lowerdate, upperdate)
set the range in which selection can occur
  SetHeaderColours(self, colFg, colBg)
Header colours are used for painting the weekdays at the top.
  SetHighlightColours(self, colFg, colBg)
Highlight colour is used for the currently selected date.
  SetHoliday(self, day)
Marks the specified day as being a holiday in the current month.
  SetHolidayColours(self, colFg, colBg)
Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).
bool SetLowerDateLimit(self, date)
set the range in which selection can occur
bool SetUpperDateLimit(self, date)
set the range in which selection can occur

Property Summary
  Date: See GetDate and SetDate
  HeaderColourBg: See GetHeaderColourBg
  HeaderColourFg: See GetHeaderColourFg
  HighlightColourBg: See GetHighlightColourBg
  HighlightColourFg: See GetHighlightColourFg
  HolidayColourBg: See GetHolidayColourBg
  HolidayColourFg: See GetHolidayColourFg
  LowerDateLimit: See GetLowerDateLimit and SetLowerDateLimit
  MonthControl: See GetMonthControl
  thisown: The membership flag
  UpperDateLimit: See GetUpperDateLimit and SetUpperDateLimit
  YearControl: See GetYearControl

Instance Method Details

__init__(self, parent, id=-1, date=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS, name=CalendarNameStr)
(Constructor)

Create and show a calendar control.

Parameters:
parent
           (type=Window)

id
           (type=int)

date
           (type=DateTime)

pos
           (type=Point)

size
           (type=Size)

style
           (type=long)

name
           (type=String)

Returns:
CalendarCtrl
Overrides:
wx.Control.__init__

Create(self, parent, id, date=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS, name=CalendarNameStr)

Acutally create the GUI portion of the CalendarCtrl for 2-phase creation.

Parameters:
parent
           (type=Window)

id
           (type=int)

date
           (type=DateTime)

pos
           (type=Point)

size
           (type=Size)

style
           (type=long)

name
           (type=String)

Returns:
bool
Overrides:
wx.Control.Create

EnableHolidayDisplay(self, display=True)

This function should be used instead of changing CAL_SHOW_HOLIDAYS style bit directly. It enables or disables the special highlighting of the holidays.

Parameters:
display
           (type=bool)

EnableMonthChange(self, enable=True)

This function should be used instead of changing CAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to change the month interactively. Note that if the month can not be changed, the year can not be changed either.

Parameters:
enable
           (type=bool)

EnableYearChange(self, enable=True)

This function should be used instead of changing CAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the user to change the year interactively.

Parameters:
enable
           (type=bool)

GetAttr(self, day)

Returns the attribute for the given date (should be in the range 1...31). The returned value may be None

Parameters:
day
           (type=size_t)

Returns:
CalendarDateAttr

GetDate(self)

Gets the currently selected date.

Returns:
DateTime

GetHeaderColourBg(self)

Header colours are used for painting the weekdays at the top.

Returns:
Colour

GetHeaderColourFg(self)

Header colours are used for painting the weekdays at the top.

Returns:
Colour

GetHighlightColourBg(self)

Highlight colour is used for the currently selected date.

Returns:
Colour

GetHighlightColourFg(self)

Highlight colour is used for the currently selected date.

Returns:
Colour

GetHolidayColourBg(self)

Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).

Returns:
Colour

GetHolidayColourFg(self)

Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).

Returns:
Colour

GetLowerDateLimit(self)

get the range in which selection can occur

Returns:
DateTime

GetMonthControl(self)

Get the currently shown control for month.

Returns:
Control

GetUpperDateLimit(self)

get the range in which selection can occur

Returns:
DateTime

GetYearControl(self)

Get the currently shown control for year.

Returns:
Control

HitTest(pos)

Returns 3-tuple with information about the given position on the calendar control. The first value of the tuple is a result code and determines the validity of the remaining two values. The result codes are:

CAL_HITTEST_NOWHERE hit outside of anything
CAL_HITTEST_HEADER hit on the header, weekday is valid
CAL_HITTEST_DAY hit on a day in the calendar, date is set.
Parameters:
pos
           (type=Point)

Returns:
(result, date, weekday)
Overrides:
wx.Window.HitTest

PyGetDate(self)

returns datetime.date object

PyGetLowerDateLimit(self)

returns datetime.date object

PyGetUpperDateLimit(self)

returns datetime.date object

PySetDate(self, date)

takes datetime.datetime or datetime.date object

PySetDateRange(self, lowerdate, upperdate)

takes datetime.datetime or datetime.date objects

PySetLowerDateLimit(self, date)

takes datetime.datetime or datetime.date object

PySetUpperDateLimit(self, date)

takes datetime.datetime or datetime.date object

ResetAttr(self, day)

Clears any attributes associated with the given day (in the range 1...31).

Parameters:
day
           (type=size_t)

SetAttr(self, day, attr)

Associates the attribute with the specified date (in the range 1...31). If the attribute passed is None, the items attribute is cleared.

Parameters:
day
           (type=size_t)

attr
           (type=CalendarDateAttr)

SetDate(self, date)

Sets the current date.

Parameters:
date
           (type=DateTime)

SetDateRange(self, lowerdate=DefaultDateTime, upperdate=DefaultDateTime)

set the range in which selection can occur

Parameters:
lowerdate
           (type=DateTime)

upperdate
           (type=DateTime)

Returns:
bool

SetHeaderColours(self, colFg, colBg)

Header colours are used for painting the weekdays at the top.

Parameters:
colFg
           (type=Colour)

colBg
           (type=Colour)

SetHighlightColours(self, colFg, colBg)

Highlight colour is used for the currently selected date.

Parameters:
colFg
           (type=Colour)

colBg
           (type=Colour)

SetHoliday(self, day)

Marks the specified day as being a holiday in the current month.

Parameters:
day
           (type=size_t)

SetHolidayColours(self, colFg, colBg)

Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is used).

Parameters:
colFg
           (type=Colour)

colBg
           (type=Colour)

SetLowerDateLimit(self, date=DefaultDateTime)

set the range in which selection can occur

Parameters:
date
           (type=DateTime)

Returns:
bool

SetUpperDateLimit(self, date=DefaultDateTime)

set the range in which selection can occur

Parameters:
date
           (type=DateTime)

Returns:
bool

Static Method Details

GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)

Get the default attributes for this class. This is useful if you want to use the same font or colour in your own control as in a standard control -- which is a much better idea than hard coding specific colours or fonts which might look completely out of place on the user's system, especially if it uses themes.

The variant parameter is only relevant under Mac currently and is ignore under other platforms. Under Mac, it will change the size of the returned font. See wx.Window.SetWindowVariant for more about this.

Parameters:
variant
           (type=int)

Returns:
VisualAttributes

Property Details

Date

See GetDate and SetDate

Get Method:
GetDate(self)
Set Method:
SetDate(self, date)

HeaderColourBg

See GetHeaderColourBg

Get Method:
GetHeaderColourBg(self)

HeaderColourFg

See GetHeaderColourFg

Get Method:
GetHeaderColourFg(self)

HighlightColourBg

See GetHighlightColourBg

Get Method:
GetHighlightColourBg(self)

HighlightColourFg

See GetHighlightColourFg

Get Method:
GetHighlightColourFg(self)

HolidayColourBg

See GetHolidayColourBg

Get Method:
GetHolidayColourBg(self)

HolidayColourFg

See GetHolidayColourFg

Get Method:
GetHolidayColourFg(self)

LowerDateLimit

See GetLowerDateLimit and SetLowerDateLimit

Get Method:
GetLowerDateLimit(self)
Set Method:
SetLowerDateLimit(self, date)

MonthControl

See GetMonthControl

Get Method:
GetMonthControl(self)

thisown

The membership flag

Get Method:
unknown--1218584932(...)
Set Method:
unknown--1218584876(...)

UpperDateLimit

See GetUpperDateLimit and SetUpperDateLimit

Get Method:
GetUpperDateLimit(self)
Set Method:
SetUpperDateLimit(self, date)

YearControl

See GetYearControl

Get Method:
GetYearControl(self)

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:14:09 2007 http://epydoc.sf.net