biometrics_tracker.gui.tk_gui module

class biometrics_tracker.gui.tk_gui.AddEditScheduleFrame(*args: Any, **kwargs: Any)

Bases: Frame

Implements a GUI to facilitate the maintenance of ScheduleEntry’s

clear_entry()

Clears the entry widgets except for the Starts On and Ends On date entry widgets, and removes any schedule widget that is present.

Returns

None

daily_selected()

Instantiate a Daily Schedule widget and grid it into the display

Returns

None

display_schedules(msg: ScheduleEntriesMsg)

Builds a set of widgets to display and allow the modification of a set of ScheduleEntry’s

Parameters

msg (biometrics_tracker.ipc.messages.ScheduleEntriesMsg) – a message containing a list of ScheduleEntry’s

Returns

None

edit_entry(event)

This method implements the logic for editing an existing ScheduleEntry

Parameters

event

Returns

None

focus_on_note(event)

Forces the focus to the note field. This method is used to prevent the Seq No field, which is intended to be display only, from gaining focus

Parameters

event

Returns

None

focus_set()

Delagates the focus_set invocations to the Starts On date entry widget

Returns

None

get_entry() ScheduleEntry

Retrieve a ScheduleEntry instance from the currently active SchduleEntry widget

Returns

biometric_tracker.model.datapoints.ScheduleEntry

get_non_entered_values() -> (<class 'int'>, <class 'int'>, <class 'datetime.time'>, typing.Optional[datetime.date])

Provides values for info that may not (yet) be entered by the user

Returns

tuple[int, int, time, Optional[date])

handle_delete() None

Process a list of ‘Delete’ checkboxes, sending delete messages to the database for each checked box

Returns

None

hourly_selected()

Instantiate an Hourly Schedule widget and grid it into the display

Returns

None

monthly_selected()

Instantiate a Monthly Schedule widget and grid it into the display

Returns

None

once_selected()

Instantiate a One Time Schedule widget and grid it into the display

Returns

None

retrieve_schedules(msg: Optional[ScheduleEntriesMsg] = None)

Issue a ScheduleEntryReqMsg to the database to retrieve the ScheduleEntry’s for a person :param msg: although this parm is not used in the method, it is needed in the signiture when it is used as a replyto parm for other messages

Returns

None

validate()

Assures that required info has been entered before comleting a Save request. Invokes ScheduleEntry save and delete handlers if the entries are valid

Returns

None

weekly_selected()

Instantiate a Weekly Schedule widget and grid it into the diplay

Returns

None

class biometrics_tracker.gui.tk_gui.Application(*args: Any, **kwargs: Any)

Bases: Window, CoreLogic

This ttkbootstrap Window is the main GUI for the application. It contains menus that invoke the various application functions. The body of the Window is used to contain the various Frames that implement the application’s functionality.

add_datapoint(person_msg: PersonMsg)

Presents a biometrics_tracker.gui.tk_gui.QuickEntryFrame to allow a set of metrics for a date and time to be entered. This method is invoked when a person is selected after the Biometrics/Quick Entry menu option is selected.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – the DB response message contain the Person instance

Returns

None

add_edit_schedules(person_msg: PersonMsg)

Handles the Add/Edit Schedule Entries function

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message containing a Person instance for the person whose schedules will be maintained.

Returns

None

add_person()

Presents a biometrics_tracker.gui.tk_gui.PersonFrame to allow the entry of information to a new person. This method is invoked when the Person/Add a New Person menu option is selected

Returns

None

add_plugin_menu(label: str) Any

This method is provided to the biometrics_tracker.plugin.plugin.PluginMenu.create_menu method.

Parameters
  • self

  • label

Returns

add_plugin_menu_item(menu: ttkbootstrap.Menu, label: str, action: Callable) None

This method is provided as a callback to the biometrics_tracker.plugin.plugin.PluginMenu.create_menu method

Parameters
  • menu (ttkbootstrap.Menu) – the parent Menu object

  • label – the text to be used for the menu item label

  • label – str

  • action – the callback to be invoked when the menu item is selected

  • action – Callable

Returns

