MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / popup_get_date

Function popup_get_date

PySimpleGUI/PySimpleGUI.py:21731–21897  ·  view source on GitHub ↗

Display a calendar window, get the user's choice, return as a tuple (mon, day, year) :param start_mon: The starting month :type start_mon: (int) :param start_day: The starting day - optional. Set to None or 0 if no date to be chosen at start :t

(start_mon=None, start_day=None, start_year=None, begin_at_sunday_plus=0, no_titlebar=True, title='Choose Date', keep_on_top=True,
                   location=(None, None), relative_location=(None, None), close_when_chosen=False, icon=None, locale=None, month_names=None, day_abbreviations=None, day_font = 'TkFixedFont 9', mon_year_font = 'TkFixedFont 10', arrow_font = 'TkFixedFont 7', modal=True)

Source from the content-addressed store, hash-verified

21729
21730
21731def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sunday_plus=0, no_titlebar=True, title='Choose Date', keep_on_top=True,
21732 location=(None, None), relative_location=(None, None), close_when_chosen=False, icon=None, locale=None, month_names=None, day_abbreviations=None, day_font = 'TkFixedFont 9', mon_year_font = 'TkFixedFont 10', arrow_font = 'TkFixedFont 7', modal=True):
21733 """
21734 Display a calendar window, get the user's choice, return as a tuple (mon, day, year)
21735
21736 :param start_mon: The starting month
21737 :type start_mon: (int)
21738 :param start_day: The starting day - optional. Set to None or 0 if no date to be chosen at start
21739 :type start_day: int | None
21740 :param start_year: The starting year
21741 :type start_year: (int)
21742 :param begin_at_sunday_plus: Determines the left-most day in the display. 0=sunday, 1=monday, etc
21743 :type begin_at_sunday_plus: (int)
21744 :param icon: Same as Window icon parameter. Can be either a filename or Base64 value. For Windows if filename, it MUST be ICO format. For Linux, must NOT be ICO
21745 :type icon: (str | bytes)
21746 :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
21747 :type location: (int, int)
21748 :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21749 :type relative_location: (int, int)
21750 :param title: Title that will be shown on the window
21751 :type title: (str)
21752 :param close_when_chosen: If True, the window will close and function return when a day is clicked
21753 :type close_when_chosen: (bool)
21754 :param locale: locale used to get the day names
21755 :type locale: (str)
21756 :param no_titlebar: If True no titlebar will be shown
21757 :type no_titlebar: (bool)
21758 :param keep_on_top: If True the window will remain above all current windows
21759 :type keep_on_top: (bool)
21760 :param month_names: optional list of month names to use (should be 12 items)
21761 :type month_names: List[str]
21762 :param day_abbreviations: optional list of abbreviations to display as the day of week
21763 :type day_abbreviations: List[str]
21764 :param day_font: Font and size to use for the calendar
21765 :type day_font: str | tuple
21766 :param mon_year_font: Font and size to use for the month and year at the top
21767 :type mon_year_font: str | tuple
21768 :param arrow_font: Font and size to use for the arrow buttons
21769 :type arrow_font: str | tuple
21770 :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
21771 :type modal: bool
21772 :return: Tuple containing (month, day, year) of chosen date or None if was cancelled
21773 :rtype: None | (int, int, int)
21774 """
21775
21776 if month_names is not None and len(month_names) != 12:
21777 if not SUPPRESS_ERROR_POPUPS:
21778 popup_error('Incorrect month names list specified. Must have 12 entries.', 'Your list:', month_names)
21779
21780 if day_abbreviations is not None and len(day_abbreviations) != 7:
21781 if not SUPPRESS_ERROR_POPUPS:
21782 popup_error('Incorrect day abbreviation list. Must have 7 entries.', 'Your list:', day_abbreviations)
21783
21784 now = datetime.datetime.now()
21785 cur_month, cur_day, cur_year = now.month, now.day, now.year
21786 cur_month = start_mon or cur_month
21787 if start_mon is not None:
21788 cur_day = start_day

Callers 2

mainFunction · 0.70

Calls 12

make_modalMethod · 0.95
readMethod · 0.95
closeMethod · 0.95
popup_errorFunction · 0.85
TextClass · 0.85
theme_text_colorFunction · 0.85
theme_background_colorFunction · 0.85
ButtonClass · 0.85
WindowClass · 0.85
make_days_layoutFunction · 0.70
update_daysFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected