Spaces:
Running
Running
File size: 1,214 Bytes
89d8358 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
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()
|