None

check_completion_queue()

Check the completion queue for messages, invoke the callback if a message is retrieved

Returns

None

check_response_queue()

Check the database response queue for messages, invoke the callback if a message is received.

Returns

None

edit_person(person_msg: PersonMsg)

Presents a biometrics_tracker.gui.tk_gui.PersonFrame to allow the edit of an existing person’s information. This method in invoked when a person is selected after the People/Edit a Person’s Information menu option is selected.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message object containing the Person object

Returns

None

exit_app(msg: CompletionMsg)

End the Tkinter event loop

Parameters

msg (biometrics_tracker.ipc.messages.CompletionMsg) – a Completion message, probably a response to a close database request

Returns

None

export(person_msg: PersonMsg)

Presents a gui.CSVImportFrame to allow a CSV file to be imported. This method is invoked when a person is selected after the Biometrics/Import CSV File menu option is selected.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message object containing a Person instance

Returns

None

export_process_complete(msg: ImportExportCompletionMsg)

This method is specified as the completion callback for the export process

Parameters

msg (biometrics_tracker.ipc.messages.CompletionMsg) – the completion message

Returns

None

help_menu()

Displays the help table of contents in the system default browser

Returns

None

history_report(person_msg: PersonMsg)

Presents a gui.BiometricsReportFrame that allows the accepts a date range and produces a report for the selected person.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message object containing a Person instance

Returns

None

import_csv(person_msg: PersonMsg)

Presents a gui.CSVImportFrame to allow a CSV file to be imported. This method is invoked when a person is selected after the Biometrics/Import CSV File menu option is selected.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message object containing a Person instance

Returns

None

import_process_complete(msg: ImportExportCompletionMsg)

This method is specified as the completion callback for the import process

Parameters

msg (biometrics_tracker.ipc.messages.CompletionMsg) – the completion message

Returns

None

plugin_not_found() None

This is a dummy placeholder to be used an action method in cases when a plugin module can not be imported or an entry point is not found within the module.

Returns

None

preproc_selection(sel_person: bool, sel_date_rng: bool, sel_dp_type: bool, action: Callable) None

This method is provided as an action call back to the biometrics_tracker.plugin.plugin.PluginMenu.create_menu method. It creates and displays an instance of DataPointSelectionFrame to collect selection criteria.

Parameters
  • sel_person (bool) – will Person ID be part of the selection criteria

  • sel_date_rng (bool) – will date range be part of the selection criteria

  • sel_dp_type (bool) – will DataPointType be part of the selection criteria

  • action (Callable) – the plugin’s entry point

Returns

None

refresh_people_list(msg: PeopleMsg)

Received a list of people and saves it for future use

Parameters

msg (biometrics_tracker.ipc.messages.PeopleMsg) – a message containing a list of Person instances

Returns

None

remove_child_frame(frame_class)
Removes a Frame of the specified class from the Window. This method is invoked when a application function is

complete or canceled

Parameters

frame_class (Class) – the class of the Frame to be removed (e.g. gui.PersonListFrame, gui.PersonFrame, gui.QuickEntryFrame)

Returns

None

run_scheduler() None

Presents the RunSchedulerFrame and starts biometrics_tracker.main.scheduler.Scheduler in a separate thread

Returns

None

select_install_plugin() None

Select a Plugin Specification File to be installed in the app’s plugin folder. The selected file will be copied to that folder. The application must be restarted for the plugin’s menu to appear in the menu bar

Returns

None

select_person(title: str, callback: Callable)

Presents a biometrics_tracker.gui.tk_gui.PeopleListFrame to allow the selection of a person for further processing.

Parameters
  • title (str) – a title to be displayed at the top of the Frame

  • callback (Callable) – a callback to be invoked when a person is selected

Returns

None

select_remove_plugin() None

Select a Plugin Specification File from the app’s plugin folder to be deleted.

Returns

None

submit_person_update(person_frame: PersonFrame, operation: DBOperation)

Updates the database with the result of an add or update of a person

