-
-
Notifications
You must be signed in to change notification settings - Fork 0
Object References
Typed widget pointers for behavior code. A reference gives a widget — or a whole window — a stable Python name that handlers can reach without scraping the widget tree.
| Scope | What it points at | Where it lives |
|---|---|---|
| Local | An inner widget (Button, Entry, Frame…) | The owning form |
| Global | A whole Window or Dialog | The project |
The two share one UUID pool so renames are safe — bindings reference the UUID, the user-facing name is just a label.
Scope is enforced by target type. A Window/Dialog can only be a global reference; an inner widget can only be a local reference. The Properties panel toggle picks the right scope for you.
F11 opens the Data window. Click the Object References tab (third column).
The tab shows every reference in the project — local refs grouped under their owning form, plus globals (Window/Dialog targets).
Select an inner widget. In the Properties Panel, flip the Object Reference toggle on. CTkMaker auto-suggests a name from the widget's user-facing name (or <type>_ref if the name isn't a valid identifier); collisions get a _2 / _3 suffix.
Right-click the empty canvas → Window/Dialog Properties. In the Properties panel, flip the Window-Global Reference toggle on. The whole form becomes reachable from any other form's Event Handlers.
The exporter wires every reference into the behavior class right after _build_ui() returns and before setup() is called. Inside the behavior class, just use self.<ref_name>:
class LoginPage:
def setup(self, window):
# self.submit_button is already wired — safe to use here
self.submit_button.configure(state="disabled")
def on_submit(self):
self.submit_button.configure(state="normal")Globals resolve to the target class, not an instance — opening the window means calling the class:
class LoginPage:
def setup(self, window):
self.window = window
def on_open_settings(self):
self.settings_dialog(self.window) # instantiate the ToplevelThe Object References tab supports rename and delete. Rename the user-facing name freely — the UUID is the identity, so existing bindings keep working. Generated code regenerates against the new name on export.
A reference declared by hand (added in the Object References tab without picking a target) has an empty target_id. The exporter silently skips it, so the generated .py stays runnable while you finish wiring it up.
Pre-1.11 projects with the older "behavior fields" data are migrated automatically on open — no manual step required.
See also — Variables · Event Handlers · Properties Panel · Window Properties