# Set up the main window
root = tk.Tk()
root.title("90 degree bend simulator")
root.configure(bg="white")
root.resizable(False, False)
# add a combo box for substrate material selection
substrate_label = tk.Label(root, text="Substrate material:", bg="white")
substrate_label.grid(column=0, row=0, sticky="E")
substrate_box = ttk.Combobox(root, values=materials, width=8)
substrate_box.grid(column=1, row=0, sticky="W")
substrate_box.current(1)
# add a combo box for cladding material selection
cladding_label = tk.Label(root, text="Cladding material:", bg="white")
cladding_label.grid(column=0, row=1, sticky="E")
cladding_box = ttk.Combobox(root, values=materials, width=8)
cladding_box.grid(column=1, row=1, sticky="W")
cladding_box.current(3)
# add a combo box for waveguide material selection
wg_label = tk.Label(root, text="Waveguide material:", bg="white")
wg_label.grid(column=0, row=2, sticky="E")
wg_box = ttk.Combobox(root, values=materials, width=8)
wg_box.grid(column=1, row=2, sticky="W")
wg_box.current(0)
# add a combo box for bend shape selection
shape_label = tk.Label(root, text="Bend shape:", bg="white")
shape_label.grid(column=0, row=3, sticky="E")
shape_box = ttk.Combobox(root, values=shapes, width=8)
shape_box.grid(column=1, row=3, sticky="W")
shape_box.current(0)
# add a label and a input box for waveguide width
width_label = tk.Label(root, text="Waveguide width (nm):", bg="white")
width_label.grid(column=2, row=0, sticky="E")
width_box = tk.Entry(root, width=6)
width_box.grid(column=3, row=0, sticky="W")
width_box.insert(0, "500")
# add a label and a input box for waveguide thickness
thickness_label = tk.Label(root, text="Waveguide thickness (nm):", bg="white")
thickness_label.grid(column=2, row=1, sticky="E")
thickness_box = tk.Entry(root, width=6)
thickness_box.grid(column=3, row=1, sticky="W")
thickness_box.insert(0, "220")
# add a label and a input box for waveguide radius
radius_label = tk.Label(root, text="Bend radius (um):", bg="white")
radius_label.grid(column=2, row=2, sticky="E")
radius_box = tk.Entry(root, width=6)
radius_box.grid(column=3, row=2, sticky="W")
radius_box.insert(0, "5")
# add a label and a input box for central wavelength
lda0_label = tk.Label(root, text="Central wavelength (nm):", bg="white")
lda0_label.grid(column=2, row=3, sticky="E")
lda0_box = tk.Entry(root, width=6)
lda0_box.grid(column=3, row=3, sticky="W")
lda0_box.insert(0, "1550")
# add a label and a input box for bandwidth
bw_label = tk.Label(root, text="Bandwidth (nm):", bg="white")
bw_label.grid(column=2, row=4, sticky="E")
bw_box = tk.Entry(root, width=6)
bw_box.grid(column=3, row=4, sticky="W")
bw_box.insert(0, "50")
# add a button for viewing simulation
view_button = tk.Button(root, text="View simulation", command=plot_sim)
view_button.grid(column=0, row=5, sticky="E")
# add a button for running simulation
run_button = tk.Button(root, text="Run simulation", command=plot_result)
run_button.grid(column=2, row=5, sticky="E")
# add a plot for xy cross section
fig1, ax1 = plt.subplots(figsize=(3, 3), tight_layout=True)
xy_canvas = FigureCanvasTkAgg(fig1, master=root)
xy_canvas_widget = xy_canvas.get_tk_widget()
xy_canvas_widget.grid(column=0, row=6, columnspan=2)
plt.close(fig1)
# add a plot for bending loss spectrum
fig2, ax2 = plt.subplots(figsize=(5, 3), tight_layout=True)
result_canvas = FigureCanvasTkAgg(fig2, master=root)
result_canvas_widget = result_canvas.get_tk_widget()
result_canvas_widget.grid(column=2, row=6, columnspan=2)
plt.close(fig2)
# add a plot for yz cross section
fig3, ax3 = plt.subplots(figsize=(3, 3), tight_layout=True)
yz_canvas = FigureCanvasTkAgg(fig3, master=root)
yz_canvas_widget = yz_canvas.get_tk_widget()
yz_canvas_widget.grid(column=0, row=7, columnspan=2)
plt.close(fig3)
# add a text box to display information
text_widget = tk.Text(root, height=12, width=1)
text_widget.grid(column=2, row=7, columnspan=2, sticky="ew")
default_text = "Click `View simulation` to view the simulation setup.\n"
text_widget.insert("1.0", default_text)