Parameters
  • person_frame (biometrics_tracker.gui.tk_gui.PersonFrame) – the frame presented in the add or update process. This method is invoked when the .gui.PersonFrame submit button is pressed though the submit function of the add_person and edit_person methods

  • operation (biometrics_tracker.ipc.messages.DBOperation) – whether the Person database row is to be inserted or updated

Returns

None

upcoming_events(person_msg: PersonMsg)

Build and display a list of ScheduleEntry’s that will be triggered during the specified series

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message containing a Person instance for the person whose ScheduleEntry’s will be dislayed

Returns

None

view_edit_history(person_msg: PersonMsg)

Presents a biometrics_tracker.gui.tk_gui.ViewEditBiometricsFrame that allows the retrieval and editing of datapoint for the selected person that are within a specified date range.

Parameters

person_msg (biometrics_tracker.ipc.messages.PersonMsg) – a message object containing the a Person object

Returns

None

class biometrics_tracker.gui.tk_gui.BiometricsFrameBase(*args: Any, **kwargs: Any)

Bases: Frame

This is a base class for frames that display biometrics data in various ways

focus_set()

Delegate focus_set calls to the start date widget

Returns

None

abstract retrieve_history()

This method must be overridden by inheriting classes to retrieve Datapoints for a specified prerson within a specified date range.

Returns

None

class biometrics_tracker.gui.tk_gui.BiometricsReportPromptFrame(*args: Any, **kwargs: Any)

Bases: BiometricsFrameBase

display_history(msg: CompletionMsg)

Display the DataPoints retrieved by the retrieve_history method in a ScrolledText widget. This content is also used to create the Text version of the History Report

Parameters

msg (biometrics_tracker.ipc.messges.CompletionMsg) – a completion message notifying that the report creation process is complete

Returns

retrieve_history()

Retrieve the datapoints within the specified date range for the selected person and produce a text report

Returns

None

class biometrics_tracker.gui.tk_gui.CSVImportFrame(*args: Any, **kwargs: Any)

Bases: Frame

A ttkbootstrap Frame that allows the entry of the information necessary to import a CSV file

browse_csv()

Presents a tk.filedialog to browse the file system and select a CSV file to be imported

Returns

None

focus_first_widget(event)

Focuses on the first gui.widgets.CSVImportFrame. This method is bound to the <FocusOut> widget of the ‘Number of Header Rows’ entry field

Parameters

event (Tkinter.Event) –

Returns

None

header_rows() int

Returns the number of header rows in the CSV file to be imported

Returns

number of header rows

Return type

int

import_file_name() str

Returns the import file name

Returns

file name

Return type

str

indexed_fields() dict[int, str]

Returns a dict[int, str] that has the position within the CSV file of the field as the key and the field name as the value. The field names are taken from the string values defined at the beginning of the model.importers module.

Returns

map of fields selected for import

Return type

dict[int, str]

save_import_spec()

This method is used a callback for the OK button on the Save Import Spec dialog. It collects the current values from the prompts, creates an ImportSpec object, places in an ImportSpecCollection object and pickles the collection object.

Returns

None

select_import_spec(event)

This method is used as a callback for the selection action of the Select Import Spec dialog. It retrieves the selected specification from the ImportSpecificatonCollection and uses it to set the prompt values on this Frame

Parameters

event

Returns

None

set_use_prev_row_date()

Set a boolean based on the value of the IntVar associated with the Use Previous Row Date checkbox

Returns

None

update_preview(event)

Update the ttkbootstrap.scrolled Scrollable Text widget to show the first 30 lines of the selected CSV files. This method is bound the <FocusOut> event of the CSV file name entry

Parameters

event (Tkinter.Event) –

Returns

None

class biometrics_tracker.gui.tk_gui.DataPointSelectionFrame(*args: Any, **kwargs: Any)

Bases: Frame, DataPointSelection

A GUI frame that collects selection criteria for retrieving DataPoints from the database

focus_set()

Delegate focus_set invocations to the first prompt on the display

Returns

None

get_date_range() None

If date range is part of the selection criteria, set the start date and end date properties from the Start Date and End Date widgets, otherwise set these properties to None

Returns

None

get_dp_type_selection() None

