figma2tkinter / app.py
5m4ck3r's picture
Upload 2 files
89d8358 verified
raw
history blame
1.21 kB
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="Upload your Figma design by providing the URL and token."
)
if __name__ == "__main__":
iface.launch()