-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
68 lines (56 loc) · 2.31 KB
/
gui.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import conversion_utils
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import logging
logger = logging.getLogger(__name__)
def select_pac():
tk.Tk().withdraw()
pac_filename = tk.filedialog.askopenfilename(title="Select a .pac file",
filetypes=[("Pac files", "*.pac"), ("All Files", "*.*")])
if pac_filename != "":
try:
conversion_utils.convert_files(pac_filename, "")
except Exception as e:
logger.critical(f"There was an issue converting {pac_filename}")
logger.critical(e)
def select_mpc():
tk.Tk().withdraw()
mpc_filename = tk.filedialog.askopenfilename(title="Select a .mpc file",
filetypes=[("Mpc files", "*.mpc"), ("All Files", "*.*")])
if mpc_filename != "":
try:
conversion_utils.convert_files("", mpc_filename)
except Exception as e:
logger.critical(f"There was an issue converting {mpc_filename}")
logger.critical(e)
def select_folder():
tk.Tk().withdraw()
folder_path = tk.filedialog.askdirectory()
if folder_path != "":
try:
conversion_utils.convert_folder(folder_path)
except Exception as e:
logger.warning(f"Exception caught: {e}")
pass
conversion_utils.display_results()
def init_interface():
root = tk.Tk()
root.title("UFC Undiputed 3 Model Converter")
root.geometry("530x100")
root.resizable(False, False)
style = ttk.Style()
style.configure("TButton",
font=("Arial", 12),
padding=10,
relief="flat",
foreground="black",
background="black")
button_pac = ttk.Button(root, text="Select a .pac file", style="TButton", command=select_pac)
button_pac.grid(row=1, column=0, padx=10, pady=15)
button_mpc = ttk.Button(root, text="Select a .mpc file", style="TButton", command=select_mpc)
button_mpc.grid(row=1, column=1, padx=10, pady=15)
button_folder = ttk.Button(root, text="Select a folder", style="TButton", command=select_folder)
button_folder.grid(row=1, column=2, padx=10, pady=15)
root.protocol("WM_DELETE_WINDOW", lambda: root.quit())
root.mainloop()