If DataPointType is part of the selection criteria, set the DataPointType property from the DataPointTypeComboWidget, otherwise set the property to None

Returns

None

get_person(msg: PersonMsg) None

If person is part of the selection criteria, set the selected Person ID property. This method is the callback routine for the PeopleListFrame

Parameters

msg (biometrics_tracker.ipc.messages.PersonMsg) – the Person instance retrieved from the database

Returns

None

class biometrics_tracker.gui.tk_gui.ExportFrame(*args: Any, **kwargs: Any)

Bases: Frame

A ttkbootstrap Frame that allows the entry of the information necessary to export a CSV or SQLite database file

browse_export_dir()

Presents a tk.filedialog to browse the file system and select a CSV file to be imported

Returns

None

focus_set()

Delegates the focus_set method calls to the Export Directory entry field

Returns

None

indexed_fields() dict[str, int]
Returns a dict[int, str] that has the field name as the key and the position within the Export file of the field

as the value. The field names are taken from the string values defined at the beginning of the model.importers module.

Returns

map of fields selected for export

Return type

dict[int, str]

save_export_spec()

This method is used as a callback for the Save Export Spec dialog. It collects the values of the entry prompts in the Frame, creates an instance of ExportSpec, places that instance in an instance of ExportSpecCollection and pickles the collection object

Returns

None

class biometrics_tracker.gui.tk_gui.ImportExportStatusDialog(*args: Any, **kwargs: Any)

Bases: MessageDialog

A ttkbootstrap.dialogs Dialog that displays status info for a completed import/export run

Returns

None

close_dialog()

Remove the Dialog from the screen. This method is invoked when the close button is pressed.

Returns

None

create_body(parent)

Overrides the create_body method of the base class. Builds the body of the Dialog

Parameters

parent (Tkinter derived Window or Frame) – the GUI parent for this Dialog

Returns

None

class biometrics_tracker.gui.tk_gui.NewDataPointFrame(*args: Any, **kwargs: Any)

Bases: Frame

A ttkbootstrap Frame that allows entry of a set of metrics for a particular date and time

class biometrics_tracker.gui.tk_gui.PeopleListFrame(*args: Any, **kwargs: Any)

Bases: Frame

A ttkbootstrap Frame containing a tk.Listbox that allows the selection of a person whose data is to be used in subsequent processes

focus_set()

Gives the Frame’s Listbox focus

Returns

None

Return type

None

selected_person() str

Returns the Person ID for the selected Listbox entry

Returns

person ID

Return type

str

class biometrics_tracker.gui.tk_gui.PersonFrame(*args: Any, **kwargs: Any)

Bases: Frame

A ttkbootstrap Frame that allows the entry of information associated with a person, including which metrics will be tracked for that person

class biometrics_tracker.gui.tk_gui.RunSchedulerFrame(*args: Any, **kwargs: Any)

Bases: Frame

Presents a window that allows the user to start a process that retrieves ScheduleEntry’s and uses the information to schedule jobs using the schedule library

show_scheduled_jobs(msg: SchedulerCompletionMsg) None

Displays a list of scheduled jobs after the SchedulerCompletionMsg is received

Parameters

msg (biometrics_tracking.ipc.messages.SchedulerCompletionMsg) – a message containing a list of schedule job

Returns

None

class biometrics_tracker.gui.tk_gui.SaveBiometricsReportFrame(*args: Any, **kwargs: Any)

Bases: Frame

Presents a ttkb.Frame that displays a Biometrics History Report and allows the user to save the report as a text or PDF file and optionally email the report to one or more recipients

disable_save()

Disables the save button

Returns

None

enable_save()

Enables the save button

Returns

None

no_print(msg: Optional[CompletionMsg] = None)

This method is invoked in response to the report completion message if the user did not request printing

Parameters

msg (biometrics_tracker.ipc.messages.CompletionMsg) – report completion message

Returns

None

save_report(text: StringIO, prt: bool)

Save the report to a file

Parameters
  • text (descendant of IOBase) – the destination for the save report

  • prt (bool) – did user request print

Returns

None

