-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathConfigPanel.py
More file actions
258 lines (169 loc) · 10.4 KB
/
Copy pathConfigPanel.py
File metadata and controls
258 lines (169 loc) · 10.4 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# All works in this code have been curated by ECCC and licensed under the GNU General Public License v3.0.
# Read more: https://www.gnu.org/licenses/gpl-3.0.en.html
# Get the GUI stuff
import wx
import sys
# We're going to be handling files and directories
import os
class ConfigPanel(wx.Frame):
def __init__(self,parent,title):
self.titleLbl = 'Station Information, Meters and Benchmark/Reference Files'
lbl1 = 'Station information (Station ID, Name, Time Zone)'
lbl2 = 'Meter information (Serial #, Instrument Type, Manufacturer, Model, Frequency)'
lbl3 = 'Benchmark/reference information (Station ID, Reference, Elevation, Desc.)'
desc1 = """These directories point to configuration files to allow you to view Station Information, Benchmarks and Field Equipment in drop-down menus.
Station Information and Benchmarks can be extracted and created using the AQUARIUS Data Extraction Tool (next menu over), but the meters.csv
file will have to be set up by you or your office. The AQUARIUS Data Extraction Tool should be run for every new eHSN release, as well as periodically
to ensure that all data is up-to-date; data should be extracted using the same version of eHSN that will be used to collect data.
It is recommended to store all configuration files in the default location (i.e. alongside the eHSN exe). """
self.stationsDefaultPath = 'stations.txt'
self.metersDefaultPath = 'meters.csv'
self.levelsDefaultPath = 'levels.txt'
self.iconName = "icon_transparent.ico"
# based on a frame, so set up the frame
wx.Frame.__init__(self,parent,wx.ID_ANY, title)
#Main
self.configPanel = wx.Panel(self, style = wx.BORDER_NONE)
self.configSizerV = wx.BoxSizer(wx.VERTICAL)
self.configPanel.SetSizer(self.configSizerV)
#Title
titlePanel = wx.Panel(self.configPanel, style=wx.SIMPLE_BORDER)
titleSizer = wx.BoxSizer(wx.VERTICAL)
titlePanel.SetSizer(titleSizer)
titleText = wx.StaticText(titlePanel, label=self.titleLbl, style=wx.ALIGN_CENTRE_HORIZONTAL)
titleSizer.Add(titleText,0,wx.EXPAND)
f = wx.Font(15, wx.ROMAN, wx.FONTSTYLE_NORMAL, wx.BOLD, False)
titleText.SetFont(f)
descTxt = wx.StaticText(titlePanel, label=desc1, style=wx.ALIGN_LEFT)
titleSizer.Add(descTxt, 0, wx.EXPAND)
#Stations
self.stationsPanel = wx.Panel(self.configPanel, style=wx.SIMPLE_BORDER)
self.stationsSizerV = wx.BoxSizer(wx.VERTICAL)
self.stationsPanel.SetSizer(self.stationsSizerV)
self.stationsTitlePanel = wx.Panel(self.stationsPanel, style=wx.BORDER_NONE)
self.stationsTitleSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.stationsTitlePanel.SetSizer(self.stationsTitleSizerH)
self.stationsPathPanel = wx.Panel(self.stationsPanel, style=wx.BORDER_NONE)
self.stationsPathSizerV = wx.BoxSizer(wx.VERTICAL)
self.stationsPathPanel.SetSizer(self.stationsPathSizerV)
self.stationsTitButPanel = wx.Panel(self.stationsTitlePanel, style=wx.BORDER_NONE)
self.stationsTitButSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.stationsTitButPanel.SetSizer(self.stationsTitButSizerH)
stationsDescText = wx.StaticText(self.stationsTitlePanel, label=lbl1)
self.stationsButton = wx.Button(self.stationsTitButPanel, 100, "Browse")
self.stationsResetButton = wx.Button(self.stationsTitButPanel, 101, "Reset to Default")
self.stationsResetButton.Hide()
# stationPad = wx.StaticText(self.stationsTitButPanel, size=(-1,-1))
self.stationsPathText = wx.StaticText(self.stationsPathPanel, label=self.stationsDefaultPath)
self.stationsPathText.SetForegroundColour("#5E9811")
# self.stationsTitButSizerH.Add(self.stationsResetButton, 1, wx.EXPAND)
# self.stationsTitButSizerH.Add(stationPad, 1, wx.EXPAND)
self.stationsTitButSizerH.Add(self.stationsButton, 1, wx.EXPAND)
self.stationsPathSizerV.Add(self.stationsPathText, 1, wx.EXPAND)
self.stationsTitleSizerH.Add(stationsDescText, 4, wx.EXPAND)
self.stationsTitleSizerH.Add(self.stationsTitButPanel, 1, wx.EXPAND)
self.stationsSizerV.Add(self.stationsTitlePanel, 1, wx.EXPAND)
self.stationsSizerV.Add(self.stationsPathPanel, 1, wx.EXPAND)
#Meters
self.metersPanel = wx.Panel(self.configPanel, style=wx.SIMPLE_BORDER)
self.metersSizerV = wx.BoxSizer(wx.VERTICAL)
self.metersPanel.SetSizer(self.metersSizerV)
self.metersTitlePanel = wx.Panel(self.metersPanel, style=wx.BORDER_NONE)
self.metersTitleSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.metersTitlePanel.SetSizer(self.metersTitleSizerH)
self.metersPathPanel = wx.Panel(self.metersPanel, style=wx.BORDER_NONE)
self.metersPathSizerV = wx.BoxSizer(wx.VERTICAL)
self.metersPathPanel.SetSizer(self.metersPathSizerV)
self.metersTitDescPanel = wx.Panel(self.metersTitlePanel, style=wx.BORDER_NONE)
self.metersTitDescSizerV = wx.BoxSizer(wx.VERTICAL)
self.metersTitDescPanel.SetSizer(self.metersTitDescSizerV)
self.metersTitButPanel = wx.Panel(self.metersTitlePanel, style=wx.BORDER_NONE)
self.metersTitButSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.metersTitButPanel.SetSizer(self.metersTitButSizerH)
metersDescText = wx.StaticText(self.metersTitDescPanel, label=lbl2)
self.metersButton = wx.Button(self.metersTitButPanel, 102, "Browse")
self.metersResetButton = wx.Button(self.metersTitButPanel, 103, "Reset to Default")
# meterPad = wx.StaticText(self.metersTitButPanel, size=(-1,-1))
self.metersResetButton.Hide()
self.metersPathText = wx.StaticText(self.metersPathPanel, label=self.metersDefaultPath)
self.metersPathText.SetForegroundColour("#5E9811")
self.metersTitDescSizerV.Add(metersDescText, 1, wx.EXPAND)
# self.metersTitButSizerH.Add(self.metersResetButton, 1, wx.EXPAND)
# self.metersTitButSizerH.Add(meterPad, 1, wx.EXPAND)
self.metersTitButSizerH.Add(self.metersButton, 1, wx.EXPAND)
self.metersPathSizerV.Add(self.metersPathText, 1, wx.EXPAND)
self.metersTitleSizerH.Add(self.metersTitDescPanel, 4, wx.EXPAND)
self.metersTitleSizerH.Add(self.metersTitButPanel, 1, wx.EXPAND)
self.metersSizerV.Add(self.metersTitlePanel, 1, wx.EXPAND)
self.metersSizerV.Add(self.metersPathPanel, 1, wx.EXPAND)
#Levels
self.levelsPanel = wx.Panel(self.configPanel, style=wx.SIMPLE_BORDER)
self.levelsSizerV = wx.BoxSizer(wx.VERTICAL)
self.levelsPanel.SetSizer(self.levelsSizerV)
self.levelsTitlePanel = wx.Panel(self.levelsPanel, style=wx.BORDER_NONE)
self.levelsTitleSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.levelsTitlePanel.SetSizer(self.levelsTitleSizerH)
self.levelsPathPanel = wx.Panel(self.levelsPanel, style=wx.BORDER_NONE)
self.levelsPathSizerV = wx.BoxSizer(wx.VERTICAL)
self.levelsPathPanel.SetSizer(self.levelsPathSizerV)
self.levelsTitDescPanel = wx.Panel(self.levelsTitlePanel, style=wx.BORDER_NONE)
self.levelsTitDescSizerV = wx.BoxSizer(wx.VERTICAL)
self.levelsTitDescPanel.SetSizer(self.levelsTitDescSizerV)
self.levelsTitButPanel = wx.Panel(self.levelsTitlePanel, style=wx.BORDER_NONE)
self.levelsTitButSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.levelsTitButPanel.SetSizer(self.levelsTitButSizerH)
levelsDescText = wx.StaticText(self.levelsTitDescPanel, label=lbl3)
self.levelsButton = wx.Button(self.levelsTitButPanel, 104, "Browse")
self.levelsResetButton = wx.Button(self.levelsTitButPanel, 105, "Reset to Default")
# levelPad = wx.StaticText(self.levelsTitButPanel, size=(-1,-1))
self.levelsResetButton.Hide()
self.levelsPathText = wx.StaticText(self.levelsPathPanel, label=self.levelsDefaultPath)
self.levelsPathText.SetForegroundColour("#5E9811")
self.levelsTitDescSizerV.Add(levelsDescText, 1, wx.EXPAND)
# self.levelsTitButSizerH.Add(self.levelsResetButton, 1, wx.EXPAND)
# self.levelsTitButSizerH.Add(levelPad, 1, wx.EXPAND)
self.levelsTitButSizerH.Add(self.levelsButton, 1, wx.EXPAND)
self.levelsPathSizerV.Add(self.levelsPathText, 1, wx.EXPAND)
self.levelsTitleSizerH.Add(self.levelsTitDescPanel, 4, wx.EXPAND)
self.levelsTitleSizerH.Add(self.levelsTitButPanel, 1, wx.EXPAND)
self.levelsSizerV.Add(self.levelsTitlePanel, 1, wx.EXPAND)
self.levelsSizerV.Add(self.levelsPathPanel, 1, wx.EXPAND)
self.configSizerV.Add(titlePanel, 0, wx.EXPAND)
self.configSizerV.Add(self.stationsPanel, 1, wx.EXPAND)
self.configSizerV.Add(self.metersPanel, 1, wx.EXPAND)
self.configSizerV.Add(self.levelsPanel, 1, wx.EXPAND)
self.bottomButtonPanel = wx.Panel(self, style=wx.BORDER_NONE)
self.bottomButtonSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.bottomButtonPanel.SetSizer(self.bottomButtonSizerH)
self.clearButton = wx.Button(self.bottomButtonPanel, 106, "Clear All Paths")
self.closeButton = wx.Button(self.bottomButtonPanel, 107, "Done")
self.bottomButtonSizerH.Add(self.clearButton, 1, wx.EXPAND)
self.bottomButtonSizerH.Add(self.closeButton, 1, wx.EXPAND)
self.sizer=wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.configPanel, 1, wx.EXPAND)
self.sizer.Add(self.bottomButtonPanel, 0, wx.EXPAND)
icon_path = self.iconName
if hasattr(sys, '_MEIPASS'):
icon_path = os.path.join(sys._MEIPASS, icon_path)
#PNG Icon
if os.path.exists(icon_path):
png = wx.Image(icon_path, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
self.icon = wx.Icon(png)
self.SetIcon(self.icon)
# Tell it which sizer is to be used for main frame
# It may lay out automatically and be altered to fit window
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
# Show it !!!
self.Show(1)
def OnReset(self, event):
self.stationsPathText.SetValue(self.stationsDefaultPath)
def main():
# Set up a window based app, and create a main window in it
app = wx.PySimpleApp()
view = ConfigPanel(None, "User Configuration")
# Enter event loop
app.MainLoop()
if __name__ == "__main__":
main()