1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.adv.GenericCalendarCtrl:
==========================================================================================================================================
|phoenix_title| **wx.adv.GenericCalendarCtrl**
==========================================================================================================================================
The calendar control allows the user to pick a date.
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.
Generic calendar has advanced possibilities for the customization of its display, described below. If you want to use these possibilities on every platform, use GenericCalendarCtrl instead of :ref:`wx.adv.CalendarCtrl`.
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 :ref:`wx.adv.CalendarDateAttr` class.
An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with :meth:`~wx.adv.GenericCalendarCtrl.SetAttr` allows to modify its appearance. Just create a custom attribute object and set it for the day you want to be displayed specially (note that the control will take ownership of the pointer, i.e. it will delete it itself). A day may be marked as being a holiday, even if it is not recognized as one by :ref:`wx.DateTime` using the :meth:`wx.adv.CalendarDateAttr.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 ``EVT_CALENDAR_PAGE_CHANGED`` event handler.
.. _GenericCalendarCtrl-styles:
|styles| Window Styles
================================
This class supports the following styles:
- ``wx.adv.CAL_SUNDAY_FIRST``: Show Sunday as the first day in the week (not in wxGTK)
- ``wx.adv.CAL_MONDAY_FIRST``: Show Monday as the first day in the week (not in wxGTK)
- ``wx.adv.CAL_SHOW_HOLIDAYS``: Highlight holidays in the calendar (only generic)
- ``wx.adv.CAL_NO_YEAR_CHANGE``: Disable the year changing (deprecated, only generic)
- ``wx.adv.CAL_NO_MONTH_CHANGE``: Disable the month (and, implicitly, the year) changing
- ``wx.adv.CAL_SHOW_SURROUNDING_WEEKS``: Show the neighbouring weeks in the previous and next months (only generic, always on for the native controls)
- ``wx.adv.CAL_SEQUENTIAL_MONTH_SELECTION``: Use alternative, more compact, style for the month and year selection controls. (only generic)
- ``wx.adv.CAL_SHOW_WEEK_NUMBERS``: Show week numbers on the left side of the calendar. (not in generic)
.. _GenericCalendarCtrl-events:
|events| Events Emitted by this Class
=====================================
Handlers bound for the following event types will receive a :ref:`wx.adv.CalendarEvent` parameter.
- EVT_CALENDAR: A day was double clicked in the calendar.
- EVT_CALENDAR_SEL_CHANGED: The selected date changed.
- EVT_CALENDAR_PAGE_CHANGED: The selected month (and/or year) changed.
- EVT_CALENDAR_WEEKDAY_CLICKED: User clicked on the week day header (only generic).
- EVT_CALENDAR_WEEK_CLICKED: User clicked on the week of the year number (only generic).
Implementations:GTK, MSW ports; a generic implementation is used elsewhere.
.. note::
Changing the selected date will trigger an ``EVT_CALENDAR_DAY``, ``MONTH`` or ``YEAR`` event as well as an ``EVT_CALENDAR_SEL_CHANGED`` event.
.. seealso:: :ref:`Calendar Sample <calendar sample>`, :ref:`wx.adv.CalendarDateAttr`, :ref:`wx.adv.CalendarEvent`, :ref:`wx.adv.DatePickerCtrl`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>GenericCalendarCtrl</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.adv.CalendarCtrl_inheritance.png" alt="Inheritance diagram of GenericCalendarCtrl" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Control.html" title="wx.Control" alt="" coords="60,237,148,267"/> <area shape="rect" id="node3" href="wx.adv.CalendarCtrl.html" title="wx.adv.CalendarCtrl" alt="" coords="31,315,177,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="59,160,148,189"/> <area shape="rect" id="node4" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,87,35"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="48,83,159,112"/> <area shape="rect" id="node6" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="112,5,213,35"/> </map>
</p>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.adv.GenericCalendarCtrl.__init__` Default constructor.
:meth:`~wx.adv.GenericCalendarCtrl.Create` Creates the control.
:meth:`~wx.adv.GenericCalendarCtrl.EnableHolidayDisplay` This function should be used instead of changing ``CAL_SHOW_HOLIDAYS`` style bit directly.
:meth:`~wx.adv.GenericCalendarCtrl.EnableMonthChange` This function should be used instead of changing ``CAL_NO_MONTH_CHANGE`` style bit.
:meth:`~wx.adv.GenericCalendarCtrl.EnableYearChange`
:meth:`~wx.adv.GenericCalendarCtrl.GetAttr` Returns the attribute for the given date (should be in the range 1...31).
:meth:`~wx.adv.GenericCalendarCtrl.GetDate` Gets the currently selected date.
:meth:`~wx.adv.GenericCalendarCtrl.GetDateRange` Returns the limits currently being used.
:meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourBg` Gets the background colour of the header part of the calendar window.
:meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourFg` Gets the foreground colour of the header part of the calendar window.
:meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourBg` Gets the background highlight colour.
:meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourFg` Gets the foreground highlight colour.
:meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourBg` Return the background colour currently used for holiday highlighting.
:meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourFg` Return the foreground colour currently used for holiday highlighting.
:meth:`~wx.adv.GenericCalendarCtrl.HitTest` Returns one of CalendarHitTestResult constants and fills either `date` or `wd` pointer with the corresponding value depending on the hit test code.
:meth:`~wx.adv.GenericCalendarCtrl.Mark` Mark or unmark the day.
:meth:`~wx.adv.GenericCalendarCtrl.PyGetDate` Return the date as a Python datetime.date object.
:meth:`~wx.adv.GenericCalendarCtrl.ResetAttr` Clears any attributes associated with the given day (in the range 1...31).
:meth:`~wx.adv.GenericCalendarCtrl.SetAttr` Associates the attribute with the specified date (in the range 1...31).
:meth:`~wx.adv.GenericCalendarCtrl.SetDate` Sets the current date.
:meth:`~wx.adv.GenericCalendarCtrl.SetDateRange` Restrict the dates that can be selected in the control to the specified range.
:meth:`~wx.adv.GenericCalendarCtrl.SetHeaderColours` Set the colours used for painting the weekdays at the top of the control.
:meth:`~wx.adv.GenericCalendarCtrl.SetHighlightColours` Set the colours to be used for highlighting the currently selected date.
:meth:`~wx.adv.GenericCalendarCtrl.SetHoliday` Marks the specified day as being a holiday in the current month.
:meth:`~wx.adv.GenericCalendarCtrl.SetHolidayColours` Sets the colours to be used for the holidays highlighting.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.adv.GenericCalendarCtrl.Date` See :meth:`~wx.adv.GenericCalendarCtrl.GetDate` and :meth:`~wx.adv.GenericCalendarCtrl.SetDate`
:attr:`~wx.adv.GenericCalendarCtrl.DateRange` See :meth:`~wx.adv.GenericCalendarCtrl.GetDateRange` and :meth:`~wx.adv.GenericCalendarCtrl.SetDateRange`
:attr:`~wx.adv.GenericCalendarCtrl.HeaderColourBg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourBg`
:attr:`~wx.adv.GenericCalendarCtrl.HeaderColourFg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourFg`
:attr:`~wx.adv.GenericCalendarCtrl.HighlightColourBg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourBg`
:attr:`~wx.adv.GenericCalendarCtrl.HighlightColourFg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourFg`
:attr:`~wx.adv.GenericCalendarCtrl.HolidayColourBg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourBg`
:attr:`~wx.adv.GenericCalendarCtrl.HolidayColourFg` See :meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourFg`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.adv.GenericCalendarCtrl(Control)
**Possible constructors**::
GenericCalendarCtrl()
GenericCalendarCtrl(parent, id=ID_ANY, date=DefaultDateTime,
pos=DefaultPosition, size=DefaultSize, style=CAL_SHOW_HOLIDAYS,
name=CalendarNameStr)
The calendar control allows the user to pick a date.
.. method:: __init__(self, *args, **kw)
|overload| Overloaded Implementations:
**~~~**
**__init__** `(self)`
Default constructor.
**~~~**
**__init__** `(self, parent, id=ID_ANY, date=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=CAL_SHOW_HOLIDAYS, name=CalendarNameStr)`
Does the same as :meth:`Create` method.
:param `parent`:
:type `parent`: wx.Window
:param `id`:
:type `id`: wx.WindowID
:param `date`:
:type `date`: wx.DateTime
:param `pos`:
:type `pos`: wx.Point
:param `size`:
:type `size`: wx.Size
:param `style`:
:type `style`: long
:param `name`:
:type `name`: string
**~~~**
.. method:: Create(self, parent, id=ID_ANY, date=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=CAL_SHOW_HOLIDAYS, name=CalendarNameStr)
Creates the control.
See :meth:`Window.__init__` for the meaning of the parameters and the control overview for the possible styles.
:param `parent`:
:type `parent`: wx.Window
:param `id`:
:type `id`: wx.WindowID
:param `date`:
:type `date`: wx.DateTime
:param `pos`:
:type `pos`: wx.Point
:param `size`:
:type `size`: wx.Size
:param `style`:
:type `style`: long
:param `name`:
:type `name`: string
:rtype: `bool`
.. method:: 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.
:param `display`:
:type `display`: bool
.. method:: 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 cannot be changed, the year cannot be changed neither.
:param `enable`:
:type `enable`: bool
:rtype: `bool`
:returns:
``True`` if the value of this option really changed or ``False`` if it was already set to the requested value.
.. method:: 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. Only in generic :ref:`wx.adv.CalendarCtrl`.
:param `enable`:
:type `enable`: bool
.. method:: GetAttr(self, day)
Returns the attribute for the given date (should be in the range 1...31).
The returned pointer may be ``None``. Only in generic :ref:`wx.adv.CalendarCtrl`.
:param `day`:
:type `day`: int
:rtype: :ref:`wx.adv.CalendarDateAttr`
.. method:: GetDate(self)
Gets the currently selected date.
:rtype: :ref:`DateTime`
.. method:: GetDateRange(self)
Returns the limits currently being used.
:rtype: `tuple`
:returns:
( `bool`, `lowerdate`, `upperdate` )
.. seealso:: :meth:`SetDateRange`
.. method:: GetHeaderColourBg(self)
Gets the background colour of the header part of the calendar window.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and always returns ``NullColour`` in the native versions.
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHeaderColours`
.. method:: GetHeaderColourFg(self)
Gets the foreground colour of the header part of the calendar window.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and always returns ``NullColour`` in the native versions.
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHeaderColours`
.. method:: GetHighlightColourBg(self)
Gets the background highlight colour.
Only in generic :ref:`wx.adv.CalendarCtrl`.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and always returns ``NullColour`` in the native versions.
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHighlightColours`
.. method:: GetHighlightColourFg(self)
Gets the foreground highlight colour.
Only in generic :ref:`wx.adv.CalendarCtrl`.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and always returns ``NullColour`` in the native versions.
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHighlightColours`
.. method:: GetHolidayColourBg(self)
Return the background colour currently used for holiday highlighting.
Only useful with generic :ref:`wx.adv.CalendarCtrl` as native versions currently don't support holidays display at all and always return ``NullColour`` .
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHolidayColours`
.. method:: GetHolidayColourFg(self)
Return the foreground colour currently used for holiday highlighting.
Only useful with generic :ref:`wx.adv.CalendarCtrl` as native versions currently don't support holidays display at all and always return ``NullColour`` .
:rtype: :ref:`Colour`
.. seealso:: :meth:`SetHolidayColours`
.. method:: HitTest(self, pos)
Returns one of CalendarHitTestResult constants and fills either `date` or `wd` pointer with the corresponding value depending on the hit test code.
Not implemented in wxGTK currently.
:param `pos`:
:type `pos`: wx.Point
:rtype: `tuple`
:returns:
( :ref:`wx.adv.CalendarHitTestResult`, `date`, `wd` )
.. method:: Mark(self, day, mark)
Mark or unmark the day.
This day of month will be marked in every month. In generic :ref:`wx.adv.CalendarCtrl`,
:param `day`:
:type `day`: int
:param `mark`:
:type `mark`: bool
.. method:: PyGetDate(self)
Return the date as a Python datetime.date object.
.. method:: ResetAttr(self, day)
Clears any attributes associated with the given day (in the range 1...31).
Only in generic :ref:`wx.adv.CalendarCtrl`.
:param `day`:
:type `day`: int
.. method:: SetAttr(self, day, attr)
Associates the attribute with the specified date (in the range 1...31).
If the pointer is ``None``, the items attribute is cleared. Only in generic :ref:`wx.adv.CalendarCtrl`.
:param `day`:
:type `day`: int
:param `attr`:
:type `attr`: wx.adv.CalendarDateAttr
.. method:: SetDate(self, date)
Sets the current date.
The `date` parameter must be valid and in the currently valid range as set by :meth:`SetDateRange` , otherwise the current date is not changed and the function returns ``False``.
:param `date`:
:type `date`: wx.DateTime
:rtype: `bool`
.. method:: SetDateRange(self, lowerdate=DefaultDateTime, upperdate=DefaultDateTime)
Restrict the dates that can be selected in the control to the specified range.
If either date is set, the corresponding limit will be enforced and ``True`` returned. If none are set, the existing restrictions are removed and ``False`` is returned.
:param `lowerdate`: The low limit for the dates shown by the control or :ref:`wx.DefaultDateTime`.
:type `lowerdate`: wx.DateTime
:param `upperdate`: The high limit for the dates shown by the control or :ref:`wx.DefaultDateTime`.
:type `upperdate`: wx.DateTime
:rtype: `bool`
:returns:
``True`` if either limit is valid, ``False`` otherwise
.. seealso:: :meth:`GetDateRange`
.. method:: SetHeaderColours(self, colFg, colBg)
Set the colours used for painting the weekdays at the top of the control.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and does nothing in the native versions.
:param `colFg`:
:type `colFg`: wx.Colour
:param `colBg`:
:type `colBg`: wx.Colour
.. method:: SetHighlightColours(self, colFg, colBg)
Set the colours to be used for highlighting the currently selected date.
This method is currently only implemented in generic :ref:`wx.adv.CalendarCtrl` and does nothing in the native versions.
:param `colFg`:
:type `colFg`: wx.Colour
:param `colBg`:
:type `colBg`: wx.Colour
.. method:: SetHoliday(self, day)
Marks the specified day as being a holiday in the current month.
This method is only implemented in the generic version of the control and does nothing in the native ones.
:param `day`:
:type `day`: int
.. method:: SetHolidayColours(self, colFg, colBg)
Sets the colours to be used for the holidays highlighting.
This method is only implemented in the generic version of the control and does nothing in the native ones. It should also only be called if the window style includes ``CAL_SHOW_HOLIDAYS`` flag or :meth:`EnableHolidayDisplay` had been called.
:param `colFg`:
:type `colFg`: wx.Colour
:param `colBg`:
:type `colBg`: wx.Colour
.. attribute:: Date
See :meth:`~wx.adv.GenericCalendarCtrl.GetDate` and :meth:`~wx.adv.GenericCalendarCtrl.SetDate`
.. attribute:: DateRange
See :meth:`~wx.adv.GenericCalendarCtrl.GetDateRange` and :meth:`~wx.adv.GenericCalendarCtrl.SetDateRange`
.. attribute:: HeaderColourBg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourBg`
.. attribute:: HeaderColourFg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHeaderColourFg`
.. attribute:: HighlightColourBg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourBg`
.. attribute:: HighlightColourFg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHighlightColourFg`
.. attribute:: HolidayColourBg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourBg`
.. attribute:: HolidayColourFg
See :meth:`~wx.adv.GenericCalendarCtrl.GetHolidayColourFg`
|