Skip to content

Variables

Lasha Kandelaki edited this page May 1, 2026 · 3 revisions

Variables

Shared values widgets can bind to. Change one variable, every bound widget updates live. Two scopes: global (project-wide) and local (per form).

Variables window

Open the Variables window

F11 or View → Variables.

The window has two tabs:

Tab Scope Visible to
Global Whole project Every widget in every form
Local: <form-name> The active form only Widgets inside that form

The Local tab follows the active document — switch forms and the tab relabels.

Types

Type Tk runtime Use for
str tk.StringVar text labels, entries, dropdown values
int tk.IntVar counts, indices
float tk.DoubleVar sliders, progress
bool tk.BooleanVar switches, checkboxes

Add / Rename / Delete

Toolbar buttons in the Variables window. Renaming is safe — bindings reference the variable's UUID, not its name.

Bind a widget property

In the Properties panel, click the in a row's left gutter to bind that property to a variable. Bound rows show + an orange tint; the on the right unbinds.

The diamond's color tells you the scope:

  • 🔵 Blue ◆ — bound to a global variable
  • 🟠 Orange ◆ — bound to a local variable

Binding a property

Updates propagate live: typing into one Entry mirrors instantly into every Label / Switch / Slider sharing the variable.

Cross-form moves

Dragging or pasting a widget from one form to another can break local-variable bindings (the target form doesn't own those vars). When that happens, a Reparent Variables dialog opens with two choices:

Source Target
Keep the originals Duplicate them in the target form (or reuse a same-name match)
Delete the originals Unbind the moved widgets

Cancel aborts the whole move.

Export

Globals declare on the main window class as self.var_X; Toplevels read them as self.master.var_X. Locals declare on their owning class. Either way, every bound property becomes a shared tk.Variable — no extra wiring.


See alsoProperties Panel · Exporting Code · Keyboard Shortcuts

Clone this wiki locally