-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
103 lines (88 loc) · 3.47 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import enum
import PySimpleGUI as SGui
def create_field(name, default, key=None, two_fields=False, length=6):
input_key = key
if input_key is None:
input_key = name
text = SGui.Text(name)
field1 = SGui.Input(size=(length, None), default_text=default, key=input_key)
if not two_fields:
return text, field1
return text, field1, SGui.Input(size=(length, None), default_text=default, key=input_key + "_2")
def create_combo(name, values, key=None):
input_key = key
if input_key is None:
input_key = name
return SGui.Text(name), SGui.Combo(values, default_value=values[0], key=input_key)
class Layout(enum.Enum):
VanDerPol = 1
Rossler = 2
NoseHoover = 3
Lorens = 4
def create_layout(selected_layout):
layout_name = str(selected_layout)
x_text, x_field = create_field("x", 1, "x_" + layout_name)
y_text, y_field = create_field("y", 1, "y_" + layout_name)
z_text, z_field = create_field("z", 1, "z_" + layout_name)
mu_text, mu_field = create_field("μ", 1)
a_text, a_field, a2_field = create_field("a", 0.2, "a_" + layout_name, True)
b_text, b_field, b2_field = create_field("b", 0.2, two_fields=True)
c_default = 0
if selected_layout == Layout.Rossler:
c_default = 5.7
c_text, c_field, c2_field = create_field("c", c_default, "c_" + layout_name, two_fields=True)
if selected_layout == Layout.VanDerPol:
return [
[x_text, x_field],
[y_text, y_field],
[mu_text, mu_field]
]
if selected_layout == Layout.NoseHoover:
return [
[x_text, x_field, a_text, a_field, a2_field],
[y_text, y_field, c_text, c_field, c2_field],
[z_text, z_field]
]
return [ # Rossler
[x_text, x_field, a_text, a_field, a2_field],
[y_text, y_field, b_text, b_field, b2_field],
[z_text, z_field, c_text, c_field, c2_field]
]
def create_sync_layout(selected_layout):
layout_name = str(selected_layout)
x_text, x_field, x2_field = create_field("x", 1, "x_" + layout_name, True)
y_text, y_field, y2_field = create_field("y", 1, "y_" + layout_name, True)
z_text, z_field, z2_field = create_field("z", 1, "z_" + layout_name, True)
a_text, a_field = create_field("a", 0.2, "a_" + layout_name)
b_text, b_field = create_field("b", 0.2)
c_default = 0
if selected_layout == Layout.Rossler:
c_default = 5.7
c_text, c_field = create_field("c", c_default, "c_" + layout_name)
sigma_text, sigma_field = create_field("σ", 10)
ro_text, ro_field = create_field("ρ", 28)
beta_text, beta_field = create_field("β", 2.67)
if selected_layout == Layout.NoseHoover:
return [
[x_text, x_field, x2_field, a_text, a_field],
[y_text, y_field, y2_field, c_text, c_field],
[z_text, z_field, z2_field]
]
if selected_layout == Layout.Lorens:
return [
[x_text, x_field, x2_field, sigma_text, sigma_field],
[y_text, y_field, y2_field, ro_text, ro_field],
[z_text, z_field, z2_field, beta_text, beta_field]
]
return [ # Rossler
[x_text, x_field, x2_field, a_text, a_field],
[y_text, y_field, y2_field, b_text, b_field],
[z_text, z_field, z2_field, c_text, c_field]
]
def get_float(vals, key):
try:
return float(vals[key])
except (ValueError, KeyError):
return .0
def get_int(vals, key):
return int(vals[key])