import gradio as gr import os import subprocess import zipfile from pathlib import Path def process_figma(figma_url, figma_token): if not Path("Tkinter-Designer").exists(): subprocess.run(["git", "clone", "https://github.com/ParthJadhav/Tkinter-Designer.git"], check=True) print("Cloning to the github repo") os.chdir("Tkinter-Designer") conversion_command = [ "python", "-m", "tkdesigner.cli", figma_url, figma_token ] subprocess.run(conversion_command, check=True) zip_file_path = "output.zip" with zipfile.ZipFile(zip_file_path, 'w') as zip_file: for foldername, subfolders, filenames in os.walk("build"): for filename in filenames: filepath = os.path.join(foldername, filename) zip_file.write(filepath, os.path.relpath(filepath, "build")) return zip_file_path iface = gr.Interface( fn=process_figma, inputs=["text", "text"], outputs="file", title="Figma to Tkinter Converter", description="" ) description = gr.Markdown( """ Upload your Figma design by providing the URL and token.
### Naming is Important | Figma Element Name | Tkinter Element | | --- | --- | | Button | Button | | Line | Line | | Text | Name it anything | | Rectangle | Rectangle | | TextArea | Text Area | | TextBox | Entry | | Image | Canvas.Image() | | ButtonHover (EXPERIMENTAL) | Button shown on hover |
**NOTE** : This project is created by : ParthJadhav Checkout this repo to know more : [GitHub Repo](https://github.com/ParthJadhav/Tkinter-Designer) """ ) iface.launch()