[Python] Design & build airplanes from your specifications.
1
import creator
2
import evaluator
3
import generator
4
import tkinter as tk
5
import tkinter.ttk as ttk
6
7
from matplotlib.backends.backend_tkagg import (
8
FigureCanvasTkAgg, NavigationToolbar2Tk)
9
10
11
class MainWindow(tk.Frame):
12
"""Main editor window."""
13
14
def __init__(self, *args, **kwargs):
15
tk.Frame.__init__(self, *args, **kwargs)
16
root = tk.Tk()
17
root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization')
18
19
# self.button = tk.Button(self, text="Create new window",
20
# command=self.create_window)
21
# self.button.pack(side="top")
22
frame_1 = ttk.Frame(root)
23
l_naca, e_naca = new_field(frame_1, 'naca')
24
l_chord, e_chord = new_field(frame_1, 'chord')
25
l_semi_span, e_semi_span = new_field(frame_1, 'semi_span')
26
# af = creator.base.Aircraft.from_defaults()
27
# Graph window
28
frame_2 = ttk.Frame(root)
29
# fig, ax = creator.plot_geom(af, False)
30
# plot = FigureCanvasTkAgg(fig, frame_2)
31
# plot.draw()
32
# toolbar = NavigationToolbar2Tk(plot, frame_2)
33
# toolbar.update()
34
35
l_naca.grid(row=0, column=0)
36
e_naca.grid(row=0, column=1, padx=4)
37
# b_naca.grid(row=0, column=2)
38
l_chord.grid(row=1, column=0)
39
e_chord.grid(row=1, column=1, padx=4)
40
l_semi_span.grid(row=2, column=0, padx=4)
41
e_semi_span.grid(row=2, column=1, padx=4)
42
frame_1.pack(side=tk.LEFT)
43
# Graph window
44
# plot.get_tk_widget().pack(expand=1, fill=tk.BOTH)
45
# toolbar.pack()
46
frame_2.pack(side=tk.LEFT)
47
48
def create_window(self):
49
self.counter += 1
50
window = tk.Toplevel(self)
51
window.wm_title("Window #%s" % self.counter)
52
label = tk.Label(window, text="This is window #%s" % self.counter)
53
label.pack(side="top", fill="both", expand=True, padx=100, pady=100)
54
55
56
def new_field(parent, name):
57
"""Add a new user input field."""
58
59
label = ttk.Label(parent, text=name)
60
entry = ttk.Entry(parent)
61
return label, entry
62
63
64
def set_naca(name):
65
naca_num = name.get()
66
print(naca_num)
67
68
69
def set_chord(name):
70
chord = name.get()
71
print(chord)
72
73
74
def set_semi_span(name):
75
semi_span = name.get()
76
print(semi_span)
77
78
79
# plot.get_tk_widget().pack()
80
MainWindow().mainloop()
81