-
Notifications
You must be signed in to change notification settings - Fork 11
/
StageMeasurementsPanel.py
2656 lines (2000 loc) · 102 KB
/
StageMeasurementsPanel.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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# 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
from decimal import Decimal
import wx
import wx.lib.masked as masked
import wx.lib.scrolledpanel as scrolledpanel
from time import strptime
# import wx.combo as cb
from wx import ComboPopup
import datetime
# import wx.core as cb
# import wx.ComboPopup as cb
import NumberControl
from DropdownTime import *
from pdb import set_trace
#Overwrite the TextCtrl Class in order to control the float input
class MyTextCtrl(wx.TextCtrl):
def __init__(self, *args, **kwargs):
super(MyTextCtrl, self).__init__(*args, **kwargs)
self.preValue = ""
##This class is taken from wxPython demo
##https://github.com/wxWidgets/wxPython/blob/master/demo/ComboCtrl.py
class ComboCtrlPopup(wx.ListCtrl, ComboPopup):
def __init__(self):
self.PostCreate(wx.PreListCtrl())
ComboPopup.__init__(self)
def AddItem(self, txt):
self.InsertStringItem(self.GetItemCount(), txt)
def AddItems(self, lis):
for txt in lis:
self.AddItem(txt)
def OnMotion(self, evt):
item, flags = self.HitTest(evt.GetPosition())
if item >= 0:
self.Select(item)
self.curitem = item
def OnLeftDown(self, evt):
self.value = self.curitem
self.Dismiss()
# The following methods are those that are overridable from the
# ComboPopup base class. Most of them are not required, but all
# are shown here for demonstration purposes.
# This is called immediately after construction finishes. You can
# use self.GetCombo if needed to get to the ComboCtrl instance.
def Init(self):
self.value = -1
self.curitem = -1
# Create the popup child control. Return true for success.
def Create(self, parent):
wx.ListCtrl.Create(self, parent,
style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_Left_DOWN, self.OnLeftDown)
return True
# Return the widget that is to be used for the popup
def GetControl(self):
#self.log.write("ListCtrlComboPopup.GetControl")
return self
# Called just prior to displaying the popup, you can use it to
# 'select' the current item.
def SetStringValue(self, val):
idx = self.FindItem(-1, val)
if idx != wx.NOT_FOUND:
self.Select(idx)
# Return a string representation of the current item.
def GetStringValue(self):
if self.value >= 0:
return self.GetItemText(self.value)
return ""
# Called immediately after the popup is shown
def OnPopup(self):
ComboPopup.OnPopup(self)
self.SetFocus()
class StageMeasurementsPanel(wx.Panel):
def __init__(self, mode, lang, *args, **kwargs):
super(StageMeasurementsPanel, self).__init__(*args, **kwargs)
self.timeTxtLbl = "Time"
self.stageTxtLbl = "HG"
self.stageTxtLbl2 = "HG2"
self.levelTxtLbl = "Water Level Reference"
self.sensorResetTxtLbl = "Sensor Reset Correction"
self.sensorResetAppTxtLbl = "Action Taken"
self.weightedMghTxtLbl = "Weighted M.G.H."
self.srcTxtLbl = "S.R.C."
self.gcTxtLbl = "Gauge Correction"
self.correctedMghTxtLbl = "Corrected M.G.H. (m)"
self.mghAggregationLbl = "M.G.H. Aggr."
self.mghAggregationChoices = ["", "HG", "HG2", "WLR1", "WLR2"]
self.mghMethodLbl = " MGH Aggr.\n Method:"
self.mghMethods = ["", "Average", "Time-weighted"]
self.references = [""]
self.srcChoices = ['', 'Reset (RS)', 'No Reset (NR)', 'Flushed (FL)', 'Found (FD)', 'Purged (PU)', 'Recovered (RC)', 'Maintenance (MT)', 'G.C. Applied (GCA)', 'CTRL Cleared (CC)', 'DWL', 'Changed Tank (CT)']
self.BMs = []
self.mghCalBtnLbl = "Calculate M.G.H."
self.surgeTxtLbl = "Surge\n(+/- m)"
self.factors = ""
self.incompleteDischargeTimeMsg = """The discharge mmt time is not complete. As a result, the MGH calculation has not
taken the discharge mmt time into account."""
self.incompleteDischargeTimeTitle = "Warning"
self.stageLbl = "Stage Activity\nSummary Remarks"
self.checkDischargeTime = True
self.readingTypeLbl = 'Reading\nType'
self.readingTypes = ['', 'Routine', 'Routine Before', 'Routine After', 'Reset Before', 'Reset After',
'Cleaning Before', 'Cleaning After', 'After Calibration', 'Reference Primary', 'Reference']
self.frame = self.GetParent()
self.size = self.frame.GetSize()
self.colHeaderHeight = 48 * 1.3
self.colHeaderWidth = 60
# self.minWidth = 20
self.rowHeight = 28
self.wrapLength = self.colHeaderWidth * 2
self.entryNum = 0
self.hgButton = True
self.weightMGHBtnHint = "*Always enter Weighted M.G.H even if its the same as Corrected M.G.H.*\nYou should always\
enter Weighted M.G.H even if it is the same as Corrected M.G.H since Corrected M.G.H. is automatically calculated \
in Aquarius.\n\n1. The value of the Weighted M.G.H. is put in the 'Observed gauge height' of the Mean Gauge Height section\
within the Discharge page of Aquarius\n2. The Gauge Correction and S.R.C. are put in the 'Adjustment' column in Aquarius\n3. Aquarius adds \
these numbers together to get the Corrected M.G.H.\n\nSince Corrected M.G.H. is auto-calculated in Aquarius and will \
be available in Aquarius, it is NOT uploaded from the Corrected M.G.H. field here."
# self.correctMGHBtnHint = "Corrected MGH is not directly uploaded to Aquarius, ensure values are entered as Weighted MGH + S.R.C. and Gauge Correction."
self.mode=mode
self.manager = None
self.lang = lang
self.InitUI()
#convert to upper case
def OnTextType(self, event):
textCtr=event.GetEventObject()
insertPoint = textCtr.GetInsertionPoint()
# textCtr.ChangeValue(unicode.upper(textCtr.GetValue()))
textCtr.SetInsertionPoint(insertPoint)
# while True:
# raise Exception('I know Python!')
event.Skip()
def InitUI(self):
if self.mode=="DEBUG":
print("In StageMeasurementsPanel")
self.layoutSizerV = wx.BoxSizer(wx.VERTICAL)
self.locale = wx.Locale(self.lang)
#Measurements Panel
self.measurementsScrollPanel = scrolledpanel.ScrolledPanel(self, size=(200, 200), style=wx.SIMPLE_BORDER|wx.VSCROLL)
self.measurementsScrollPanel.SetupScrolling()
# self.measurementsScrollPanel.SetMinSize((200,200))
# self.measurementsScrollPanel.ShowScrollbars(wx.SHOW_SB_NEVER, wx.SHOW_SB_ALWAYS)
self.measurementsSizer = wx.BoxSizer(wx.HORIZONTAL)
self.measurementsSizerV = wx.BoxSizer(wx.VERTICAL)
#Entry Adding Column
self.entryColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.entryColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
entryColPanel = wx.Panel(self.entryColumnPanel, style=wx.SIMPLE_BORDER)
wx.StaticText(entryColPanel, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.rowHeight, self.colHeaderHeight))
#For dynamically added entries
self.entryColButtonPanel = wx.Panel(self.entryColumnPanel, style=wx.SIMPLE_BORDER)
self.entryColButtonSizer = wx.BoxSizer(wx.VERTICAL)
self.entryColButtonPanel.SetSizer(self.entryColButtonSizer)
#Add a default button
name = "%s" % self.entryNum
button = wx.Button(self.entryColButtonPanel, id=10101+self.entryNum, label="+", name=name, size=(self.rowHeight, self.rowHeight))
self.entryNum += 1
button.Bind(wx.EVT_BUTTON, self.OnAddPress)
self.entryColButtonSizer.Add(button, 0, wx.EXPAND)
self.entryColumnSizer.Add(entryColPanel, 0, wx.EXPAND)
self.entryColumnSizer.Add(self.entryColButtonPanel, 0, wx.EXPAND)
self.entryColumnPanel.SetSizer(self.entryColumnSizer)
#Time column
self.timeColumnSizer = wx.BoxSizer(wx.VERTICAL)
timeLabelPanel = wx.Panel(self.measurementsScrollPanel, style=wx.SIMPLE_BORDER)
timeLabelSizer = wx.BoxSizer(wx.HORIZONTAL)
timeLabelPanel.SetSizer(timeLabelSizer)
timeLabelTxt = wx.StaticText(timeLabelPanel, label=self.timeTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth, self.colHeaderHeight))
## timeLabelTxt.Wrap(self.wrapLength)
timeLabelSizer.Add(timeLabelTxt, 1, wx.EXPAND)
#Create new panel and sizer for dynamic entries
self.timeValPanel = wx.Panel(self.measurementsScrollPanel, style=wx.SIMPLE_BORDER)
self.timeValSizer = wx.BoxSizer(wx.VERTICAL)
self.timeValPanel.SetSizer(self.timeValSizer)
#Add all to the Time
self.timeColumnSizer.Add(timeLabelPanel, 0, wx.EXPAND)
self.timeColumnSizer.Add(self.timeValPanel, 0, wx.EXPAND)
#Stage column 1
# self.stageColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.stageColumnSizerV = wx.BoxSizer(wx.VERTICAL)
self.stageColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
stageLabelPanel = wx.Panel(self.stageColumnPanel, style=wx.SIMPLE_BORDER)
# stageLabelSizer = wx.BoxSizer(wx.HORIZONTAL)
stageLabelSizerV = wx.BoxSizer(wx.VERTICAL)
stageLabelPanel.SetSizer(stageLabelSizerV)
stageLabelTxt = wx.StaticText(stageLabelPanel, label=self.stageTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth*2, self.colHeaderHeight / 2))
stageLabelTxt.SetMinSize((self.colHeaderWidth*2, self.colHeaderHeight / 2))
stageLabelTxt.Wrap(self.wrapLength)
# self.hgCkbox = wx.CheckBox(stageLabelPanel)
# self.hgCkbox.Bind(wx.EVT_CHECKBOX, self.OnHGCalculateMGH)
# self.stageLabelBtn = wx.Button(stageLabelPanel, label=self.stageTxtLbl, style=wx.BU_TOP, size=(self.colHeaderWidth, self.colHeaderHeight / 2))
# self.stageLabelBtn.Bind(wx.EVT_BUTTON, self.OnHGButton)
# self.stageLabelBtn.SetBackgroundColour('yellow')
self.stageLabelCtrl1 = wx.TextCtrl(stageLabelPanel, style=wx.TE_PROCESS_ENTER, size=(self.colHeaderWidth*2, self.colHeaderHeight / 2))
self.stageLabelCtrl1.SetMinSize((self.colHeaderWidth*2, self.colHeaderHeight / 2))
self.stageLabelCtrl1.Bind(wx.EVT_TEXT, self.OnTextType)
self.stageLabelCtrl1.Bind(wx.EVT_KEY_DOWN, self.OnTab)
stageLabelSizerV.Add(stageLabelTxt, 1, wx.EXPAND)
stageLabelSizerV.Add(self.stageLabelCtrl1, 1, wx.EXPAND)
# stageLabelSizerV.Add(self.hgCkbox, 0, wx.EXPAND|wx.LEFT, 20)
# stageLabelSizer.Add(stageLabelSizerV, 1, wx.EXPAND)
#Create new panel and sizer for dynamically items
self.stagePanel = wx.Panel(self.stageColumnPanel, style=wx.SIMPLE_BORDER, name="hg")
self.stageSizer = wx.BoxSizer(wx.VERTICAL)
self.stagePanel.SetSizer(self.stageSizer)
self.stageColumnSizerV.Add(stageLabelPanel, 0, wx.EXPAND)
self.stageColumnSizerV.Add(self.stagePanel, 0, wx.EXPAND)
# self.stageColumnSizerV.Add(self.stageColumnSizer, 1, wx.EXPAND)
self.stageColumnPanel.SetSizer(self.stageColumnSizerV)
#Stage Column 2
self.stageColumnSizer2 = wx.BoxSizer(wx.VERTICAL)
self.stageColumnSizerH2 = wx.BoxSizer(wx.HORIZONTAL)
self.stageColumnPanel2 = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
stageLabelPanel2 = wx.Panel(self.stageColumnPanel2, style=wx.SIMPLE_BORDER)
stageLabelSizer2 = wx.BoxSizer(wx.HORIZONTAL)
stageLabelSizer2V = wx.BoxSizer(wx.VERTICAL)
stageLabelPanel2.SetSizer(stageLabelSizer2)
stageLabelTxt2 = wx.StaticText(stageLabelPanel2, label=self.stageTxtLbl2, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth*2, self.colHeaderHeight / 2))
stageLabelTxt2.SetMinSize((self.colHeaderWidth*2, self.colHeaderHeight / 2))
stageLabelTxt2.Wrap(self.wrapLength)
# self.hg2Ckbox = wx.CheckBox(stageLabelPanel2)
# self.hg2Ckbox.Bind(wx.EVT_CHECKBOX, self.OnHG2CalculateMGH)
# self.stageLabelBtn2 = wx.Button(stageLabelPanel2, label=self.stageTxtLbl2, style=wx.BU_TOP, size=(self.colHeaderWidth, self.colHeaderHeight / 2))
# self.stageLabelBtn2.Bind(wx.EVT_BUTTON, self.OnHGButton)
self.stageLabelCtrl2 = wx.TextCtrl(stageLabelPanel2, style=wx.TE_PROCESS_ENTER, size=(self.colHeaderWidth*2, self.colHeaderHeight / 2))
self.stageLabelCtrl2.SetMinSize((self.colHeaderWidth*2, self.colHeaderHeight / 2))
self.stageLabelCtrl2.Bind(wx.EVT_TEXT, self.OnTextType)
self.stageLabelCtrl2.Bind(wx.EVT_KEY_DOWN, self.OnTab)
# for i in self.stageLabelCtrl1.GetParent().GetParent().GetChildren():
# for p in i.GetChildren():
# print type(p)
# self.stageLabelCtrl1.MoveAfterInTabOrder(self.stageLabelCtrl2)
stageLabelSizer2V.Add(stageLabelTxt2, 0, wx.EXPAND)
stageLabelSizer2V.Add(self.stageLabelCtrl2, 0, wx.EXPAND)
# stageLabelSizer2V.Add(self.hg2Ckbox, 0, wx.EXPAND|wx.LEFT, 20)
stageLabelSizer2.Add(stageLabelSizer2V, 1, wx.EXPAND)
#Create new panel and sizer for dynamically items
self.stagePanel2 = wx.Panel(self.stageColumnPanel2, style=wx.SIMPLE_BORDER, name="hg2")
self.stageSizer2 = wx.BoxSizer(wx.VERTICAL)
self.stagePanel2.SetSizer(self.stageSizer2)
self.stageColumnSizer2.Add(stageLabelPanel2, 0, wx.EXPAND)
self.stageColumnSizer2.Add(self.stagePanel2, 0, wx.EXPAND)
self.stageColumnSizerH2.Add(self.stageColumnSizer2, 1, wx.EXPAND)
self.stageColumnPanel2.SetSizer(self.stageColumnSizerH2)
#W.L Reference column
self.wlColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
self.wlColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.wlColumnPanel.SetSizer(self.wlColumnSizer)
wlHeaderPanel = wx.Panel(self.wlColumnPanel, style=wx.SIMPLE_BORDER)
wlHeaderSizer = wx.BoxSizer(wx.VERTICAL)
wlHeaderPanel.SetSizer(wlHeaderSizer)
# wlHeaderLabelPanel = wx.Panel(wlHeaderPanel, style=wx.SIMPLE_BORDER)
# wlHeaderLabelSizer = wx.BoxSizer(wx.VERTICAL)
# wlHeaderLabelPanel.SetSizer(wlHeaderLabelSizer)
# wlHeaderComboPanel = wx.Panel(wlHeaderPanel, style=wx.SIMPLE_BORDER)
self.wlHeaderComboSizer = wx.BoxSizer(wx.HORIZONTAL)
# wlHeaderComboPanel.SetSizer(self.wlHeaderComboSizer)
# wlHeaderSizer.Add(wlHeaderLabelPanel, 0, wx.EXPAND)
# wlHeaderSizer.Add(wlHeaderComboPanel, 0, wx.EXPAND)
#Create panel for dynamic entries
wlValPanel = wx.Panel(self.wlColumnPanel, style=wx.SIMPLE_BORDER)
wlValSizer = wx.BoxSizer(wx.HORIZONTAL)
wlValPanel.SetSizer(wlValSizer)
self.wlValLeftPanel = wx.Panel(wlValPanel, style=wx.SIMPLE_BORDER, name='wlr1')
self.wlValLeftSizer = wx.BoxSizer(wx.VERTICAL)
self.wlValLeftPanel.SetSizer(self.wlValLeftSizer)
self.wlValRightPanel = wx.Panel(wlValPanel, style=wx.SIMPLE_BORDER, name='wlr2')
self.wlValRightSizer = wx.BoxSizer(wx.VERTICAL)
self.wlValRightPanel.SetSizer(self.wlValRightSizer)
wlValSizer.Add(self.wlValLeftPanel, 0, wx.EXPAND)
wlValSizer.Add(self.wlValRightPanel, 0, wx.EXPAND)
# wlHeaderCLPanel = wx.Panel(wlHeaderComboPanel, style=wx.SIMPLE_BORDER)
# wlHeaderCLSizer = wx.BoxSizer(wx.HORIZONTAL)
# wlHeaderCLPanel.SetSizer(wlHeaderCLSizer)
# wlHeaderCRPanel = wx.Panel(wlHeaderComboPanel, style=wx.SIMPLE_BORDER)
# wlHeaderCRSizer = wx.BoxSizer(wx.HORIZONTAL)
# wlHeaderCRPanel.SetSizer(wlHeaderCRSizer)
wlLabelTxt = wx.StaticText(wlHeaderPanel, label=self.levelTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth * 4, self.colHeaderHeight/2))
# wlLabelTxt.SetMinSize((self.colHeaderWidth*2, self.colHeaderHeight / 2))
wlLabelTxt.Wrap(self.wrapLength * 2)
wlHeaderSizer.Add(wlLabelTxt, 0, wx.EXPAND)
self.bmLeft = wx.ComboBox(wlHeaderPanel, choices=self.BMs, style=wx.CB_DROPDOWN, size=(self.colHeaderWidth*2, self.colHeaderHeight/2-1))
# self.bmLeft.SetMinSize((self.colHeaderWidth, self.colHeaderHeight / 2))
self.bmLeft.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
self.bmLeft.Bind(wx.EVT_TEXT, self.OnTextType)
self.bmLeft.Bind(wx.EVT_KEY_DOWN, self.OnTab)
self.bmRight = wx.ComboBox(wlHeaderPanel, choices=self.BMs, style=wx.CB_DROPDOWN, size=(self.colHeaderWidth*2, self.colHeaderHeight/2-1))
# self.bmRight.SetMinSize((self.colHeaderWidth, self.colHeaderHeight / 2))
self.bmRight.Bind(wx.EVT_MOUSEWHEEL, self.do_nothing)
self.bmRight.Bind(wx.EVT_TEXT, self.OnTextType)
self.bmRight.Bind(wx.EVT_KEY_DOWN, self.OnTab)
self.wlHeaderComboSizer.Add(self.bmLeft, 1, wx.EXPAND)
self.wlHeaderComboSizer.Add(self.bmRight, 1, wx.EXPAND)
wlHeaderSizer.Add(self.wlHeaderComboSizer, 0, wx.EXPAND)
self.wlColumnSizer.Add(wlHeaderPanel, 0, wx.EXPAND)
self.wlColumnSizer.Add(wlValPanel, 0, wx.EXPAND)
#SRC column
self.srcColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.srcColumnSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.srcColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
srcLabelPanel = wx.Panel(self.srcColumnPanel, style=wx.SIMPLE_BORDER)
srcLabelSizer = wx.BoxSizer(wx.HORIZONTAL)
srcLabelPanel.SetSizer(srcLabelSizer)
srcTxt = wx.StaticText(srcLabelPanel, label=self.sensorResetTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth * 1.4, self.colHeaderHeight))
srcTxt.Wrap(self.wrapLength)
srcLabelSizer.Add(srcTxt, 1, wx.EXPAND)
#Create Panel for dynamic entries
self.srcPanel = wx.Panel(self.srcColumnPanel, style=wx.SIMPLE_BORDER)
self.srcSizer = wx.BoxSizer(wx.VERTICAL)
self.srcPanel.SetSizer(self.srcSizer)
self.srcColumnSizer.Add(srcLabelPanel, 0, wx.EXPAND)
self.srcColumnSizer.Add(self.srcPanel, 0, wx.EXPAND)
self.srcColumnSizerH.Add(self.srcColumnSizer, 1, wx.EXPAND)
self.srcColumnPanel.SetSizer(self.srcColumnSizerH)
#SRC Applied Column
self.srcAppColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.srcAppColumnSizerH = wx.BoxSizer(wx.HORIZONTAL)
self.srcAppColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
srcAppLabelPanel = wx.Panel(self.srcAppColumnPanel, style=wx.SIMPLE_BORDER)
srcAppLabelSizer = wx.BoxSizer(wx.HORIZONTAL)
srcAppLabelPanel.SetSizer(srcAppLabelSizer)
srcAppTxt = wx.StaticText(srcAppLabelPanel, label=self.sensorResetAppTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(-1, self.colHeaderHeight))
srcAppTxt.Wrap(self.wrapLength / 1.4)
srcAppLabelSizer.Add(srcAppTxt, 1, wx.EXPAND)
#Create Panel for dynamic entries
self.srcAppPanel = wx.Panel(self.srcAppColumnPanel, style=wx.SIMPLE_BORDER)
self.srcAppSizer = wx.BoxSizer(wx.VERTICAL)
self.srcAppPanel.SetSizer(self.srcAppSizer)
self.srcAppColumnSizer.Add(srcAppLabelPanel, 0, wx.EXPAND)
self.srcAppColumnSizer.Add(self.srcAppPanel, 0, wx.EXPAND)
self.srcAppColumnSizerH.Add(self.srcAppColumnSizer, 1, wx.EXPAND)
self.srcAppColumnPanel.SetSizer(self.srcAppColumnSizerH)
#Reading Types
self.readingTypeColumnpanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
readingTypeColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.readingTypeColumnpanel.SetSizer(readingTypeColumnSizer)
#Create header panel
readingTypeHeaderSizer = wx.BoxSizer(wx.VERTICAL)
readingTypeHeaderPanel = wx.Panel(self.readingTypeColumnpanel, style=wx.SIMPLE_BORDER, size=(-1, self.colHeaderHeight))
readingTypeHeaderPanel.SetSizer(readingTypeHeaderSizer)
readingTypeTxt = wx.StaticText(readingTypeHeaderPanel, label=self.readingTypeLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(20, self.colHeaderHeight/2))
readingTypeHeaderSizer.Add(readingTypeTxt, 1, wx.EXPAND)
#Create new panel and sizer for dynamic entries
self.readingTypeValPanel = wx.Panel(self.readingTypeColumnpanel, style=wx.SIMPLE_BORDER)
self.readingTypeValSizer = wx.BoxSizer(wx.VERTICAL)
self.readingTypeValPanel.SetSizer(self.readingTypeValSizer)
readingTypeColumnSizer.Add(readingTypeHeaderPanel, 0, wx.EXPAND)
readingTypeColumnSizer.Add(self.readingTypeValPanel, 0, wx.EXPAND)
#MGH Aggregation Column
self.mghAggColumnPanel = wx.Panel(self.measurementsScrollPanel, style=wx.BORDER_NONE)
mghAggColumnSizer = wx.BoxSizer(wx.VERTICAL)
self.mghAggColumnPanel.SetSizer(mghAggColumnSizer)
#Create header panel
mghAggHeaderSizer = wx.BoxSizer(wx.VERTICAL)
mghAggHeaderPanel = wx.Panel(self.mghAggColumnPanel, style=wx.SIMPLE_BORDER, size=(-1, self.colHeaderHeight))
mghAggHeaderPanel.SetSizer(mghAggHeaderSizer)
mghAggTxt = wx.StaticText(mghAggHeaderPanel, label=self.mghAggregationLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.colHeaderWidth, self.colHeaderHeight/2))
mghAggTxt.Wrap(self.wrapLength*2)
# self.mghAggCombobox = wx.ComboBox(mghAggHeaderPanel, choices=sorted(self.mghAggregationChoices), value=self.mghAggregationChoices[0], style=wx.CB_READONLY, size=(self.colHeaderWidth, self.colHeaderHeight/2))
# self.mghAggCombobox.Bind(wx.EVT_COMBOBOX, self.OnAggComboChangeMGHColor)
mghAggHeaderSizer.Add(mghAggTxt, 1, wx.EXPAND)
# mghAggHeaderSizer.Add(self.mghAggCombobox, 0, wx.EXPAND|wx.TOP, 5)
#Create new panel and sizer for dynamic entries
self.mghAggValPanel = wx.Panel(self.mghAggColumnPanel, style=wx.SIMPLE_BORDER)
self.mghAggValSizer = wx.BoxSizer(wx.VERTICAL)
self.mghAggValPanel.SetSizer(self.mghAggValSizer)
mghAggColumnSizer.Add(mghAggHeaderPanel, 0, wx.EXPAND)
mghAggColumnSizer.Add(self.mghAggValPanel, 0, wx.EXPAND)
# Surge column
self.surgeColumnSizer = wx.BoxSizer(wx.VERTICAL)
surgeLabelPanel = wx.Panel(self.measurementsScrollPanel, style=wx.SIMPLE_BORDER)
surgeLabelSizer = wx.BoxSizer(wx.HORIZONTAL)
surgeLabelPanel.SetSizer(surgeLabelSizer)
surgeLabelTxt = wx.StaticText(surgeLabelPanel, label=self.surgeTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL,
size=(self.colHeaderWidth, self.colHeaderHeight))
## timeLabelTxt.Wrap(self.wrapLength)
surgeLabelSizer.Add(surgeLabelTxt, 1, wx.EXPAND)
# Create new panel and sizer for dynamic entries
self.surgeValPanel = wx.Panel(self.measurementsScrollPanel, style=wx.SIMPLE_BORDER)
self.surgeValSizer = wx.BoxSizer(wx.VERTICAL)
self.surgeValPanel.SetSizer(self.surgeValSizer)
# Add all to the Time
self.surgeColumnSizer.Add(surgeLabelPanel, 0, wx.EXPAND)
self.surgeColumnSizer.Add(self.surgeValPanel, 0, wx.EXPAND)
#Add all panels to measurementsSizer
self.measurementsSizer.Add(self.entryColumnPanel, 0, wx.EXPAND)
self.measurementsSizer.Add(self.timeColumnSizer, 0, wx.EXPAND)
self.measurementsSizer.Add(self.stageColumnPanel, 0, wx.EXPAND)
self.measurementsSizer.Add(self.stageColumnPanel2, 0, wx.EXPAND)
self.measurementsSizer.Add(self.wlColumnPanel, 0, wx.EXPAND)
self.measurementsSizer.Add(self.srcColumnPanel, 0, wx.EXPAND)
self.measurementsSizer.Add(self.srcAppColumnPanel, 1, wx.EXPAND)
self.measurementsSizer.Add(self.readingTypeColumnpanel, 1, wx.EXPAND)
self.measurementsSizer.Add(self.mghAggColumnPanel, 0, wx.EXPAND)
self.measurementsSizer.Add(self.surgeColumnSizer, 0, wx.EXPAND)
self.measurementsSizerV.Add(self.measurementsSizer, 1, wx.EXPAND)
self.measurementsScrollPanel.SetSizer(self.measurementsSizerV)
#Pre-Summary Stuff
preSummaryPanel = wx.Panel(self, style=wx.SIMPLE_BORDER)
preSummarySizer = wx.BoxSizer(wx.VERTICAL)
preSummaryPanel.SetSizer(preSummarySizer)
self.PreSummRowHeight = self.rowHeight / 2
self.PreSummColWidth = self.colHeaderWidth
self.SummColWidth = self.colHeaderWidth * 1.9 + 33
weightMGHPanel = wx.Panel(preSummaryPanel, style=wx.NO_BORDER)
weightMGHSizer = wx.BoxSizer(wx.HORIZONTAL)
weightMGHTxt = wx.StaticText(weightMGHPanel, label=self.weightedMghTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.SummColWidth-15, self.PreSummRowHeight))
self.weightMGHButton = wx.Button(weightMGHPanel, size=(15, self.PreSummRowHeight), label="!")
self.weightMGHButton.Bind(wx.EVT_BUTTON, self.OnWMGHBtn)
weightMGHSizer.Add(weightMGHTxt, 0, wx.EXPAND)
weightMGHSizer.Add(self.weightMGHButton, 0, wx.EXPAND)
weightMGHPanel.SetSizer(weightMGHSizer)
srcSummPanel = wx.Panel(preSummaryPanel, style=wx.NO_BORDER)
srcSummSizer = wx.BoxSizer(wx.HORIZONTAL)
srcSummPanelTxt = wx.StaticText(srcSummPanel, label=self.srcTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.SummColWidth, self.PreSummRowHeight))
srcSummSizer.Add(srcSummPanelTxt, 0, wx.EXPAND)
srcSummPanel.SetSizer(srcSummSizer)
gcSummPanel = wx.Panel(preSummaryPanel, style=wx.NO_BORDER)
gcSummSizer = wx.BoxSizer(wx.HORIZONTAL)
gcSummPanelTxt = wx.StaticText(gcSummPanel, label=self.gcTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.SummColWidth, self.PreSummRowHeight))
gcSummSizer.Add(gcSummPanelTxt, 0, wx.EXPAND)
gcSummPanel.SetSizer(gcSummSizer)
corrMghPanel = wx.Panel(preSummaryPanel, style=wx.NO_BORDER)
corrMghSizer = wx.BoxSizer(wx.HORIZONTAL)
corrMghPanelTxt = wx.StaticText(corrMghPanel, label=self.correctedMghTxtLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(self.SummColWidth, self.PreSummRowHeight))
# self.correctMGHButton = wx.Button(corrMghPanel, size=(15, self.PreSummRowHeight), label="!")
# self.correctMGHButton.Bind(wx.EVT_BUTTON, self.OnCMGHBtn)
corrMghSizer.Add(corrMghPanelTxt, 0, wx.EXPAND)
# corrMghSizer.Add(self.correctMGHButton, 0, wx.EXPAND)
corrMghPanel.SetSizer(corrMghSizer)
#On row by row basis
#Weighted MGH x
self.MGHHG = MyTextCtrl(weightMGHPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.MGHHG2 = MyTextCtrl(weightMGHPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.MGHWLRefL = MyTextCtrl(weightMGHPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.MGHWLRefR = MyTextCtrl(weightMGHPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
weightMGHSizer.Add(self.MGHHG, 0, wx.EXPAND)
weightMGHSizer.Add(self.MGHHG2, 0, wx.EXPAND)
weightMGHSizer.Add(self.MGHWLRefL, 0, wx.EXPAND)
weightMGHSizer.Add(self.MGHWLRefR, 0, wx.EXPAND)
self.MGHHG.SetBackgroundColour((204,204,204))
self.MGHHG.SetForegroundColour((0,0,204))
self.MGHHG2.SetBackgroundColour((204,204,204))
self.MGHHG2.SetForegroundColour((0,0,204))
self.MGHWLRefL.SetBackgroundColour((204,204,204))
self.MGHWLRefL.SetForegroundColour((0,0,204))
self.MGHWLRefR.SetBackgroundColour((204,204,204))
self.MGHWLRefR.SetForegroundColour((0,0,204))
mghMethodTxt = wx.StaticText(weightMGHPanel, label=self.mghMethodLbl, size=(self.PreSummColWidth * 2, self.PreSummRowHeight + 7))
self.mghMethod = wx.ComboBox(weightMGHPanel, choices=self.mghMethods, style=wx.CB_READONLY, size=(self.PreSummColWidth, self.PreSummRowHeight))
self.mghMethod.Bind(wx.EVT_COMBOBOX, self.CalculateAllMGH)
weightMGHSizer.Add(mghMethodTxt, 1, wx.EXPAND)
weightMGHSizer.Add(self.mghMethod, 2, wx.EXPAND)
checkBoxPanel = wx.Panel(preSummaryPanel, style=wx.NO_BORDER)
checkBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
checkBoxPanel.SetSizer(checkBoxSizer)
self.hgCkbox = wx.CheckBox(checkBoxPanel)
self.hg2Ckbox = wx.CheckBox(checkBoxPanel)
self.wlr1Ckbox = wx.CheckBox(checkBoxPanel)
self.wlr2Ckbox = wx.CheckBox(checkBoxPanel)
checkBoxSizer.Add((self.SummColWidth, -1), 0, wx.EXPAND)
checkBoxSizer.Add(self.hgCkbox, 0, wx.EXPAND)
checkBoxSizer.Add((105, -1), 0, wx.EXPAND)
checkBoxSizer.Add(self.hg2Ckbox, 0, wx.EXPAND)
checkBoxSizer.Add((105, -1), 0, wx.EXPAND)
checkBoxSizer.Add(self.wlr1Ckbox, 0, wx.EXPAND)
checkBoxSizer.Add((105, -1), 0, wx.EXPAND)
checkBoxSizer.Add(self.wlr2Ckbox, 0, wx.EXPAND)
self.hgCkbox.Bind(wx.EVT_CHECKBOX, self.OnHGCalculateMGH)
self.hg2Ckbox.Bind(wx.EVT_CHECKBOX, self.OnHG2CalculateMGH)
self.wlr1Ckbox.Bind(wx.EVT_CHECKBOX, self.OnWlr1CalculateMGH)
self.wlr2Ckbox.Bind(wx.EVT_CHECKBOX, self.OnWlr2CalculateMGH)
# mghCalBtn = wx.Button(preSummaryPanel, label=self.mghCalBtnLbl, size=(self.PreSummColWidth, self.PreSummRowHeight))
# mghCalBtn.Bind(wx.EVT_BUTTON, self.CalculateMGH)
# self.MGHHG.Bind(wx.EVT_TEXT, self.OnTypeChangeColorBack)
# self.MGHHG2.Bind(wx.EVT_TEXT, self.OnTypeChangeColorBack)
# self.MGHWLRefL.Bind(wx.EVT_TEXT, self.OnTypeChangeColorBack)
# self.MGHWLRefR.Bind(wx.EVT_TEXT, self.OnTypeChangeColorBack)
# self.MGHHG.Bind(wx.EVT_TEXT, self.OnHGCol)
# self.MGHHG2.Bind(wx.EVT_TEXT, self.OnHG2Col)
# self.MGHWLRefL.Bind(wx.EVT_TEXT, self.OnWL1Col)
# self.MGHWLRefR.Bind(wx.EVT_TEXT, self.OnWL2Col)
#SRC x
self.SRCHG = MyTextCtrl(srcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.SRCHG2 = MyTextCtrl(srcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
srcSummSizer.Add(self.SRCHG, 0, wx.EXPAND)
srcSummSizer.Add(self.SRCHG2, 0, wx.EXPAND)
#GC x
self.GCHG = MyTextCtrl(gcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.GCHG2 = MyTextCtrl(gcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.GCWLRefL = MyTextCtrl(gcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
self.GCWLRefR = MyTextCtrl(gcSummPanel, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight))
gcSummSizer.Add(self.GCHG, 0, wx.EXPAND)
gcSummSizer.Add(self.GCHG2, 0, wx.EXPAND)
gcSummSizer.Add(self.GCWLRefL, 0, wx.EXPAND)
gcSummSizer.Add(self.GCWLRefR, 0, wx.EXPAND)
#Corrected Mean gauge Height x
self.CMGHHG = MyTextCtrl(corrMghPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight), name="HG1")
# self.CMGHHG = wx.StaticText(preSummaryPanel, size=(self.PreSummColWidth, self.PreSummRowHeight))
self.CMGHHG2 = MyTextCtrl(corrMghPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight), name="HG2")
self.CMGHWLRefL = MyTextCtrl(corrMghPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight), name="WLR1")
self.CMGHWLRefR = MyTextCtrl(corrMghPanel, style=wx.TE_READONLY|wx.TE_CENTRE, size=(self.PreSummColWidth*2, self.PreSummRowHeight), name="WLR2")
corrMghSizer.Add(self.CMGHHG, 0, wx.EXPAND)
corrMghSizer.Add(self.CMGHHG2, 0, wx.EXPAND)
corrMghSizer.Add(self.CMGHWLRefL, 0, wx.EXPAND)
corrMghSizer.Add(self.CMGHWLRefR, 0, wx.EXPAND)
self.CMGHHG.SetBackgroundColour((204,204,204))
self.CMGHHG.SetForegroundColour((0,0,204))
self.CMGHHG2.SetBackgroundColour((204,204,204))
self.CMGHHG2.SetForegroundColour((0,0,204))
self.CMGHWLRefL.SetBackgroundColour((204,204,204))
self.CMGHWLRefL.SetForegroundColour((0,0,204))
self.CMGHWLRefR.SetBackgroundColour((204,204,204))
self.CMGHWLRefR.SetForegroundColour((0,0,204))
# self.MGHHG.Enable(False)
# self.MGHHG2.Enable(False)
# self.MGHWLRefL.Enable(False)
# self.MGHWLRefR.Enable(False)
# self.CMGHHG.Enable(False)
# self.CMGHHG2.Enable(False)
# self.CMGHWLRefL.Enable(False)
# self.CMGHWLRefR.Enable(False)
stageRemarkPanel = wx.Panel(preSummaryPanel, style=wx.SIMPLE_BORDER, size=(-1, -1))
stageRemarkSizer = wx.BoxSizer(wx.HORIZONTAL)
stageRemarkPanel.SetSizer(stageRemarkSizer)
stageTxt = wx.StaticText(stageRemarkPanel, label=self.stageLbl, style=wx.ALIGN_CENTRE_HORIZONTAL, size=(120, -1))
self.stageRemarksCtrl = wx.TextCtrl(stageRemarkPanel, style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_BESTWRAP, size=(-1, self.PreSummRowHeight * 1.7))
stageRemarkSizer.Add(stageTxt, 0)
stageRemarkSizer.Add(self.stageRemarksCtrl, 1, wx.EXPAND)
#Bind rounding
# self.MGHHG.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.MGHHG2.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.MGHWLRefL.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.MGHWLRefR.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.SRCHG.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.SRCHG2.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.GCHG.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.GCHG2.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.GCWLRefL.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
self.GCWLRefR.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.CMGHHG.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.CMGHHG2.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.CMGHWLRefL.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
# self.CMGHWLRefR.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
#Bind corrected MGH calculation
self.MGHHG.Bind(wx.EVT_KILL_FOCUS, self.OnHGCol)
self.MGHHG2.Bind(wx.EVT_KILL_FOCUS, self.OnHG2Col)
self.MGHWLRefL.Bind(wx.EVT_KILL_FOCUS, self.OnWL1Col)
self.MGHWLRefR.Bind(wx.EVT_KILL_FOCUS, self.OnWL2Col)
self.SRCHG.Bind(wx.EVT_KILL_FOCUS, self.OnHGCol)
self.SRCHG2.Bind(wx.EVT_KILL_FOCUS, self.OnHG2Col)
self.GCHG.Bind(wx.EVT_KILL_FOCUS, self.OnHGCol)
self.GCHG2.Bind(wx.EVT_KILL_FOCUS, self.OnHG2Col)
self.GCWLRefL.Bind(wx.EVT_KILL_FOCUS, self.OnWL1Col)
self.GCWLRefR.Bind(wx.EVT_KILL_FOCUS, self.OnWL2Col)
#Bind float control
self.MGHHG.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.MGHHG2.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.MGHWLRefL.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.MGHWLRefR.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.SRCHG.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.SRCHG2.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.GCHG.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.GCHG2.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.GCWLRefL.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.GCWLRefR.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.CMGHHG.Bind(wx.EVT_TEXT, self.OnTextUpdateDischargeMGH)
self.CMGHHG2.Bind(wx.EVT_TEXT, self.OnTextUpdateDischargeMGH)
self.CMGHWLRefL.Bind(wx.EVT_TEXT, self.OnTextUpdateDischargeMGH)
self.CMGHWLRefR.Bind(wx.EVT_TEXT, self.OnTextUpdateDischargeMGH)
self.CMGHHG.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.CMGHHG2.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.CMGHWLRefL.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.CMGHWLRefR.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
#Summary x
#Spacers
## preSummarySizer.Add((self.PreSummRowHeight, self.PreSummRowHeight), pos=(0, 0), span=(1, 1))
#The SRC col is a little longer
# preSummarySizer.Add(self.colHeaderWidth * 1.4 + 8, self.PreSummRowHeight, pos=(0, 5), span=(1, 1))
# preSummarySizer.Add(self.colHeaderWidth, self.PreSummRowHeight, pos=(0, 6), span=(1, 1))
# preSummarySizer.Add(checkBoxPanel, pos=(0, 0), span=(1,1))
# preSummarySizer.Add(self.hgCkbox, pos=(0, 1))
# preSummarySizer.Add(self.hg2Ckbox, pos=(0, 2))
# preSummarySizer.Add(self.wlr1Ckbox, pos=(0, 3))
# preSummarySizer.Add(self.wlr2Ckbox, pos=(0, 4))
# preSummarySizer.Add(weightMGHPanel, pos=(1, 0), span=(1, 1), flag=wx.EXPAND)
# preSummarySizer.Add(self.MGHHG, pos=(1, 1))
# preSummarySizer.Add(self.MGHHG2, pos=(1, 2), span=(1, 1))
# preSummarySizer.Add(self.MGHWLRefL, pos=(1, 3), span=(1, 1))
# preSummarySizer.Add(self.MGHWLRefR, pos=(1, 4), span=(1, 1))
# preSummarySizer.Add(mghMethodTxt, pos=(1, 5), span=(1, 1))
# preSummarySizer.Add(self.mghMethod, pos=(1, 6), span=(1, 3), flag=wx.EXPAND)
# preSummarySizer.Add(srcSummPanel, pos=(2, 0), span=(1, 1), flag=wx.EXPAND)
# preSummarySizer.Add(self.SRCHG, pos=(2, 1))
# preSummarySizer.Add(self.SRCHG2, pos=(2, 2), span=(1, 1))
# preSummarySizer.Add(mghCalBtn, pos=(1, 7), span=(1, 2), flag=wx.EXPAND)
# preSummarySizer.Add(gcSummPanel, pos=(3, 0), span=(1, 1), flag=wx.EXPAND)
# preSummarySizer.Add(self.GCHG, pos=(3, 1))
# preSummarySizer.Add(self.GCHG2, pos=(3, 2), span=(1, 1))
# preSummarySizer.Add(self.GCWLRefL, pos=(3, 3), span=(1, 1))
# preSummarySizer.Add(self.GCWLRefR, pos=(3, 4), span=(1, 1))
# preSummarySizer.Add(corrMghPanel, pos=(4, 0), span=(1, 1), flag=wx.EXPAND)
# preSummarySizer.Add(self.CMGHHG, pos=(4, 1))
# preSummarySizer.Add(self.CMGHHG2, pos=(4, 2), span=(1, 1))
# preSummarySizer.Add(self.CMGHWLRefL, pos=(4, 3), span=(1, 1))
# preSummarySizer.Add(self.CMGHWLRefR, pos=(4, 4), span=(1, 1))
# preSummarySizer.Add(stageRemarkPanel, pos=(5, 0), span=(1, 1), flag=wx.EXPAND)
preSummarySizer.Add(checkBoxPanel, 0, wx.EXPAND)
preSummarySizer.Add(weightMGHPanel, 1, wx.EXPAND)
preSummarySizer.Add(srcSummPanel, 1, wx.EXPAND)
preSummarySizer.Add(gcSummPanel, 1, wx.EXPAND)
preSummarySizer.Add(corrMghPanel, 1, wx.EXPAND)
preSummarySizer.Add(stageRemarkPanel, 1, wx.EXPAND)
# for i in range(1, 1):
# preSummarySizer.AddGrowableCol(i)
# for i in range(4):
# preSummarySizer.AddGrowableRow(i)
self.layoutSizerV.Add(self.measurementsScrollPanel, 1, wx.EXPAND)
self.layoutSizerV.Add(preSummaryPanel, 0, wx.EXPAND)
self.SetSizer(self.layoutSizerV)
# self.layoutSizerV.Layout()
self.Update()
self.Refresh()
# On '+' button click, add a new entry into the Stage Measurements
def OnTab(self, evt):
if evt.GetKeyCode() == wx.WXK_TAB:
if evt.GetEventObject() == self.stageLabelCtrl1:
self.stageLabelCtrl2.SetFocus()
if evt.GetEventObject() == self.stageLabelCtrl2:
self.bmLeft.SetFocus()
if evt.GetEventObject() == self.bmLeft:
self.bmRight.SetFocus()
if evt.GetEventObject() == self.bmRight:
print(self.entryNum)
if evt.GetId()/100 == 2:
for s in self.stageColumnPanel.GetChildren():
for t in s.GetChildren():
if t.GetId() == evt.GetId()%100+300:
t.SetFocus()
if evt.GetId()/100 == 3:
for s in self.stageColumnPanel2.GetChildren():
for t in s.GetChildren():
if t.GetId() == evt.GetId()%100+400:
t.SetFocus()
if evt.GetId()/100 == 4:
for s in self.wlColumnPanel.GetChildren():
for t in s.GetChildren():
if t.GetId() == evt.GetId()%100+500:
t.SetFocus()
if evt.GetId()/100 == 5:
for s in self.wlColumnPanel.GetChildren():
for t in s.GetChildren():
if t.GetId() == evt.GetId()%100+600:
t.SetFocus()
if evt.GetId()/100 == 6:
if evt.GetId()%100 < self.entryNum:
for s in self.stageColumnPanel.GetChildren():
for t in s.GetChildren():
if t.GetId() == evt.GetId()%100+300+1:
t.SetFocus()
else:
self.entryColumnPanel.SetFocus()
evt.Skip()
def OnAddPress(self, e):
if self.mode=="DEBUG":
print("add")
self.AddEntry()
def do_nothing(self,evt):
pass
# Adds a row to the Stage Measurements
# Add a new item in each of the column sizers
# set name based on entryNum
# name is used for deletion and ordering
def AddEntry(self, time=None, logger1=None, logger2=None, wl1=None, wl2=None):
#Button col
name = "%s" % self.entryNum
otherName = "%s" % (self.entryNum - 1)
button = wx.Button(self.entryColButtonPanel, id=10101+self.entryNum, label="+", name=name, size=(self.rowHeight, self.rowHeight))
oldButton = self.entryColButtonSizer.GetItem(self.entryNum-1).GetWindow()
oldButton.SetLabel('-')
oldButton.Unbind(wx.EVT_BUTTON)
oldButton.Bind(wx.EVT_BUTTON, self.OnRemovePress)
# oldButton.Bind(wx.EVT_BUTTON, self.CalculateAllMGH)
self.entryNum += 1
button.Bind(wx.EVT_BUTTON, self.OnAddPress)
self.entryColButtonSizer.Add(button, 0, wx.EXPAND)
if self.mode=="DEBUG":
print(name)
#Time col
# tc = masked.TimeCtrl(self.timeValPanel, size=(self.colHeaderWidth, self.rowHeight), displaySeconds=False, name=otherName, style=wx.TE_CENTRE, fmt24hr=True)
# tc.SetValue(wx.DateTime_Now().FormatTime())
tc = DropdownTime(False, id = 200+self.entryNum, parent=self.timeValPanel, name=otherName, size=(-1, self.rowHeight))
# tc.GetHourCtrl().Bind(wx.EVT_KILL_FOCUS, self.OnTimeUpdateMGH)
# tc.GetMinuteCtrl().Bind(wx.EVT_KILL_FOCUS, self.OnTimeUpdateMGH)
tc.Bind(wx.EVT_KEY_DOWN, self.OnTab)
tc.GetHourCtrl().Bind(wx.EVT_COMBOBOX, self.OnTimeUpdateMGH)
tc.GetMinuteCtrl().Bind(wx.EVT_COMBOBOX, self.OnTimeUpdateMGH)
tc.GetHourCtrl().Bind(wx.EVT_KEY_UP, self.OnTimeUpdateMGH)
tc.GetMinuteCtrl().Bind(wx.EVT_KEY_UP, self.OnTimeUpdateMGH)
tc.cBtn.Bind(wx.EVT_BUTTON, self.OnCBtn)
# tc.Bind(wx.EVT_KILL_FOCUS, self.CalculateAllMGH)
if time is not None:
tc.SetValue(time)
# print self.CompareTime(self.timeValSizer.GetItem(0).GetWindow().GetValue(), time)
self.timeValSizer.Add(tc, 0, wx.EXPAND)
#HG col
hg = MyTextCtrl(self.stagePanel, id = 300+self.entryNum, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.colHeaderWidth, self.rowHeight), name=otherName)
hg.SetMinSize((self.colHeaderWidth, self.rowHeight))
self.stageSizer.Add(hg, 1, wx.EXPAND)
hg.Bind(wx.EVT_TEXT, self.NumberControl)
hg.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
hg.Bind(wx.EVT_KILL_FOCUS, self.OnHGCalculateMGH)
hg.Bind(wx.EVT_KEY_DOWN, self.OnTab)
if logger1 != None:
hg.SetValue(logger1)
#HG col 2
hg2 = MyTextCtrl(self.stagePanel2, id = 400+self.entryNum, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.colHeaderWidth, self.rowHeight), name=otherName)
hg2.Bind(wx.EVT_TEXT, self.NumberControl)
hg2.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
hg2.Bind(wx.EVT_KILL_FOCUS, self.OnHG2CalculateMGH)
hg2.Bind(wx.EVT_KEY_DOWN, self.OnTab)
self.stageSizer2.Add(hg2, 0, wx.EXPAND)
if logger2 != None:
hg.SetValue(logger2)
#wl col L
wlL = MyTextCtrl(self.wlValLeftPanel, id = 500+self.entryNum, style=wx.TE_PROCESS_ENTER|wx.TE_CENTRE, size=(self.colHeaderWidth*2, self.rowHeight), name=otherName)
wlL.SetMinSize((self.colHeaderWidth*2, self.rowHeight))
wlL.Bind(wx.EVT_TEXT, self.NumberControl)
wlL.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round3)
wlL.Bind(wx.EVT_KILL_FOCUS, self.OnWlr1CalculateMGH)
wlL.Bind(wx.EVT_KEY_DOWN, self.OnTab)