Mercurial > msvpvf
comparison gui.py @ 11:2ec81711f0c7
Move python files to this repo
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 26 Jan 2022 20:36:07 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 11:2ec81711f0c7 |
---|---|
1 import tkinter | |
2 import tkinter.filedialog | |
3 import msvpvf | |
4 import os | |
5 | |
6 def round_down(num, divisor): | |
7 return num - (num%divisor) | |
8 | |
9 def open_veg_file(): | |
10 filepath.set(tkinter.filedialog.askopenfilename(title="Select project file", filetypes=[("Project files", ".veg .vf"), ("All Files", "*.*")])) | |
11 with open(filepath.get(), 'rb') as file: | |
12 version_of_file.set("Project file version: %s" % (str(bytearray(file.read())[0x46]))) | |
13 window.update_idletasks() | |
14 # eventually add shit here | |
15 | |
16 def save_veg_file(): | |
17 with open(filepath.get(), 'rb') as f: | |
18 path = bytearray(f.read()) | |
19 for i in listbox.curselection(): | |
20 prefix, data = msvpvf.type_hex(i) | |
21 path[0x18:0x27] = data | |
22 path[0x46] = int(default_version.get()) | |
23 outputfn = prefix + "_V" + default_version.get() + "_" + os.path.basename(os.path.splitext(filepath.get())[0]) | |
24 outputfn += ".vf" if prefix == "MS" else ".veg" | |
25 name = tkinter.filedialog.asksaveasfilename(defaultextension='.vf' if prefix == "MS" else '.veg', initialfile=outputfn, filetypes=[("Project files", ".veg .vf"), ("All Files", "*.*")]) | |
26 with open(name, 'wb') as f: | |
27 f.write(path) | |
28 | |
29 | |
30 window = tkinter.Tk() | |
31 window.geometry("225x200") | |
32 | |
33 filepath = tkinter.StringVar(window) | |
34 version_of_file = tkinter.StringVar(window) | |
35 selected_version = tkinter.IntVar() | |
36 | |
37 | |
38 button = tkinter.Button(text="Open", command=open_veg_file) | |
39 button.pack(pady=5) | |
40 list_items = tkinter.StringVar(value=("VEGAS Pro", "Movie Studio")) | |
41 listbox = tkinter.Listbox(window, height=2, listvariable=list_items) | |
42 listbox.select_set(0) | |
43 listbox.pack(pady=5) | |
44 | |
45 supported_versions = ["8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"] | |
46 default_version = tkinter.StringVar() | |
47 default_version.set(supported_versions[3]) | |
48 | |
49 menu = tkinter.OptionMenu(window, default_version, *supported_versions) | |
50 menu.pack(pady=5) | |
51 button = tkinter.Button(text="Save", command=save_veg_file) | |
52 button.pack(pady=5) | |
53 | |
54 tkinter.Label(window, textvariable=version_of_file).pack(pady=5) | |
55 window.title("msvpvf") | |
56 window.minsize(225, 200) | |
57 | |
58 window.mainloop() |