Using the Command-Line Interface (CLI)
The Tkinter Designer CLI provides a fast and scriptable way to generate GUI code directly from your terminal.
Command Syntax
The basic structure of the command is as follows:
tkdesigner <file_url> <token> [options]
Positional Arguments
These two arguments are required and must be provided in order.
-
file_url
- Description: The full URL of the Figma design file you want to convert.
- Example:
"https://www.figma.com/file/ABC123XYZ/MyDesign"
-
token
- Description: Your Figma Personal Access Token required for API authentication.
- Example:
"12345-abcdef-67890-ghijk"
Note: It's good practice to wrap the URL and token in double quotes (
""
) to prevent shell interpretation issues with special characters.
Optional Arguments (Options)
These flags can be added to customize the command's behavior.
-
-o, --output <PATH>
- Description: Specifies the directory where the output files will be saved. If not provided, it defaults to the current working directory.
- Example:
-o ./my-projects/my-app
-
-f, --force
- Description: If the specified output directory already exists and is not empty, this flag will force the tool to overwrite its contents. Without this flag, you will be prompted for confirmation before overwriting.
- Example:
-f
Practical Example
Here is a complete command demonstrating how to generate a GUI project:
tkdesigner \
"https://www.figma.com/file/WVLnulVsI177tvnxSdqOUZ/Untitled?node-id=0%3A1" \
"figd_oF......................................" \
-o ./my-app
What Happens Next?
After running the command, Tkinter Designer will:
1. Create the directory ./my-app
if it doesn't exist.
2. Inside it, create a build
directory (./my-app/build
).
3. Save the generated Python file(s) (e.g., gui.py
) inside build
.
4. Create an assets
directory inside build
(e.g., ./my-app/build/assets/frame0
) and save all the required image assets there.
A success message will be printed to the console, confirming the output location:
Project successfully generated at /path/to/your/project/my-app/build.
You can then navigate to this directory and run your application:
cd ./my-app/build
python gui.py