5m4ck3r commited on
Commit
89d8358
1 Parent(s): f083c5c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import subprocess
4
+ import zipfile
5
+ from pathlib import Path
6
+
7
+ def process_figma(figma_url, figma_token):
8
+ if not Path("Tkinter-Designer").exists():
9
+ subprocess.run(["git", "clone", "https://github.com/ParthJadhav/Tkinter-Designer.git"], check=True)
10
+ print("Cloning to the github repo")
11
+
12
+ os.chdir("Tkinter-Designer")
13
+ conversion_command = [
14
+ "python",
15
+ "-m",
16
+ "tkdesigner.cli",
17
+ figma_url,
18
+ figma_token
19
+ ]
20
+
21
+ subprocess.run(conversion_command, check=True)
22
+ zip_file_path = "output.zip"
23
+ with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
24
+ for foldername, subfolders, filenames in os.walk("build"):
25
+ for filename in filenames:
26
+ filepath = os.path.join(foldername, filename)
27
+ zip_file.write(filepath, os.path.relpath(filepath, "build"))
28
+
29
+ return zip_file_path
30
+
31
+ iface = gr.Interface(
32
+ fn=process_figma,
33
+ inputs=["text", "text"],
34
+ outputs="file",
35
+ title="Figma to Tkinter Converter",
36
+ description="Upload your Figma design by providing the URL and token."
37
+ )
38
+
39
+ if __name__ == "__main__":
40
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ gitpython
3
+ audioop