Coverage for / opt / hostedtoolcache / Python / 3.12.13 / x64 / lib / python3.12 / site-packages / fcp7xml_to_unreal / xml_ui.py: 99%
75 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-17 22:47 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-17 22:47 +0000
1import tkinter as tk
2from tkinter import DISABLED, END, NORMAL, RIGHT, Toplevel, filedialog, messagebox, ttk
4from fcp7xml_to_unreal import __version__
5from fcp7xml_to_unreal.models.Episode import Episode
6from fcp7xml_to_unreal.xml_helpers.reports import (
7 audio_report,
8 cgfixes_report,
9 conform_report,
10)
13class xmlUI:
14 def __init__(
15 self,
16 root=None,
17 frm=None,
18 xml_file_string="",
19 episode=None,
20 xml_functions=None,
21 ):
22 if xml_functions is None:
23 xml_functions = []
24 self.root = root
25 self.frm = frm
26 self.xml_file_string = xml_file_string
27 self.current_episode = episode
28 self.xml_functions = xml_functions
30 def output_audio(self):
31 output = audio_report(self.current_episode)
32 if output is not None:
33 self.show_output(output)
35 def output_cgfixes(self):
36 self.show_output(cgfixes_report(self.current_episode))
38 def output_conform(self):
39 self.show_output(conform_report(self.current_episode))
41 def output_filtered_xml(self):
42 self.current_episode.write_filtered()
44 def create_button(self, label, function):
45 button = ttk.Button(self.frm, text=label, command=function)
46 button.grid(column=len(self.xml_functions), row=2)
47 button.config(state=DISABLED)
48 self.xml_functions.append(button)
50 def xml_to_episode(self):
51 xml_path = filedialog.askopenfilename(
52 title="Choose XML to use", filetypes=[("XMLs", "*.xml")]
53 )
54 if not xml_path:
55 messagebox.showinfo("Info", "No XML file selected.")
56 return
58 # try:
59 self.xml_file_string.set(xml_path)
60 self.current_episode = Episode(xml_path)
61 for button in self.xml_functions:
62 button.config(state=NORMAL)
64 report_output = "Ingest logs:\n\n"
65 report_output += self.current_episode.ingest_log
66 report_output += "\n\n"
68 report_output += "Conform Report:\n\n"
69 report_output += conform_report(self.current_episode)
70 report_output += "\n\n"
72 report_output += "CG Fixes Report:\n\n"
73 report_output += cgfixes_report(self.current_episode)
74 report_output += "\n\n"
76 self.show_output(report_output)
77 # except Exception as e:
78 # messagebox.showerror("Error", f"Could not process XML file:\n{e}")
80 def show_output(self, output):
81 if len(output) == 0:
82 output = "No errors found!"
83 new_window = Toplevel(self.root)
84 new_window.title("Output")
86 scroll = tk.Scrollbar(new_window, orient="vertical")
87 scroll.pack(side=RIGHT, fill="y")
89 msg = tk.Text(new_window, yscrollcommand=scroll.set)
90 msg.insert(END, output)
92 scroll.config(command=msg.yview)
93 msg.pack(side="top", fill="both", expand="True")
96def main():
97 root = tk.Tk()
98 root.resizable(True, True)
99 root.title(f"fcp7xml-to-unreal v{__version__}")
100 frm = ttk.Frame(root, padding=10)
101 frm.grid()
103 xml_file_string = tk.StringVar()
104 xml_file_string.set("Please choose an XML file")
106 xml_ui = xmlUI(root=root, frm=frm, xml_file_string=xml_file_string)
108 xml_ui.create_button("Show Audio report CSV", xml_ui.output_audio)
109 # xml_ui.create_button("CG Fixes report", xml_ui.output_cgfixes)
110 # xml_ui.create_button("Conform report", xml_ui.output_conform)
111 xml_ui.create_button("Output filtered XML", xml_ui.output_filtered_xml)
113 tk.Entry(frm, textvariable=xml_file_string, width=100).grid(
114 column=0, row=0, sticky="news", columnspan=len(xml_ui.xml_functions)
115 )
117 ttk.Button(frm, text="Choose an xml", command=xml_ui.xml_to_episode).grid(
118 column=len(xml_ui.xml_functions), row=0
119 )
121 root.mainloop()
124if __name__ == "__main__":
125 main()