forked from foohyfooh/3ds-snes-sc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
104 lines (82 loc) · 3.04 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from tkinter import Tk, TOP, LEFT, mainloop, Label, LabelFrame, Button, filedialog, messagebox, Entry
from functions import ves_to_srm, srm_to_ves, os
root = Tk()
root.title('3DS SNES Save Converter')
root.resizable(False, False)
ves = None
srm = None
#
# GUI FUNCTIONS
#
def select_ves():
global ves
inputf = filedialog.askopenfilename(initialdir="/", title="Select .VES file", filetypes=((".VES File", "*.ves"), ("All files", "*.*")))
base = os.path.basename(inputf)
if os.path.splitext(base)[1].lower() == '.ves':
ves = inputf
else:
messagebox.showerror("Error: File not valid", "You must select a .VES File")
def select_srm():
global srm
inputf = filedialog.askopenfilename(initialdir="/", title="Select .SRM file", filetypes=((".SRM File", "*.srm"), ("All files", "*.*")))
base = os.path.basename(inputf)
if os.path.splitext(base)[1].lower() == '.srm':
srm = inputf
else:
messagebox.showerror("Error: File not valid", "You must select a .SRM File")
def convert_ves_to_srm():
if ves is not None:
output1['text'] = ves_to_srm(ves)
else:
output1['text'] = 'No file selected.'
def convert_srm_to_ves():
if srm is not None and gpid.get() != '':
if len(gpid.get()) == 4:
output2['text'] = srm_to_ves(srm, gpid.get())
else:
output2['text'] = 'Invalid GPID.'
else:
output2['text'] = 'Missing variable.'
#
# INFO
#
info = LabelFrame(root, text='Info', padx=5, pady=5)
info.grid(row=0, column=1, padx=10, pady=10, sticky='nsew')
infolbl = Label(info, text='3DS SNES Save Converter\ngithub.com/manuGMG/3ds-snes-sc', pady=12)
infolbl.pack(side=TOP)
#
# ACTIONS
#
actions = LabelFrame(root, text='Actions', padx=5, pady=5)
actions.grid(row=1, column=1, padx=10, pady=10, sticky='nsew')
output1 = Label(actions, text='(Output File)', padx=5)
output1.grid(row=0, column=1, sticky='nsew')
btn = Button(actions, text='VES to SRM', command=convert_ves_to_srm)
btn.grid(row=0, column=0, pady=3, sticky='nsew')
btn = Button(actions, text='SRM to VES', command=convert_srm_to_ves)
btn.grid(row=1, column=0, sticky='nsew')
output2 = Label(actions, text='(Output File)', padx=5)
output2.grid(row=1, column=1, sticky='nsew')
#
# VES TO SRM
#
frame = LabelFrame(root, text='Convert from .VES to .SRM', padx=5, pady=5)
frame.grid(row=0, column=0, padx=10, pady=10, sticky='nsew')
lbl = Label(frame, text='Select .VES File:')
lbl.pack(side=LEFT)
btn = Button(frame, text='Select..', width='7', command=select_ves)
btn.pack(side=LEFT)
#
# SRM TO VES
#
frame2 = LabelFrame(root, text='Convert from .SRM to .VES', padx=5, pady=5)
frame2.grid(row=1, column=0, padx=10, pady=10, sticky='nsew')
lbl = Label(frame2, text='Select .SRM File:')
lbl.grid(row=0, column=0, sticky='nsew')
btn = Button(frame2, text='Select..', width='7', command=select_srm)
btn.grid(row=0, column=1, pady=3, sticky='nsew')
lbl2 = Label(frame2, text='Game Preset ID:')
lbl2.grid(row=1, column=0, sticky='nsew')
gpid = Entry(frame2, width='7')
gpid.grid(row=1, column=1, sticky='nsew')
mainloop()