Skip to content

Exporting Code

Lasha Kandelaki edited this page May 17, 2026 · 8 revisions

Exporting Code

Generate a runnable Python file from your design.

Run export

File → Export Python — pick a destination .py (or .zip).

Output

The export writes a single Python file alongside an assets/ folder for any images/fonts your design references.

Document Becomes
First document ctk.CTk subclass — the __main__ entry point
Other documents ctk.CTkToplevel subclasses — open from your code with MyDialog(self)

If your design uses the enhanced dropdown, a scrollable_dropdown.py helper is copied next to the output file.

Properties bound to a Variables become shared tk.StringVar / IntVar / DoubleVar / BooleanVar instances at the top of the generated class — clean two-way data flow with no extra wiring.

Behavior files

Forms with bound Event Handlers also import their behavior file:

from assets.scripts.<page>.<window> import <Class>Pageself._behavior = <Class>Page()
self._behavior.setup(self)

Each event becomes either:

  • command=self._behavior.method_name (single action) or command=lambda: (self._behavior.m1(), self._behavior.m2()) (multi-action chain) — for command= events
  • widget.bind(seq, self._behavior.method_name, add="+") — for bind-style events (<Return>, <FocusOut>, …)

The assets/scripts/ folder is copied next to the output .py (or zipped with it) — this includes both the per-window behavior files and any library scripts (helpers.py, sub-packages, etc.) that behavior files import.

Options

  • Open in editor after export
  • Run preview after export
  • Export as .zip archive (Python file + assets/ + helper, all in one)

See alsoWindows and Dialogs · Event Handlers · Python Import

Clone this wiki locally