Report window

Display a session-usage report in a Tkinter window.

Duration formatting


source

fmt_duration

def fmt_duration(
    seconds
):

Format a duration in seconds as whole minutes and seconds.

Application summary table


source

show_apps

def show_apps(
    root, report_data
):

Create and populate the foreground-application summary table.

Session summary


source

show_summary

def show_summary(
    root, report_data
):

Add the session summary fields to the report window.

Selected-app title details


source

update_titles

def update_titles(
    title_tree, report_data, app_tree
):

Replace title-table rows with title durations for the selected app.


source

show_titles

def show_titles(
    root
):

Create the table used to show titles for the selected application.

Report window lifecycle


source

show_report

def show_report(
    parent, report_data, report_title:str='Usage Report', is_show_titles:bool=True
):

Open a report as a child of the application’s Tk root.

  1. Report-data shape: this module treats report_data[“events”] as a list of app-summary dictionaries. The project context describes a preferred future structure where “events” is a dictionary containing “top_apps”, “titles_by_app”, and “timeline”. Confirm the reporter’s current return shape before documenting that structure more specifically.

  2. Title-data availability: update_titles assumes every app event has a “top_titles” key, including any idle event. Confirm whether idle rows include that key or whether they should be excluded from title-detail display.

  3. Configuration default timing: is_show_titles = cf.SHOW_WINDOW_TITLES is evaluated when the function is defined, rather than when it is called. That is valid for a static configuration setting, but it will not reflect changes to cf.SHOW_WINDOW_TITLES made later in the same process.