Time Handling¶
tks.times
provides 4 classes to obtain a time from a user.
TimeVar
- A Tk variable which holds a time.
TimeEntry
- Displays entry boxes for hours, minutes and optionally seconds and an AM/PM selector. Also contains a button to display a time selection dialog.
TimeDialog
- Displays a dialog window allowing the user to select a time.
TimeSelector
- A widget which contains the time selection machinery.
-
class
tks.times.
TimeVar
(master=None, value=None, name=None)¶ A Tkinter variable which holds a
datetime.time
-
class
tks.times.
TimeEntry
(master, variable=None, locale='en', fonts=None, show_seconds=False)¶ A time entry widget
Parameters: - master (
ttk.Frame
) – The master frame - variable (
tks.times.TimeVar
) – The variable which hold the date to display in the entry boxes. - locale (str or
babel.Locale
) – Determines the widgets in the entry. Either a locale name e.g. ‘en’ or a babel Locale instance. Ifbabel
is not installed ISO 8601 format will be used i.e. 24 hours (no am/pm) and ‘:’ as a separator. - fonts (
DefaultFonts
) – Fonts to use - show_seconds (bool) – If True a seconds value can be entered.
- master (
-
class
tks.times.
TimeDialog
(master, title, start_time=None, locale='en', time_position='top', show_seconds=False, ampm=None, fonts=None)¶ Display a dialog to obtain a time from the user
Parameters: - master (
ttk.Frame
) – The master frame - title (str) – Window title.
- start_time (
datetime.time
) – The time to display in the entry boxes. If not provided or None then today’s date will be used. - locale (str or
babel.Locale
) – Determines the widgets in the entry. Either a locale name e.g. ‘en’ or a babel Locale instance. Ifbabel
is not installed ISO 8601 format will be used i.e. 24 hours (no am/pm) and ‘:’ as a separator. - time_position –
Controls if and where a text representation of the time is displayed. Can be one of the following
None - Don’t display tk.TOP - Display above the clock face tk.BOTTOM - Display below the clock face
- show_seconds (bool) – If True a seconds value can be entered.
- ampm – If not None display a 12 hour clock face with am/pm selection where the 1st element of the tuple is the text for AM and the 2nd element for PM.
- fonts (
DefaultFonts
) – Fonts definitions to use
- master (
-
class
tks.times.
TimeSelector
(master, start_time, locale='en', ampm=None, time_position='top', show_seconds=False, fonts=None, colors=None)¶ A time selection widget.
Parameters: - master (
ttk.Frame
) – The master frame - locale (str or
babel.Locale
) – Determines the widgets in the entry. Either a locale name e.g. ‘en’ or a babel Locale instance. Ifbabel
is not installed ISO 8601 format will be used i.e. 24 hours (no am/pm) and ‘:’ as a separator. - ampm – If not None display a 12 hour clock face with am/pm selection where the 1st element of the tuple is the text for AM and the 2nd element for PM.
- time_position (str) – Controls where to display the selected time. I None the time is not displayed. If tk.TOP then it is displayed above the clock dial, if tk.BOTTOM then below.
- show_seconds (bool) – If True then the selector can also be used to set seconds.
- fonts (
DefaultFonts
) – Font definitions to use - colors (
DefaultColors
) – Colors to use.
Used by the
TimeDialog
class but can be used independently.-
time
¶ The selected time
- master (