show_printer_dialog(msg: Optional[CompletionMsg] = None)

Open the report file in a browser so it can be printed via the browser print dialog

Parameters

msg (biometrics_tracker.ipc.messages.CompletionMsg) – report completion message

Returns

None

class biometrics_tracker.gui.tk_gui.ScheduledEntryWindow(*args: Any, **kwargs: Any)

Bases: Window, CoreLogic

This ttkbootstrap Window handles the scheduled entry of a single metric. The person is the person is the owner of the schedule entry and date is assumed to be the current date.

check_completion_queue()

Check the completion queue for messages, invoke the callback if a message is retrieved

Returns

None

check_response_queue()

Check the database response queue for messages, invoke the callback if a message is received.

Returns

None

close_db() None

Send a CloseDataBaseReqMsg to the database manager, with exit_app method as the reply_to Callable

Returns

None

exit_app(msg: CompletionMsg) None

Ends the GUI event loop

Parameters

msg – a Completion message, usually a response to a Close Database request

Returns

None

get_date() date

Returns the date the metric reading was taken

Returns

the date the metric reading was taken

Return type

datetime.date

get_time() time

Returns the time the metric reading was taken

Returns

the time the metric reading was taken

Return type

datetime.time

help_menu()

Displays the help table of contents in the system default browser

Returns

None

make_metric_widget(msg: PersonMsg)

A callback specified as the replyto Callable in the message sent by the run method

Parameters

msg (biometrics_tracker.ipc.messages.PersonMsg) – a message containing a Person instance

Returns

None

remove_child_frame(frame_class)
Removes a Frame of the specified class from the Window. This method is invoked when a application function is

complete or canceled

Parameters

frame_class (Class) – the class of the Frame to be removed (e.g. gui.PersonListFrame, gui.PersonFrame, gui.QuickEntryFrame)

Returns

None

run() None

This method is invoked when the ScheduledEntry thread is started. It sends a request to the persistance manager to retrieve the Person instance for the person associated with the scheduled job that invoked this class

Returns

None

submit()

A callback invoked when the Submit button is clicked

Returns

None

suspend_schedule()

A callback invoked when the Suspend this Schedule button is clicked

Returns

None

class biometrics_tracker.gui.tk_gui.UpcomingScheduledEventsFrame(*args: Any, **kwargs: Any)

Bases: Frame

This Frame prompts the user for start and end dates and displays the ScheduleEntry’s that will be triggered during the specified period

focus_set()

Delegate the focus_set method to the Starts On date widget

Returns

None

retrieve_schedules()

Issue a ScheduleEntryReqMsg to the database to retrieve the ScheduleEntry’s for a person

Returns

None

show_events()

Build a list of ScheduleEntry’s that will be triggered during the specified period and insert the contents into a ScrollableFrame

Returns

None

store_entries(msg: ScheduleEntriesMsg)

This method is used as the ‘replyto’ in the ScheduleEntryReqMsg’s sent by the retrieve_schedules method

Parameters

msg (biometrics_tracker.ipc.messages.ScheduleEntryMsg) – a message containing a list of ScheduleEntry’s retrieved from the database

Returns

None

class biometrics_tracker.gui.tk_gui.ViewEditBiometricsFrame(*args: Any, **kwargs: Any)

Bases: BiometricsFrameBase

A Frame that allows the edit and deletion of DataPoints

create_placeholder_widget() PlaceholderWidget

Create a placeholder widget to take up space until the user selects a DataPoint to edit

Returns

None

display_history(msg: DataPointRespMsg)

Create a entry prompts from the DataPoints history retrieved by the retrieve_history method

Parameters

msg – a response message containing a list of DataPoints

Returns

None

edit_datapoint(event)

A callback method to be invoked on the double click of a PayloadLabel entry in the list of retrieved DataPoints

Parameters

event (tkinter.Event) – the event generated by the double click

Returns

None

retrieve_history()

Retrieve the datapoints within the specified date range for the selected person and fill a ScrollableFrame with rows of widgets

Returns

None

save_datapoint()

A callback method that handles deletes and updates when the Save button is clicked