Debug and optimize and check the debugged code again when it always gibes me the error…
- User
Debug and optimize and check the debugged code again when it always gibes me the error SyntaxError: invalid character ‘‘’ (U+2018). After Optimizing and proof-reading again give out the code and a table what you have optimized and why: import tkinter as tk from tkinter import ttk from tkinter import messagebox import pickle
class MRIProtocolsApp(tk.Tk): def init(self): super().init() self.title(‘MRI Protocols’) self.protocol_data_file = ‘protocols.pkl’
self.init_gui() self.load_protocols()
def init_gui(self): self.sequence_types = [‘T1’, ‘T2’, ‘PD’, ‘DWI’, ‘SWI’, ‘T2 FLAIR’, ‘Other’] self.orientations = [‘Transverse’, ‘Sagittal’, ‘Coronal’, ‘Other’]
self.main_frame = ttk.Frame(self) self.main_frame.grid(column=0, row=0, sticky=(tk.W, tk.N, tk.E, tk.S)) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1)
Protocol list frame
self.protocol_list_frame = ttk.Frame(self.main_frame) self.protocol_list_frame.grid(column=0, row=0, padx=10, pady=10)
ttk.Label(self.protocol_list_frame, text=‘Saved Protocols:’).grid(column=0, row=0) self.protocol_list = tk.Listbox(self.protocol_list_frame) self.protocol_list.grid(column=0, row=1, sticky=(tk.W, tk.N, tk.E, tk.S)) self.protocol_list.bind(’<>‘, self.update_protocol_view)
Add protocol button
ttk.Button(self.protocol_list_frame, text=‘Add Protocol’, command=self.new_protocol_window).grid(column=0, row=2, pady=10)
Sequence protocol view frame
self.protocol_view_frame = ttk.Frame(self.main_frame) self.protocol_view_frame.grid(column=1, row=0, padx=10, pady=10, sticky=(tk.W, tk.E, tk.N, tk.S))
ttk.Label(self.protocol_view_frame, text=‘Protocol Name:’).grid(column=0, row=0, sticky=(tk.W)) self.protocol_name_var = tk.StringVar() self.protocol_name_entry = ttk.Entry(self.protocol_view_frame, textvariable=self.protocol_name_var) self.protocol_name_entry.grid(column=1, row=0, sticky=(tk.W, tk.E))
ttk.Label(self.protocol_view_frame, text=‘Sequences:’).grid(column=0, row=1, sticky=(tk.W)) self.sequence_tree = ttk.Treeview(self.protocol_view_frame, height=8, columns=3) self.sequence_tree.grid(column=1, row=1, sticky=(tk.W, tk.E, tk.N, tk.S)) self.sequence_tree.column(“#0”, width=0, stretch=tk.NO) self.sequence_tree.column(1, width=150, minwidth=100) self.sequence_tree.column(2, width=150, minwidth=100) self.sequence_tree.column(3, width=150, minwidth=100) self.sequence_tree.heading(1, text=‘Sequence Type’) self.sequence_tree.heading(2, text=‘Orientation’) self.sequence_tree.heading(3, text=‘Annotation’)
Save button
ttk.Button(self.protocol_view_frame, text=‘Save Protocol’, command=self.save_protocol).grid(column=1, row=2, pady=10, sticky=(tk.E))
def update_protocol_view(self, event=None): if self.protocol_list.curselection(): selected_protocol_index = self.protocol_list.curselection()[0] protocol = self.protocols[selected_protocol_index]
- Assistant