Skip to content

options_tab

Options tab builder.

build_options_tab(app, parent)

Build the options tab for NPV/chart settings.

Parameters:

Name Type Description Default
app RefinanceCalculatorApp

Application instance with option state.

required
parent Frame

Frame that hosts the options controls.

required
Source code in src/refi_calculator/gui/builders/options_tab.py
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
def build_options_tab(
    app: RefinanceCalculatorApp,
    parent: ttk.Frame,
) -> None:
    """Build the options tab for NPV/chart settings.

    Args:
        app: Application instance with option state.
        parent: Frame that hosts the options controls.
    """
    ttk.Label(parent, text="Application Options", font=("Segoe UI", 10, "bold")).pack(
        anchor=tk.W,
        pady=(0, 15),
    )

    options_frame = ttk.LabelFrame(parent, text="NPV & Chart Settings", padding=15)
    options_frame.pack(fill=tk.X, pady=(0, 10))

    add_option(
        options_frame,
        "NPV Window (years):",
        app.npv_window_years,
        0,
        "Time horizon for NPV calculation (e.g., 5 = 5-Year NPV)",
    )
    add_option(
        options_frame,
        "Chart Horizon (years):",
        app.chart_horizon_years,
        1,
        "How many years to display on the cumulative savings chart",
    )

    sens_frame = ttk.LabelFrame(parent, text="Sensitivity Analysis", padding=15)
    sens_frame.pack(fill=tk.X, pady=(0, 10))

    add_option(
        sens_frame,
        "Max Rate Reduction (%):",
        app.sensitivity_max_reduction,
        0,
        "How far below current rate to analyze (e.g., 2.0 = current - 2%)",
    )
    add_option(
        sens_frame,
        "Rate Step (%):",
        app.sensitivity_step,
        1,
        "Increment between rate scenarios (e.g., 0.25)",
    )

    ttk.Button(parent, text="Apply & Recalculate", command=app._calculate).pack(pady=15)
    ttk.Label(
        parent,
        text="Changes take effect after clicking 'Apply & Recalculate' or running a new calculation.",
        font=("Segoe UI", 8),
        foreground="#666",
    ).pack(anchor=tk.W)