-
Notifications
You must be signed in to change notification settings - Fork 3
/
GUI.pyw
1693 lines (1546 loc) · 87.9 KB
/
GUI.pyw
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import json
import shutil
import numpy as np
from ast import literal_eval
import matplotlib.pyplot as plt
from multiprocessing import Process
from pyPSCF import pyPSCF
from pyPSCF.BackTrajHysplit import *
import time
if sys.version_info.major >= 3:
from tkinter import *
from tkinter.messagebox import *
from tkinter.filedialog import *
import tkinter.scrolledtext as tkst
# ttk must be called last
from tkinter.ttk import *
else: # we are on Python 2
# import Queue
# tkinter modules
from Tkinter import *
from tkMessageBox import *
from tkFileDialog import *
import ScrolledText as tkst
# ttk must be called last
from ttk import *
# from modules.PSCF4GUI import PSCF, specie2study
# from modules.backTraj4GUI import BT
def arr2json(arr):
return json.dumps(arr.tolist())
def json2arr(astr, dtype):
return np.fromiter(json.loads(astr), dtype)
class TextRedirector(object):
"""Redirect the stdout to the window"""
def __init__(self, widget, tag="stdout"):
self.widget = widget
self.tag = tag
def write(self, str):
self.widget.configure(state="normal")
self.widget.insert("end", str, (self.tag,))
self.widget.configure(state="disabled")
class ContextMenu(Menu):
def __init__(self, x, y, widget):
"""A subclass of Menu, used to display a context menu in Text and
Entry widgets.
If the widget isn't active, some options do not appear"""
if sys.version_info.major >= 3:
super().__init__(None, tearoff=0) # otherwise Tk allows splitting it in a new window
else:
Menu.__init__(self, None, tearoff=0)
self.widget = widget
# MacOS uses a key called Command, instead of the usual Control used by Windows and Linux
# so prepare the accelerator strings accordingly
# For future reference, Mac also uses Option instead of Alt
# also, a little known fact about Python is that it *does* support using the ternary operator
# like in this case
control_key = "Command" if self.tk.call('tk', 'windowingsystem') == "aqua" else "Ctrl"
# str is necessary because in some instances a Tcl_Obj is returned instead of a string
if str(widget.cget('state')) in (ACTIVE, NORMAL): # do not add if state is readonly or disabled
self.add_command(label="Cut",
image=ICONS['cut'],
compound=LEFT,
accelerator='%s+X' % (control_key),
command=lambda: self.widget.event_generate("<<Cut>>"))
self.add_command(label="Copy",
image=ICONS['copy'],
compound=LEFT,
accelerator='%s+C' % (control_key),
command=lambda: self.widget.event_generate("<<Copy>>"))
if str(widget.cget('state')) in (ACTIVE, NORMAL):
self.add_command(label="Paste",
image=ICONS['paste'],
compound=LEFT,
accelerator='%s+V' % (control_key),
command=lambda: self.widget.event_generate("<<Paste>>"))
self.add_separator()
self.add_command(label="Select all",
image=ICONS['select_all'],
compound=LEFT,
accelerator='%s+A' % (control_key),
command=self.on_select_all)
self.tk_popup(x, y) # self.post does not destroy the menu when clicking out of it
def on_select_all(self):
# disabled Text widgets have a different way to handle selection
if isinstance(self.widget, Text):
# adding a SEL tag to a chunk of text causes it to be selected
self.widget.tag_add(SEL, "1.0", END)
elif isinstance(self.widget, Entry) or \
isinstance(self.widget, Combobox):
# apparently, the <<SelectAll>> event doesn't fire correctly if the widget is readonly
self.widget.select_range(0, END)
elif isinstance(self.widget, Spinbox):
self.widget.selection("range", 0, END)
class EntryContext(Entry):
def __init__(self, parent, **kwargs):
"""An enhanced Entry widget that has a right-click menu
Use like any other Entry widget"""
if sys.version_info.major >= 3:
super().__init__(parent, **kwargs)
else:
Entry.__init__(self, parent, **kwargs)
# on Mac the right button fires a Button-2 event, or so I'm told
# some mice don't even have two buttons, so the user is forced
# to use Command + the only button
# bear in mind that I don't have a Mac, so this point may be bugged
# bind also the context menu key, for those keyboards that have it
# that is, most of the Windows and Linux ones (however, in Win it's
# called App, while on Linux is called Menu)
# Mac doesn't have a context menu key on its keyboards, so no binding
# bind also the Shift+F10 shortcut (same as Menu/App key)
# the call to tk windowingsystem is justified by the fact
# that it is possible to install X11 over Darwin
# finally, bind the "select all" key shortcut
# again, Mac uses Command instead of Control
windowingsystem = self.tk.call('tk', 'windowingsystem')
if windowingsystem == "win32": # Windows, both 32 and 64 bit
self.bind("<Button-3>", self.on_context_menu)
self.bind("<KeyPress-App>", self.on_context_menu)
self.bind("<Shift-KeyPress-F10>", self.on_context_menu)
# for some weird reason, using a KeyPress binding to set the selection on
# a readonly Entry or disabled Text doesn't work, but a KeyRelease does
self.bind("<Control-KeyRelease-a>", self.on_select_all)
elif windowingsystem == "aqua": # MacOS with Aqua
self.bind("<Button-2>", self.on_context_menu)
self.bind("<Control-Button-1>", self.on_context_menu)
self.bind("<Command-KeyRelease-a>", self.on_select_all)
elif windowingsystem == "x11": # Linux, FreeBSD, Darwin with X11
self.bind("<Button-3>", self.on_context_menu)
self.bind("<KeyPress-Menu>", self.on_context_menu)
self.bind("<Shift-KeyPress-F10>", self.on_context_menu)
self.bind("<Control-KeyRelease-a>", self.on_select_all)
def on_context_menu(self, event):
if str(self.cget('state')) != DISABLED:
ContextMenu(event.x_root, event.y_root, event.widget)
def on_select_all(self, event):
self.select_range(0, END)
class SelectFile(LabelFrame):
def __init__(self, parent, textvariable=None, title="Directory", **kwargs):
"""A subclass of LabelFrame sporting a readonly Entry and a Button with
a folder icon.
It comes complete with a context menu and a directory selection screen.
"""
if sys.version_info.major >= 3:
super().__init__(parent, text=title, **kwargs)
else:
LabelFrame.__init__(self, parent, text=title, **kwargs)
self.textvariable = textvariable
self.dir_entry = EntryContext(self,
width=40,
textvariable=self.textvariable)
self.dir_entry.pack(side=LEFT,
fill=BOTH,
expand=YES)
self.dir_button = Button(self,
image=ICONS['browse'],
compound=LEFT,
text="Browse...",
command=self.on_browse_file)
self.dir_button.pack(side=LEFT)
self.clear_button = Button(self,
image=ICONS['clear16'],
compound=LEFT,
text="Clear",
command=self.on_clear)
self.clear_button.pack(side=LEFT)
def on_browse_file(self):
# if the user already selected a directory, try to use it
current_dir = os.path.dirname(self.textvariable.get())
if os.path.exists(current_dir):
directory = askopenfilename(initialdir=current_dir)
# otherwise attempt to detect the user's userdata folder
else:
# os.path.expanduser gets the current user's home directory on every platform
if sys.platform == "win32":
# get userdata directory on Windows
# it assumes that you choose to store userdata in the My Games directory
# while installing Wesnoth
userdata = os.path.join(os.path.expanduser("~"),
"Documents")
elif sys.platform.startswith("linux"): # we're on Linux; usually this string is 'linux2'
userdata = os.path.join(os.path.expanduser("~"),
"Documents")
elif sys.platform == "darwin": # we're on MacOS
# bear in mind that I don't have a Mac, so this point may be bugged
userdata = os.path.join(os.path.expanduser("~"),
"Library")
else: # unknown system; if someone else wants to add other rules, be my guest
userdata="."
if os.path.exists(userdata): # we may have gotten it wrong
directory = askopenfilename(initialdir=userdata)
else:
directory = askopenfilename(initialdir=".")
if directory:
# use os.path.normpath, so on Windows the usual backwards slashes
# are correctly shown
self.textvariable.set(os.path.normpath(directory))
def on_clear(self):
self.textvariable.set("")
class SelectDirectory(LabelFrame):
def __init__(self, parent, textvariable=None, title="Directory", **kwargs):
"""A subclass of LabelFrame sporting a readonly Entry and a Button with
a folder icon.
It comes complete with a context menu and a directory selection screen.
"""
if sys.version_info.major >= 3:
super().__init__(parent, text=title, **kwargs)
else:
LabelFrame.__init__(self, parent, text=title, **kwargs)
self.textvariable = textvariable
self.dir_entry = EntryContext(self,
width=40,
textvariable=self.textvariable)
self.dir_entry.pack(side=LEFT,
fill=BOTH,
expand=YES)
self.dir_button = Button(self,
image=ICONS['browse'],
compound=LEFT,
text="Browse...",
command=self.on_browse_dir)
self.dir_button.pack(side=LEFT)
self.clear_button = Button(self,
image=ICONS['clear16'],
compound=LEFT,
text="Clear",
command=self.on_clear)
self.clear_button.pack(side=LEFT)
def on_browse_dir(self):
# if the user already selected a directory, try to use it
current_dir = self.textvariable.get()
if os.path.exists(current_dir):
directory = askdirectory(initialdir=current_dir)
# otherwise attempt to detect the user's userdata folder
else:
# os.path.expanduser gets the current user's home directory on every platform
if sys.platform == "win32":
# get userdata directory on Windows
userdata = os.path.join(os.path.expanduser("~"),
"Documents")
elif sys.platform.startswith("linux"): # we're on Linux;
# usually this string is 'linux2'
userdata = os.path.join(os.path.expanduser("~"),
"Documents")
elif sys.platform == "darwin": # we're on MacOS
# bear in mind that I don't have a Mac, so this point may be bugged
userdata = os.path.join(os.path.expanduser("~"),
"Library")
else: # unknown system;
# if someone else wants to add other rules, be my guest
userdata="."
if os.path.exists(userdata): # we may have gotten it wrong
directory = askdirectory(initialdir=userdata)
else:
directory = askdirectory(initialdir=".")
if directory:
# use os.path.normpath, so on Windows the usual backwards slashes
# are correctly shown
self.textvariable.set(os.path.normpath(directory)+os.sep)
# app.exist_file()
def on_clear(self):
self.textvariable.set("")
class StationTab(Frame):
def __init__(self, parent):
if sys.version_info.major >= 3:
super().__init__(parent)
else:
Frame.__init__(self, parent)
self.station_frame = LabelFrame(self,
text="Stations parameters")
self.station_frame.grid(row=0,
column=0,
sticky=N+E+S+W)
self.info = Label(self.station_frame,
text="Manage station longitude, latitude and altitude.")
self.info.grid(row=0,
column=0,
sticky=N+E+S+W)
# load station
with open('parameters'+os.sep+'locationStation.json', 'r') as dataFile:
self.locStation = json.load(dataFile)
# ===== Station to modify or delete ==================================
self.modif_frame = LabelFrame(self.station_frame,
text="Modify existing station")
self.modif_frame.grid(row=1,
column=0,
sticky=N+E+S+W)
self.station = StringVar()
# maybe the worth method to get the first key of this dict...
for key in self.locStation:
self.station.set(key)
break
self.lat = StringVar()
self.lon = StringVar()
self.alt = StringVar()
self.lat.set(self.locStation[self.station.get()][0])
self.lon.set(self.locStation[self.station.get()][1])
self.alt.set(self.locStation[self.station.get()][2])
self.stationLabel = Label(self.modif_frame, text="Station", justify=LEFT)
self.stationLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.stationOptionMenu = OptionMenu(self.modif_frame, self.station, self.station.get(), *self.locStation, command=self.station_callback)
self.stationOptionMenu.grid(row=0, column=1, columnspan=3, sticky=W, padx=5, pady=5)
self.latLabel = Label(self.modif_frame, text="Latitude", justify=LEFT)
self.latLabel.grid(row=1, column=0, sticky=E+W, padx=5, pady=5)
self.latEntry = EntryContext(self.modif_frame, width=10, textvariable=self.lat)
self.latEntry.grid(row=1, column=1, sticky=E+W, padx=5, pady=5)
self.lonLabel = Label(self.modif_frame, text="Longitude", justify=LEFT)
self.lonLabel.grid(row=2, column=0, sticky=E+W, padx=5, pady=5)
self.lonEntry = EntryContext(self.modif_frame, width=10, textvariable=self.lon)
self.lonEntry.grid(row=2, column=1, sticky=E+W, padx=5, pady=5)
self.altLabel = Label(self.modif_frame, text="Altitude", justify=LEFT)
self.altLabel.grid(row=3, column=0, sticky=E+W, padx=5, pady=5)
self.altEntry = EntryContext(self.modif_frame, width=10, textvariable=self.alt)
self.altEntry.grid(row=3, column=1, sticky=E+W, padx=5, pady=5)
# ===== Button
self.buttonBoxModif = Frame(self.modif_frame)
self.buttonBoxModif.grid(row=4,
column=0,
columnspan=4,
sticky=E+W)
self.save_button = Button(self.buttonBoxModif,
text="Save",
image=ICONS['save'],
compound=LEFT,
width=15, # to avoid changing size when callback is called
command=self.on_save)
self.save_button.pack(side=LEFT, padx=5, pady=5)
self.delete_button = Button(self.buttonBoxModif,
text="Delete",
# image=ICONS['save'],
compound=LEFT,
width=15, # to avoid changing size when callback is called
command=self.on_delete)
self.delete_button.pack(side=RIGHT, padx=5, pady=5)
# ===== Add a station ===============================================
self.add_frame = LabelFrame(self.station_frame,
text="Add a new station")
self.add_frame.grid(row=2,
column=0,
sticky=N+E+S+W,
padx=5,
pady=5)
self.addLabelName = Label(self.add_frame, text="Station name")
self.addLabelName.grid(row=0, column=0, sticky=E+W, padx=5, pady=5)
self.addEntryName = EntryContext(self.add_frame, width=10)
self.addEntryName.grid(row=0, column=1, sticky=E+W, padx=5, pady=5)
self.addLabelLatitude = Label(self.add_frame, text="Latitude")
self.addLabelLatitude.grid(row=1, column=0, sticky=E+W, padx=5, pady=5)
self.addEntryLatitude = EntryContext(self.add_frame, width=10)
self.addEntryLatitude.grid(row=1, column=1, sticky=E+W, padx=5, pady=5)
self.addLabelLongitude = Label(self.add_frame, text="Longitude")
self.addLabelLongitude.grid(row=2, column=0, sticky=E+W, padx=5, pady=5)
self.addEntryLongitude = EntryContext(self.add_frame, width=10)
self.addEntryLongitude.grid(row=2, column=1, sticky=E+W, padx=5, pady=5)
self.addLabelAltitude = Label(self.add_frame, text="Altitude")
self.addLabelAltitude.grid(row=3, column=0, sticky=E+W, padx=5, pady=5)
self.addEntryAltitude = EntryContext(self.add_frame, width=10)
self.addEntryAltitude.grid(row=3, column=1, sticky=E+W, padx=5, pady=5)
# ===== Button
self.buttonBoxAdd = Frame(self.add_frame)
self.buttonBoxAdd.grid(row=4,
column=0,
columnspan=2,
sticky=E+W)
self.save_button_add = Button(self.buttonBoxAdd,
text="Save",
image=ICONS['save'],
compound=LEFT,
width=15, # to avoid changing size when callback is called
command=self.on_save_add)
self.save_button_add.pack(side=LEFT, padx=5, pady=5)
def station_callback(self, event):
"""Update the lat/lon/alt for the station"""
self.lat.set(self.locStation[self.station.get()][0])
self.lon.set(self.locStation[self.station.get()][1])
self.alt.set(self.locStation[self.station.get()][2])
def on_save(self):
"""Save the selected lon/lat/lat station from the 'locationStation.json' file"""
with open('parameters'+os.sep+'locationStation_tmp.json', 'w') as fileSave:
try:
self.locStation[self.station.get()] = [self.lat.get(), self.lon.get(), self.alt.get()]
except (ValueError, SyntaxError):
os.remove('parameters'+os.sep+'locationStation_tmp.json')
showinfo("""Error""", """There is a problem somewhere... \
Probably a typo. The 'locationStation.json' file is \
not updated due to this problem.""")
return 0
json.dump(self.locStation, fileSave, indent=4)
shutil.copy('parameters'+os.sep+'locationStation_tmp.json', 'parameters'+os.sep+'locationStation.json')
os.remove('parameters'+os.sep+'locationStation_tmp.json')
print('Station '+self.station.get()+' saved')
return 1
def on_delete(self):
"""Delete the selected station from the 'locationStation.json' file"""
with open('parameters'+os.sep+'locationStation_tmp.json', 'w') as fileSave:
try:
# remove the station from the dict
rep = askokcancel(title="Beware!",
message="You are about to delete the station "+self.station.get()+", are you sure of it?")
if rep:
self.locStation.pop(self.station.get())
except (ValueError, SyntaxError, KeyError):
os.remove('parameters'+os.sep+'locationStation_tmp.json')
showinfo("""Error""", """There is a problem somewhere...\
Probably a typo. The 'locationStation.json' file is \
not updated due to this problem.""")
return 0
json.dump(self.locStation, fileSave, indent=4)
shutil.copy('parameters'+os.sep+'locationStation_tmp.json', 'parameters'+os.sep+'locationStation.json')
os.remove('parameters'+os.sep+'locationStation_tmp.json')
print('Station '+self.station.get()+' deleted')
# TODO: change station and update the list
for key in self.locStation:
self.station.set(key)
return
self.station_callback()
return 1
def on_save_add(self):
"""Save the new station into the 'locationStation.json' file"""
# check if the station already exist
for key in self.locStation:
if key == self.addEntryName.get():
showinfo("""Error""", """The station already exist, try to \
update it instead of add it again.""")
return 0
with open('parameters'+os.sep+'locationStation_tmp.json', 'w') as fileSave:
try:
# check if the coordinate are float
float(self.addEntryLatitude.get())
float(self.addEntryLongitude.get())
float(self.addEntryAltitude.get())
except (ValueError, SyntaxError):
os.remove('parameters'+os.sep+'locationStation_tmp.json')
showinfo("""Error""", """There is a problem somewhere... \
Probably a typo. The 'locationStation.json' file is \
not updated due to this problem.""")
return 0
self.locStation[self.addEntryName.get()] = [self.addEntryLatitude.get(), self.addEntryLongitude.get(), self.addEntryAltitude.get()]
json.dump(self.locStation, fileSave, indent=4)
shutil.copy('parameters'+os.sep+'locationStation_tmp.json', 'parameters'+os.sep+'locationStation.json')
os.remove('parameters'+os.sep+'locationStation_tmp.json')
print('Station '+self.addEntryName.get()+' added')
# TODO
# add a callback so when a station is add, we can see it in the list
return 1
# class TextoutputTab(Frame):
# def __init__(self, parent):
# if sys.version_info.major>=3:
# super().__init__(parent)
# else:
# Frame.__init__(self, parent)
#
# self.output_frame = LabelFrame(self,
# text="Output")
# self.output_frame.grid(row=0,
# column=0,
# sticky=N+E+S+W)
# # ==== Text widget for output ========================================
# self.output_text = tkst.ScrolledText(self.output_frame,
# wrap="word",
# width=200,
# height=30)
# self.output_text.grid(row=0,
# column=0,
# sticky=N+E+S+W)
# self.output_text.tag_configure("stderr", foreground="#b22222")
class BacktrajTab(Frame):
def __init__(self, parent):
if sys.version_info.major >= 3:
super().__init__(parent)
else:
Frame.__init__(self, parent)
# Import local Param from the JSON file
with open('parameters'+os.sep+'localParamBackTraj.json', 'r') as dataFile:
self.param = json.load(dataFile)
with open('parameters'+os.sep+'locationStation.json', 'r') as dataFile:
self.locStation = json.load(dataFile)
self.Backtraj_frame = LabelFrame(self,
text="Back-Trajectory options")
self.Backtraj_frame.grid(row=0,
column=0,
sticky=N+E+S+W)
# Directory
self.dirGDAS = StringVar()
self.dirGDAS.set(self.param["dirGDAS"])
self.dirGDASSelect = SelectDirectory(self.Backtraj_frame, textvariable=self.dirGDAS, title="Meteo (GDAS) directory")
self.dirGDASSelect.grid(row=0, column=0, columnspan=2, sticky=E+W, padx=5, pady=5)
self.dirHysplit = StringVar()
self.dirHysplit.set(self.param["dirHysplit"])
self.dirHysplitSelect = SelectDirectory(self.Backtraj_frame, textvariable=self.dirHysplit, title="Hysplit directory")
self.dirHysplitSelect.grid(row=1, column=0, columnspan=2, sticky=E+W, padx=5, pady=5)
self.dirOutput = StringVar()
self.dirOutput.set(self.param["dirOutput"])
self.dirOutputSelect = SelectDirectory(self.Backtraj_frame, textvariable=self.dirOutput, title="Output directory")
self.dirOutputSelect.grid(row=2, column=0, columnspan=2, sticky=E+W, padx=5, pady=5)
# ===== Station Frame ===================
self.station_frame = LabelFrame(self.Backtraj_frame,
text="Station")
self.station_frame.grid(row=3,
column=0,
sticky=E+W+S+N,
padx=5,
pady=5)
# ===== Select station
self.station = StringVar()
self.station.set(self.param["station"])
self.stationLabel = Label(self.station_frame, text="Station", justify=LEFT)
self.stationLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.stationOptionMenu = OptionMenu(self.station_frame, self.station, self.param["station"], *self.locStation, command=self.station_callback)
self.stationOptionMenu.grid(row=0, column=1, columnspan=3, sticky=W, padx=5, pady=5)
# ===== Station coord.
self.lon = StringVar()
self.lon.set(self.locStation[self.station.get()][1])
self.lonLabel = Label(self.station_frame, text="Longitude", justify=LEFT)
self.lonLabel.grid(row=1, column=0, sticky=W, padx=5, pady=5)
self.lonBackTrajEntry = EntryContext(self.station_frame, width=10, textvariable=self.lon)
self.lonBackTrajEntry.grid(row=1, column=1, sticky=W, padx=5, pady=5)
self.lat = StringVar()
self.lat.set(self.locStation[self.station.get()][0])
self.latLabel = Label(self.station_frame, text="Latitude", justify=LEFT)
self.latLabel.grid(row=2, column=0, sticky=W, padx=5, pady=5)
self.latBackTrajEntry = EntryContext(self.station_frame, width=10, textvariable=self.lat)
self.latBackTrajEntry.grid(row=2, column=1, sticky=W, padx=5, pady=5)
self.alt = StringVar()
self.alt.set(self.locStation[self.station.get()][2])
self.altLabel = Label(self.station_frame, text="Altitude", justify=LEFT)
self.altLabel.grid(row=1, column=4, sticky=W, padx=5, pady=5)
self.altEntry = EntryContext(self.station_frame, width=10, textvariable=self.alt)
self.altEntry.grid(row=1, column=5, sticky=W, padx=5, pady=5)
# ===== Time frame ===========================
self.time_frame = LabelFrame(self.Backtraj_frame,
text="Date")
self.time_frame.grid(row=3,
column=1,
sticky=E+W+S+N,
padx=5,
pady=5)
# Start time
self.startLabel = Label(self.time_frame, text="Starting day (YYYY-MM-DD HH)", justify=LEFT)
self.startLabel.grid(row=0,
column=0,
sticky=E+W+S+N,
padx=5, pady=5)
self.buttonMin = Frame(self.time_frame)
self.buttonMin.grid(row=0, column=1, sticky=W+E+S+N, padx=5, pady=5)
self.dateMin = StringVar()
self.dateMin.set(self.param["dateMin"])
self.dateMinEntry = EntryContext(self.buttonMin, width=20,
textvariable=self.dateMin).pack(side=LEFT)
# End date
self.endLabel = Label(self.time_frame, text="Ending day (YYYY-MM-DD HH)", justify=LEFT)
self.endLabel.grid(row=1, column=0,
sticky=E+W+S+N,
padx=5, pady=0)
self.buttonMax = Frame(self.time_frame)
self.buttonMax.grid(row=1, column=1, sticky=W+E+S+N, padx=5, pady=5)
self.dateMax = StringVar()
self.dateMax.set(self.param["dateMax"])
self.dateMaxEntry = EntryContext(self.buttonMax, width=20,
textvariable=self.dateMax).pack(side=LEFT)
#
# self.YY = StringVar()
# self.YY.set(self.param["date"][0])
# self.YYLabel = Label(self.buttonStart, text="YY:", justify=LEFT).pack(side=LEFT)
# self.YYEntry = EntryContext(self.buttonStart, width=5, textvariable=self.YY).pack(side=LEFT)
# self.MM = StringVar()
# self.MM.set(self.param["date"][1])
# self.MMLabel = Label(self.buttonStart, text="MM:", justify=LEFT).pack(side=LEFT)
# self.MMEntry = EntryContext(self.buttonStart, width=5, textvariable=self.MM).pack(side=LEFT)
# self.DD = StringVar()
# self.DD.set(self.param["date"][2])
# self.DDLabel = Label(self.buttonStart, text="DD:", justify=LEFT).pack(side=LEFT)
# self.DDEntry = EntryContext(self.buttonStart, width=5, textvariable=self.DD).pack(side=LEFT)
# self.HH = StringVar()
# self.HH.set(self.param["date"][3])
# self.HHLabel = Label(self.buttonStart, text="HH:", justify=LEFT).pack(side=LEFT)
# self.HHEntry = EntryContext(self.buttonStart, width=5, textvariable=self.HH).pack(side=LEFT)
# # End time
# self.endLabel = Label(self.time_frame, text="Ending day (YY/MM/DD/HH)", justify=LEFT)
# self.endLabel.grid(row=2, column=0,
# sticky=E+W,
# padx=5, pady=0)
# self.buttonEnd = Frame(self.time_frame)
# self.buttonEnd.grid(row=3, column=0, sticky=W+E, padx=5, pady=5)
# self.YYend = StringVar()
# self.YYend.set(self.param["dateEnd"][0])
# self.YYendLabel = Label(self.buttonEnd, text="YY:", justify=LEFT).pack(side=LEFT)
# self.YYendEntry = EntryContext(self.buttonEnd, width=5, textvariable=self.YYend).pack(side=LEFT)
# self.MMend = StringVar()
# self.MMend.set(self.param["dateEnd"][1])
# self.MMendLabel = Label(self.buttonEnd, text="MM:", justify=LEFT).pack(side=LEFT)
# self.MMendEntry = EntryContext(self.buttonEnd, width=5, textvariable=self.MMend).pack(side=LEFT)
# self.DDend = StringVar()
# self.DDend.set(self.param["dateEnd"][2])
# self.DDendLabel = Label(self.buttonEnd, text="DD:", justify=LEFT).pack(side=LEFT)
# self.DDendEntry = EntryContext(self.buttonEnd, width=5, textvariable=self.DDend).pack(side=LEFT)
# self.HHend = StringVar()
# self.HHend.set(self.param["dateEnd"][3])
# self.HHendLabel = Label(self.buttonEnd, text="HH:", justify=LEFT).pack(side=LEFT)
# self.HHendEntry = EntryContext(self.buttonEnd, width=5, textvariable=self.HHend).pack(side=LEFT)
# ===== Back Traj param ===========================================
self.bt_frame = LabelFrame(self.Backtraj_frame,
text="Back-traj parameters")
self.bt_frame.grid(row=4,
column=0,
sticky=E+W+S+N,
padx=5,
pady=5)
# Time for BT
self.hBT = StringVar()
self.hBT.set(self.param["hBT"])
self.hBTLabel = Label(self.bt_frame, text="Time for the back-trajectories [h]", justify=LEFT)
self.hBTLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.hBTEntry = EntryContext(self.bt_frame, width=5, textvariable=self.hBT)
self.hBTEntry.grid(row=0, column=1, sticky=W, padx=5, pady=5)
# step between 2 BT
self.stepHH = StringVar()
self.stepHH.set(self.param["stepHH"])
self.stepHHLabel = Label(self.bt_frame, text="Step between 2 starting back-trajectories. [h]", justify=LEFT)
self.stepHHLabel.grid(row=2, column=0, sticky=W, padx=5, pady=5)
self.stepHHEntry = EntryContext(self.bt_frame, width=5, textvariable=self.stepHH)
self.stepHHEntry.grid(row=2, column=1, sticky=W, padx=5, pady=5)
# ===== CPU frame ===========================
self.cpu_frame = LabelFrame(self.Backtraj_frame,
text="CPU")
self.cpu_frame.grid(row=4,
column=1,
sticky=E+W+S+N,
padx=5,
pady=5)
self.cpu = IntVar()
self.cpu.set(1) # os.cpu_count()-1)
self.CPULabel = Label(self.cpu_frame, text="Number of CPU")
self.CPULabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.CPUEntry = EntryContext(self.cpu_frame, width=5, textvariable=self.cpu)
self.CPUEntry.grid(row=0, column=1, sticky=W, padx=5, pady=5)
self.l1 = Label(self.cpu_frame, text="Each CPU is uses to its maximum. So be careful.")
self.l1.grid(row=1, column=0, columnspan=5, sticky=W, padx=5, pady=5)
# ====================================================================
self.columnconfigure(0, weight=10)
self.Backtraj_frame.columnconfigure(0, weight=10)
self.Backtraj_frame.columnconfigure(1, weight=10)
self.rowconfigure(0, weight=10)
self.Backtraj_frame.rowconfigure(0, weight=1)
self.Backtraj_frame.rowconfigure(1, weight=1)
self.Backtraj_frame.rowconfigure(2, weight=1)
self.Backtraj_frame.rowconfigure(3, weight=10)
self.Backtraj_frame.rowconfigure(4, weight=10)
self.exist_file()
def on_clear(self):
self.text.configure(state=NORMAL)
self.text.delete(1.0, END)
self.text.configure(state=DISABLED)
def checkParam(self):
dirOutput = self.param["dirOutput"]+os.sep
HysplitExec = self.param["dirHysplit"]+os.sep+"exec"+os.sep+"hyts_std"
if sys.platform == "win32":
HysplitExec += ".exe"
dirHysplit = self.param["dirHysplit"]+os.sep+"working"+os.sep
dirGDAS = self.param["dirGDAS"]+os.sep
CONTROL = dirHysplit+"CONTROL"
if not os.path.exists(dirGDAS):
showerror("Error", "The path for the GDAS file can not be found...")
return (0, 0)
if not os.path.exists(dirHysplit):
showerror("Error", "The Hysplit directory command do not exist...")
return (0, 0)
if not os.path.exists(HysplitExec):
showerror("Error", "The Hysplit 'hyts_std' command do not exist...")
return (0, 0)
if os.path.exists(dirOutput) == False:
if sys.version_info.major >= 3:
a = str(input("The output directory does not exist. Make one? ([y], n) "))
else:
a = str(raw_input("The output directory does not exist. Make one? ([y], n) "))
if a == "y" or a == "Y" or a == "" or a == "yes":
os.makedirs(dirOutput)
else:
showerror("Error", "Script exit")
return (0, 0)
return (1, self.param["cpu"])
def on_save(self):
with open('parameters'+os.sep+'localParamBackTraj_tmp.json', 'w') as fileSave:
try:
paramNew = {
"dirGDAS": self.dirGDAS.get(),
"dirHysplit": self.dirHysplit.get(),
"dirOutput": self.dirOutput.get(),
"lat": self.lat.get(),
"lon": self.lon.get(),
"alt": self.alt.get(),
"station": self.station.get(),
"hBT": self.hBT.get(),
"cpu": self.cpu.get(),
"stepHH": self.stepHH.get(),
"dateMin": self.dateMin.get(),
"dateMax": self.dateMax.get(),
}
except (ValueError, SyntaxError):
os.remove('parameters'+os.sep+'localParamBackTraj_tmp.json')
showinfo("""Error""", """There is a problem somewhere... Probably a typo. The 'localParamBackTraj.json' file is not updated due to this problem.""")
return 0
json.dump(paramNew, fileSave, indent=4)
shutil.copy('parameters'+os.sep+'localParamBackTraj_tmp.json', 'parameters'+os.sep+'localParamBackTraj.json')
os.remove('parameters'+os.sep+'localParamBackTraj_tmp.json')
# update the "param" dict.
self.param = paramNew
return 1
def station_callback(self, event):
self.lat.set(self.locStation[self.station.get()][0])
self.lon.set(self.locStation[self.station.get()][1])
self.dirOutput.set(os.path.normpath(self.dirOutput.get()+os.sep+'..'+os.sep+self.station.get())+os.sep)
self.exist_file()
def exist_file(self):
if not os.path.exists(self.dirOutput.get()):
self.dirOutputSelect.dir_entry.config(foreground='red')
else:
self.dirOutputSelect.dir_entry.config(foreground='black')
class PSCFTab(Frame):
def __init__(self, parent):
if sys.version_info.major >= 3:
super().__init__(parent)
else:
Frame.__init__(self, parent)
# Import local Param from the JSON file
with open('parameters'+os.sep+'localParamPSCF.json', 'r') as dataFile:
self.param = json.load(dataFile)
with open('parameters'+os.sep+'locationStation.json', 'r') as dataFile:
self.locStation = json.load(dataFile)
self.PSCF_frame = LabelFrame(self,
text="PSCF options")
self.PSCF_frame.grid(row=0,
column=0,
sticky=N+E+S+W)
# ===== Directory and concentration file ===============================
self.dirBackTraj = StringVar()
self.dirBackTraj.set(self.param["dirBackTraj"])
self.dirBackTrajSelect = SelectDirectory(self.PSCF_frame, textvariable=self.dirBackTraj, title="Back-trajectory directory")
self.dirBackTrajSelect.grid(row=0, columnspan=3, sticky=E+W, padx=5)
self.Cfile = StringVar()
self.Cfile.set(self.param["Cfile"])
self.CfileSelect = SelectFile(self.PSCF_frame, textvariable=self.Cfile, title="Concentration file")
self.CfileSelect.grid(row=1, columnspan=3, sticky=E+W, padx=5)
# ============ Station Frame ===========================================
self.station_frame = LabelFrame(self.PSCF_frame,
text="Station")
self.station_frame.grid(row=2,
column=0,
sticky=E+W+S+N,
padx=5,
pady=5)
# Station name
self.station = StringVar()
self.station.set(self.param["station"])
self.stationLabel = Label(self.station_frame, text="Station", justify=LEFT)
self.stationLabel.grid(row=0, column=0, columnspan=2, sticky=W, padx=5, pady=5)
self.stationOptionMenu = OptionMenu(self.station_frame, self.station,
self.param["station"], *self.locStation, command=self.station_callback)
self.stationOptionMenu.grid(row=0, column=2, sticky=W, padx=5, pady=5)
self.stationOptionMenu.configure(width=6)
# Prefix for the back-trajectory
self.prefixTraj = StringVar()
self.prefixTraj.set(self.param["prefix"])
self.prefixTrajLabel = Label(self.station_frame, text="Back-traj prefix", justify=LEFT)
self.prefixTrajLabel.grid(row=1, column=0, columnspan=2, sticky=W, padx=5, pady=5)
self.prefixTrajEntry = EntryContext(self.station_frame, width=10, textvariable=self.prefixTraj)
self.prefixTrajEntry.grid(row=1, column=2, sticky=W, padx=5, pady=5)
# Ref point
self.lon0 = StringVar()
self.lon0.set(self.locStation[self.param["station"]][1])
self.lon0Label = Label(self.station_frame, text="Lon", justify=LEFT)
self.lon0Label.grid(row=2, column=0, sticky=W, padx=5, pady=5)
self.lon0Entry = EntryContext(self.station_frame, width=5, textvariable=self.lon0)
self.lon0Entry.grid(row=2, column=1, sticky=W, padx=5, pady=5)
self.lat0 = StringVar()
self.lat0.set(self.locStation[self.param["station"]][0])
self.lat0Label = Label(self.station_frame, text="Lat", justify=LEFT)
self.lat0Label.grid(row=3, column=0, sticky=W, padx=5, pady=5)
self.lat0Entry = EntryContext(self.station_frame, width=5, textvariable=self.lat0)
self.lat0Entry.grid(row=3, column=1, sticky=W, padx=5, pady=5)
# ============== Back Traj Frame ========================
self.Backtraj_frame = LabelFrame(self.PSCF_frame,
text="Back Trajectory")
self.Backtraj_frame.grid(row=2,
column=1,
sticky=E+W+S+N,
padx=5,
pady=5)
# Back traj
self.backTraj = IntVar()
self.backTraj.set(self.param["backTraj"])
self.backTrajLabel = Label(self.Backtraj_frame, text="Back-trajectory [h]", justify=LEFT)
self.backTrajLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.backTrajEntry = EntryContext(self.Backtraj_frame, width=5, textvariable=self.backTraj)
self.backTrajEntry.grid(row=0, column=1, sticky=W, padx=5, pady=5)
# Add hour
self.add_hour = StringVar()
self.add_hour.set(self.param["add_hour"])
self.add_hourLabel = Label(self.Backtraj_frame, text="Add hour", justify=LEFT)
self.add_hourLabel.grid(row=2, column=0, sticky=W, padx=5, pady=5)
self.add_hourEntry = EntryContext(self.Backtraj_frame, width=28, textvariable=self.add_hour, justify=LEFT)
self.add_hourEntry.grid(row=3, column=0, columnspan=2, sticky=W, padx=5, pady=5)
# Cut with rain
self.cutWithRain = BooleanVar()
self.cutWithRain.set(self.param["cutWithRain"])
self.cutWithRainCheck = Checkbutton(self.Backtraj_frame, text="Cut when it's raining", variable=self.cutWithRain)
self.cutWithRainCheck.grid(row=4, column=0, sticky=W, padx=5, pady=5)
# ============== Weighting Function Frame ========================
self.wf_frame = LabelFrame(self.PSCF_frame,
text="Weighting function")
self.wf_frame.grid(row=2,
column=2,
sticky=E+W+S+N,
padx=5,
pady=5)
# Weighting function
self.weigthingFunction = BooleanVar()
self.weigthingFunction.set(self.param["wF"])
self.weigthingFunctionCheck = Checkbutton(self.wf_frame, text="Use the weighting function", variable=self.weigthingFunction, command=self.wf_callback)
self.weigthingFunctionCheck.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.wf_manual = BooleanVar()
self.wf_manual.set(self.param["wFmanual"])
manualChoice = ("Auto", "User defined")[self.wf_manual.get()]
self.varChoiceManual = StringVar(self.wf_frame)
self.varChoiceManual.set(manualChoice)
self.wf_manualChoice = OptionMenu(self.wf_frame, self.varChoiceManual, manualChoice, "User defined", "Auto", command=self.wf_manual_callback)
self.wf_manualChoice.grid(row=0, column=1, sticky=W, padx=5, pady=5)
self.wf_frame_manual_choice = Frame(self.wf_frame)
self.wf_frame_manual_choice.grid(row=1, column=0, columnspan=2, sticky=W, padx=5, pady=5)
self.wFbox0 = Frame(self.wf_frame_manual_choice)
self.wFbox0.grid(row=1, column=0, padx=5, sticky=E)
self.wFbox1 = Frame(self.wf_frame_manual_choice)
self.wFbox1.grid(row=2, column=0, padx=5, sticky=E)
self.wFbox2 = Frame(self.wf_frame_manual_choice)
self.wFbox2.grid(row=3, column=0, padx=5, sticky=E)
self.wFbox3 = Frame(self.wf_frame_manual_choice)
self.wFbox3.grid(row=4, column=0, padx=5, sticky=E)
self.wFlim0 = StringVar()
self.wFlim0.set(self.param["wFlim"][0])
self.wFlim1 = StringVar()
self.wFlim1.set(self.param["wFlim"][1])
self.wFlim2 = StringVar()
self.wFlim2.set(self.param["wFlim"][2])
self.wFval0 = StringVar()
self.wFval0.set(self.param["wFval"][0])
self.wFval1 = StringVar()
self.wFval1.set(self.param["wFval"][1])
self.wFval2 = StringVar()
self.wFval2.set(self.param["wFval"][2])
self.wFval3 = StringVar()
self.wFval3.set(self.param["wFval"][3])
self.wFlim0Label = Label(self.wFbox0, text="d < ", justify=LEFT).pack(side=LEFT)
self.wFlim0Entry = EntryContext(self.wFbox0, width=5, textvariable=self.wFlim0).pack(side=LEFT)
self.wFval0Label = Label(self.wFbox0, text="*d_max=", justify=LEFT).pack(side=LEFT)
self.wFval0Entry = EntryContext(self.wFbox0, width=5, textvariable=self.wFval0).pack(side=LEFT)
self.wFlim0Entry = EntryContext(self.wFbox1, width=5, textvariable=self.wFlim0).pack(side=LEFT)
self.wFlim0Label = Label(self.wFbox1, text="*d_max <= d < ", justify=LEFT).pack(side=LEFT)
self.wFlim1Entry = EntryContext(self.wFbox1, width=5, textvariable=self.wFlim1).pack(side=LEFT)
self.wFval1Label = Label(self.wFbox1, text="*d_max=", justify=LEFT).pack(side=LEFT)
self.wFval1Entry = EntryContext(self.wFbox1, width=5, textvariable=self.wFval1).pack(side=LEFT)
self.wFlim0Entry = EntryContext(self.wFbox2, width=5, textvariable=self.wFlim1).pack(side=LEFT)
self.wFlim0Label = Label(self.wFbox2, text="*d_max <= d < ", justify=LEFT).pack(side=LEFT)
self.wFlim1Entry = EntryContext(self.wFbox2, width=5, textvariable=self.wFlim2).pack(side=LEFT)
self.wFval1Label = Label(self.wFbox2, text="*d_max=", justify=LEFT).pack(side=LEFT)
self.wFval1Entry = EntryContext(self.wFbox2, width=5, textvariable=self.wFval2).pack(side=LEFT)
self.wFlim2Label = Label(self.wFbox3, text="d >= ", justify=LEFT).pack(side=LEFT)
self.wFlim2Entry = EntryContext(self.wFbox3, width=5, textvariable=self.wFlim2).pack(side=LEFT)
self.wFval3Label = Label(self.wFbox3, text="*d_max=", justify=LEFT).pack(side=LEFT)
self.wFval3Entry = EntryContext(self.wFbox3, width=5, textvariable=self.wFval3).pack(side=LEFT)
# ======================= Species to Study ===========================
self.specie_frame = LabelFrame(self.PSCF_frame,
text="Species")
self.specie_frame.grid(row=3,
column=0,
columnspan=2,
sticky=E+W+S+N,
padx=5,
pady=5)
self.species = StringVar()
allSpecies = ";".join(self.param["species"])
self.species.set(allSpecies)
self.speciesLabel = Label(self.specie_frame, text="Specie(s) to study", justify=LEFT)
self.speciesLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5)
self.speciesEntry = EntryContext(self.specie_frame, width=40, textvariable=self.species)
self.speciesEntry.grid(row=0, column=1, sticky=W, padx=5, pady=5)
# Choice percentile/threshold
self.percentileBool = BooleanVar()
self.percentileBool.set(self.param["percentileBool"])
self.percentileBoolCheck = Checkbutton(self.specie_frame, text="Use the Xth percentile as threshold. If not check, use the threshold.", variable=self.percentileBool, command=self.percentile_callback)
self.percentileBoolCheck.grid(row=1, column=0, columnspan=60, sticky=W, padx=5, pady=5)
# Percentile
self.percentileLabel = Label(self.specie_frame, text="Percentile", justify=LEFT)
self.percentileLabel.grid(row=2, column=0, sticky=W, padx=5, pady=5)
self.percentile = StringVar()
self.percentile.set(self.param["percentile"])
self.percentileEntry = EntryContext(self.specie_frame, width=30, textvariable=self.percentile)
self.percentileEntry.grid(row=2, column=1, sticky=W, padx=5, pady=5)
# threshold
self.threshold = StringVar()
self.threshold.set(self.param["threshold"])
self.thresholdLabel = Label(self.specie_frame, text="Threshold", justify=LEFT)
self.thresholdLabel.grid(row=3, column=0, sticky=W, padx=5, pady=5)
self.thresholdEntry = EntryContext(self.specie_frame, width=30, textvariable=self.threshold)
self.thresholdEntry.grid(row=3, column=1, sticky=W, padx=5, pady=5)
# ===== Time frame ===========================