-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlm.py
4839 lines (3407 loc) · 211 KB
/
mlm.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
#!/usr/bin/env python3
from tkinter import Tk, Label, Button, StringVar, Entry,NONE, END,HORIZONTAL,N, W, E, S, Checkbutton,Radiobutton, IntVar, Radiobutton, Scrollbar, Listbox, LEFT, BOTH, Spinbox, Menu, Text, NORMAL
import tkinter as tk
from tkinter import ttk
#For more themes
#from ttkthemes import ThemedTk
import math
# to create a dialog interface for the input file
from tkinter.filedialog import askopenfilename
#from tkinter.filedialog import asksavefilename
from tkinter.filedialog import asksaveasfile
# to manage a different font
from tkinter import font
# need this to check if a a file exists
import os
import sys
# to read the XLS file
import xlrd
# to create an XLS file
import xlsxwriter
# to rewrite an xls file without delete it
from xlutils.copy import copy
# to manage date
import datetime
import time
# to manage SEA FLOOR format
import csv
# to manage images
from PIL import Image, ImageTk
# to manage plots
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
# to map the surveys on GoogleMaps using the browser
import webbrowser
# for the web scraping on BODC VOCABS
from bs4 import BeautifulSoup
import requests
# ONLY FOR TEST
# Only for test Poland_output_Alex_20-04-2018_V3.xls
'''
To create an exe (Linux/Windows):
https://pypi.org/project/auto-py-to-exe/
pip install auto-py-to-exe
auto-py-to-exe
To include the NODC logo use the following option inside auto-py-to-exe:
--hidden-import='PIL._tkinter_finder'
FOR WINDOWS ONLY with ANACONDA:
--exclude-module scikit-learn,PyQt5,PyQt4,2to3,IPython,Jinja2,pycparser,scipy
TO ADD NEW THEMES:
pip install ttkthemes
N.B. The themes plastik, clearlooks and elegance are recommended to make your
UI look nicer on all platforms when using Tkinter and the ttk extensions in Python.
When you are targeting Ubuntu, consider using the great radiance theme.
'''
class MarineLitterManager:
NUMBERS_ARRAY = []
for n in range(150):
NUMBERS_ARRAY.append(n)
TMP_LETTERS_ARRAY = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
]
LETTERS_ARRAY = TMP_LETTERS_ARRAY
howmanynumbers = len(NUMBERS_ARRAY)-1
if howmanynumbers > 25:
letters_cicles=int(float(howmanynumbers)/25)
for c in range(letters_cicles):
for n in range(26):
LETTERS_ARRAY.append(TMP_LETTERS_ARRAY[c]+TMP_LETTERS_ARRAY[n])
LETTERS_ARRAY.insert(0, " ")
FIELDBEACHES=['BeachCode',
'BeachName',
'Country',
'BeachInfoAmmendment',
'FillingDate',
'FillingName',
'FillingPhone',
'FillingMail',
'FillingInstitute',
'UrbanizationDegree',
'ReferenceBeach',
'BeachWidthLow',
'BeachWidthHigh',
'BeachLength',
'BeachLatitude',
'BeachLongitude',
'CoordinateSystem',
'BeachBack',
'BeachBackOther',
'BeachBackDevelopment',
'DevelopmentDescription',
'PositionMeasurementDate',
'CurrentsDirection',
'WindsDirection',
'BeachOrientation',
'BeachMaterial',
'BeachTopography',
'Obstacles',
'Usage1',
'Usage1Seasonality',
'Usage2',
'Usage2Seasonality',
'Usage3',
'Usage3Seasonality',
'BeachAccess',
'BeachCleaningSeasonality',
'SeasonalityMonths',
'CleaningFrequency',
'OtherDescription',
'CleaningMethod',
'CleaningResponsible',
'Notes',]
FIELDSURVEYS=['BeachCode',
'SurveyCode',
'SurveyType',
'DataPolicy',
'SurveyDate',
'Originator',
'Collator',
'ProjectCode',
'SurveyStartLatitude',
'SurveyStartLongitude',
'SurveyEndLatitude',
'SurveyEndLongitude',
'CoordinateSystem',
'SurveyLength',
'SurveyWidth',
'Surveyor1Name',
'Surveyor1Phone',
'Surveyor1Mail',
'Surveyor2Name',
'Surveyor2Phone',
'Surveyor2Mail',
'TownName',
'TownDistance',
'TownPosition',
'TownPopulation',
'WinterTourists',
'SpringTourists',
'SummerTourists',
'AutumnTourists',
'FoodOutlets',
'FoodOutletsDistance',
'FoodOutletsSeasonality',
'SeasonalityMonths',
'FoodOutletsPosition',
'ShippingLaneDistance',
'ShippingLaneTraffic',
'ShippingLaneTypes',
'ShippingLanePosition',
'HarbourName',
'HarbourDistance',
'HarbourPosition',
'HarbourType',
'HarbourSize',
'RiverName',
'RiverDistance',
'RiverPosition',
'WasteWaterDischarges',
'WasteWaterDistance',
'WasteWaterPosition',
'LitterPresence',
'LastCleaning',
'WeatherConditions',
'WeatherConditionsOther',
'AnimalsFound',
'AnimalsNumber',
'SurveyCircumstances',
'SpecialEvents',
'Notes',]
FIELDANIMALS=['SurveyCode',
'Animal',
'State',
'Sex',
'Age',
'Entanglement',
'EntanglementNature',
'Comments',]
FIELDLITTER=['SurveyCode',
'LitterReferenceList',
'ItemCode',
'ItemName',
'ParameterOriginalName',
'NoItems',
'Notes',]
#spostare i campi timestamp (shot_timestamp) e
#l'haul duration (haul_dur) nella "parte delle survey"
FIELDSURVEYSSEAFLOOR=['SurveyName',
'ProjectCode',
'DataPolicy',
'Date',
'Ship',
'Gear',
'Country',
'Originator',
'Collator',
'StNo',
'HaulNo',
'CoordRefSys',
'ShootLat',
'ShootLong',
'HaulLat',
'HaulLong',
'Depth',
'Distance',
'GroundSpeed',
'WingSpread',
'DoorSpread',
'WarpLength',
'Shot_timestamp',
'HaulDur']
FIELDLITTERSEAFLOOR=['LTREF',
'PARAM',
'LTSZC',
'LTSRC',
'TYPPL',
'LTPRP',
'UnitWgt',
'LT_Weight',
'UnitItem',
'LT_Items',
'Shot_timestamp',
'HaulDur',
'StationNumber',] # The last field has been added only to have a match with the surveys when we create the CSV output file
checkmylistScrollListSurveyParamsSF=0
def __init__(self, master):
self.master = master
master.title("Marine Litter Manager")
'''
THE FOLLOWING THREE ROWS EXPLAIN HOW TO CHANGE THE STATE OF A TAB
DISABLED: the tab is visible but not active
NORMAL: the tab is in nomral state
HIDDEN: the tab is not visible
these options could be useful if the software must manage different
input/output formats and it's necessary show only some tabs
N.B. in the example the tab is 2 (self.surveyBL)
'''
#self.nb.tab(2, state="disabled")
#self.nb.tab(2, state="normal")
#self.nb.tab(2, state="hidden")
frameFont = ttk.Style()
frameFont.configure('new.TFrame', family='Verdana', size=8, weight='bold', underline=1)
# Defines and places the notebook widget
self.nb = ttk.Notebook(self.master)
self.nb.grid(row=1, column=0, columnspan=50, rowspan=49, sticky='NESW')
# Adds tab of the notebook
self.formats = ttk.Frame(self.nb, style='new.TFrame')
self.nb.add(self.formats, text='FORMATS')
# Adds tab of the notebook
self.infoBL = ttk.Frame(self.nb, style='new.TFrame')
self.nb.add(self.infoBL, text='BEACH LITTER')
# Adds tab of the notebook
self.beachesBL = ttk.Frame(self.nb)
self.nb.add(self.beachesBL, text='BEACHES')
# Adds tab of the notebook
self.surveyBL = ttk.Frame(self.nb)
self.nb.add(self.surveyBL, text='SURVEYS')
# Adds tab of the notebook
self.animalLitterBL = ttk.Frame(self.nb)
self.nb.add(self.animalLitterBL, text='ANIMALS & LITTER')
# Adds tab of the notebook
self.plotBL = ttk.Frame(self.nb)
self.nb.add(self.plotBL, text='SURVEYS PLOT')
# Adds tab of the notebook
self.scatterBL = ttk.Frame(self.nb)
self.nb.add(self.scatterBL, text='PARAMS PLOT')
# Adds tab of the notebook
self.infoSF = ttk.Frame(self.nb)
self.nb.add(self.infoSF, text='SEA FLOOR')
# Adds tab of the notebook
self.surveySF = ttk.Frame(self.nb)
self.nb.add(self.surveySF, text='SURVEYS')
# Adds tab of the notebook
self.litterSF = ttk.Frame(self.nb)
self.nb.add(self.litterSF, text='LITTER')
# Adds tab of the notebook
self.plotSF = ttk.Frame(self.nb)
self.nb.add(self.plotSF, text='SURVEYS PLOT')
# Adds tab of the notebook
self.scatterSF = ttk.Frame(self.nb)
self.nb.add(self.scatterSF, text='PARAMS PLOT')
# Adds tab of the notebook
self.infoCML = ttk.Frame(self.nb)
self.nb.add(self.infoCML, text='COASTAL MACRO LITTER')
# Adds tab of the notebook
self.infoOSML = ttk.Frame(self.nb)
self.nb.add(self.infoOSML, text='OPEN SEA MACRO LITTER')
# Adds tab of the notebook
self.dictionary = ttk.Frame(self.nb)
self.nb.add(self.dictionary, text='DICTIONARY')
# Adds tab of the notebook
self.links = ttk.Frame(self.nb)
self.nb.add(self.links, text='LINKS')
self.nb.tab(1, state="hidden")
self.nb.tab(2, state="hidden")
self.nb.tab(3, state="hidden")
self.nb.tab(4, state="hidden")
self.nb.tab(5, state="hidden")
self.nb.tab(6, state="hidden")
self.nb.tab(7, state="hidden")
self.nb.tab(8, state="hidden")
self.nb.tab(9, state="hidden")
self.nb.tab(10, state="hidden")
self.nb.tab(11, state="hidden")
self.nb.tab(12, state="hidden")
self.nb.tab(13, state="hidden")
self.nb.tab(14, state="hidden")
self.nb.tab(15, state="hidden")
#Common parts we have to wrap each command
xlsGrid = master.register(self.checkGridXls)
xlsGridSurvey = master.register(self.checkGridXlsSurvey)
xlsGridSurveySF = master.register(self.checkGridXlsSurveySF)
xlsGridAnimals = master.register(self.checkGridXlsAnimals)
xlsGridLitter = master.register(self.checkGridXlsLitter)
xlsGridLitterSF = master.register(self.checkGridXlsLitterSF)
createOutput = master.register(self.createXlsOutput)
createOutputModel = master.register(self.createXlsOutputModel)
createOutputModelSF = master.register(self.SaveOutputFileModelSF)
loadInputModel = master.register(self.loadModel)
loadInputModelSF = master.register(self.loadModelSF)
vcmd = master.register(self.validatenumber)
openfile = master.register(self.OpenInputFile)
openfileSF = master.register(self.OpenInputFileSF)
openfilesurveyplot = master.register(self.OpenInputFilePlotSurvey)
openfilesurveyplotSF = master.register(self.OpenInputFilePlotSurveySF)
openfileparamsplot = master.register(self.OpenInputFilePlotParams)
openfileparamsplotSF = master.register(self.OpenInputFilePlotParamsSF)
savefilexls = master.register(self.SaveOutputFileXls)
savefilecsvSF = master.register(self.SaveOutputFileCsvSF)
savefilemodel = master.register(self.SaveOutputFileModel)
savefilemodelSF = master.register(self.SaveOutputFileModelSF)
openmodelfile = master.register(self.OpenModelInputFile)
openmodelfileSF = master.register(self.OpenModelInputFileSF)
searchLegendafile = master.register(self.SearchLegendaTermFile)
checkForPlots = master.register(self.checkPlots)
checkForPlotsSF = master.register(self.checkPlotsSF)
plotMySurvey = master.register(self.executePlot)
plotMySurveySF = master.register(self.executePlotSF)
checkForPlotsParams = master.register(self.checkPlotsParams)
checkForPlotsParamsSF = master.register(self.checkPlotsParamsSF)
plotMyParams = master.register(self.executePlotParams)
plotMyParamsSF = master.register(self.executePlotParamsSF)
find_resource_path = master.register(self.resource_path)
showbeachlitter = master.register(self.ShowBeachLitterTabs)
executeLinkButtonA = master.register(self.LinkButtonA)
executeLinkButtonB = master.register(self.LinkButtonB)
executeLinkButtonC = master.register(self.LinkButtonC)
executeLinkButtonD = master.register(self.LinkButtonD)
executeLinkButtonE = master.register(self.LinkButtonE)
executeLinkButtonF = master.register(self.LinkButtonF)
showseafloorlitter = master.register(self.ShowSeaFloorLitterTabs)
showcoastalmacrolitter = master.register(self.ShowCoastalMacroLitterTabs)
showopenseamacrolitter = master.register(self.ShowOpenSeaMacroLitterTabs)
showutilities = master.register(self.ShowUtilitiesTabs)
formathidealltabs = master.register(self.HideAllTabs)
changeLabelSep = master.register(self.changeLabelSeparator)
mytext=''
self.create=0
'''
START here we add a cascading menu
'''
# START here we add a cascading menu
self.emptymenu = Menu(self.master)
self.menuBL = Menu(self.master)
self.menuSF = Menu(self.master)
# Items for Beach Litter MENU
new_itemFile = Menu(self.menuBL)
new_itemModel = Menu(self.menuBL)
new_itemFile.add_command(label='Load Litter Input File', command=(openfile))
new_itemFile.add_separator()
new_itemFile.add_command(label='Save Litter Output File', command=(savefilexls))
new_itemFile.add_separator()
new_itemModel.add_command(label='Load Model', command=(openmodelfile))
new_itemModel.add_separator()
new_itemModel.add_command(label='Save Model', command=(savefilemodel))
new_itemModel.add_separator()
self.menuBL.add_cascade(label='Beach Litter Files', menu=new_itemFile)
self.menuBL.add_cascade(label='Beach Litter Models', menu=new_itemModel)
# Items for Beach Litter MENU
new_itemFileSF = Menu(self.menuSF)
new_itemModelSF = Menu(self.menuSF)
new_itemFileSF.add_command(label='Load Litter Input File', command=(openfileSF))
new_itemFileSF.add_separator()
new_itemFileSF.add_command(label='Save Litter Output File', command=(savefilecsvSF))
new_itemFileSF.add_separator()
new_itemModelSF.add_command(label='Load Model', command=(openmodelfileSF))
new_itemModelSF.add_separator()
new_itemModelSF.add_command(label='Save Model', command=(savefilemodelSF))
new_itemModelSF.add_separator()
self.menuSF.add_cascade(label='Sea Floor Files', menu=new_itemFileSF)
self.menuSF.add_cascade(label='Sea Floor Models', menu=new_itemModelSF)
self.master.config(menu=self.emptymenu)
'''
END cascading menu
'''
# END cascading menu
'''
START FORMATS
'''
appHighlightFont = font.Font(family='helvetica', size=12, weight='bold', underline=1)
# print(font.families())
# AVAILABLE FONTS on TKINTER
# ('fangsong ti',
# 'fixed',
# 'clearlyu alternate glyphs',
# 'charter',
# 'lucidatypewriter',
# 'courier 10 pitch',
# 'lucidabright',
# 'times',
# 'open look glyph',
# 'bitstream charter',
# 'song ti', 'helvetica',
# 'open look cursor',
# 'newspaper',
# 'clearlyu ligature',
# 'mincho',
# 'clearlyu devangari extra',
# 'clearlyu pua',
# 'courier',
# 'clearlyu',
# 'lucida',
# 'clean',
# 'nil',
# 'clearlyu arabic',
# 'clearlyu devanagari',
# 'terminal',
# 'symbol',
# 'gothic',
# 'new century schoolbook',
# 'clearlyu arabic extra')
self.labelOGCNODC = Label(self.formats, text=mytext, bg="SkyBlue2", fg="black", font=appHighlightFont, height=3, width=76)
#self.labelOGCNODC['text'] = 'NODC - National Oceanographic Data Center - OGS\n https://nodc.ogs.trieste.it'
self.labelOGCNODC['text'] = 'MARINE LITTER MANAGER developed by NODC\nNational Oceanographic Data Center - OGS https://nodc.ogs.it'
self.labelOGCNODC.grid(row=0, column=0, columnspan=10, rowspan=10, padx=25, pady=55)
self.FormatBeachLitterButton = Button(self.formats, text="BEACH LITTER FORMAT", width=103, font=('helvetica','9','bold'),background = 'white', command=(showbeachlitter))
self.FormatBeachLitterButton.grid(row=11, column=0, sticky=W)
self.FormatBeachLitterButtonSF = Button(self.formats, text="SEA FLOOR LITTER FORMAT", width=103, font=('helvetica','9','bold'),background = 'white', command=(showseafloorlitter))
self.FormatBeachLitterButtonSF.grid(row=12, column=0, sticky=W)
#self.FormatCoastalMacroLitterButton = Button(self.formats, text="COASTAL MACRO LITTER FORMAT", width=103, font=('helvetica','9','bold'),background = 'white', command=(showcoastalmacrolitter))
#self.FormatCoastalMacroLitterButton.grid(row=13, column=0, sticky=W)
#self.FormatOpenSeaMacroLitterButton = Button(self.formats, text="OPEN SEA MACRO LITTER FORMAT", width=103, font=('helvetica','9','bold'),background = 'white', command=(showopenseamacrolitter))
#self.FormatOpenSeaMacroLitterButton.grid(row=14, column=0, sticky=W)
self.UtilitiesButton = Button(self.formats, text="UTILITIES", width=103, font=('helvetica','9','bold'),background = 'white', command=(showutilities))
self.UtilitiesButton.grid(row=15, column=0, sticky=W)
self.HideAllButton = Button(self.formats, text="HIDE ALL", width=103, font=('helvetica','9','bold'),background = 'white', command=(formathidealltabs))
self.HideAllButton.grid(row=16, column=0, sticky=W)
#self.path = self.resource_path('NODC.gif')
self.path = self.resource_path('logo.png')
#Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object.
self.img = ImageTk.PhotoImage(Image.open(self.path))
#The Label widget is a standard Tkinter widget used to display a text or image on the screen.
self.panel = ttk.Label(self.formats, image = self.img)
self.panel.grid(row=26, column=0, columnspan=4, rowspan=10, padx=25, pady=55)
'''
END FORMATS
'''
'''
START LINKS
'''
self.LinkButtonB = Button(self.links, text="Guidelines and forms for gathering marine litter data (PDF file)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonB))
self.LinkButtonB.grid(row=5, column=0, sticky=W)
self.LinkButtonA = Button(self.links, text="Beach format template (ZIP file)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonA))
self.LinkButtonA.grid(row=6, column=0, sticky=W)
self.LinkButtonC = Button(self.links, text="Seafloor format template (ZIP file)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonC))
self.LinkButtonC.grid(row=7, column=0, sticky=W)
self.LinkButtonD = Button(self.links, text="Beach, seafloor data available through EMODnet Chemistry Data Discovery and Access Service (web page)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonD))
self.LinkButtonD.grid(row=8, column=0, sticky=W)
self.LinkButtonE = Button(self.links, text="Marine Litter Visualization Products (web page)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonE))
self.LinkButtonE.grid(row=9, column=0, sticky=W)
self.LinkButtonF = Button(self.links, text="Aggregated collections of unrestricted data for beach and seafloor litter: Sextant Catalogue Service (web page)", width=105, font=('helvetica','9','bold'),background = 'white', command=(executeLinkButtonF))
self.LinkButtonF.grid(row=10, column=0, sticky=W)
'''
END LINKS
'''
'''
START INFO BEACH LITTER
'''
dummysheet=int(0)
self.labelEntryInfoBeaches = Label(self.infoBL, text=mytext)
self.labelEntryInfoBeaches['text'] = 'The sheet for BEACHES: ' + str(mytext)
self.labelEntryInfoBeaches.grid(row=1, column=0, sticky=E)
self.entryInfoBeachesVars = tk.IntVar()
self.entryInfoBeaches = Spinbox(self.infoBL, from_=1, to=10, textvariable= self.entryInfoBeachesVars, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoBeaches.grid(row=1, column=1, sticky=W)
self.labelEntryInfoSurveys = Label(self.infoBL, text=mytext)
self.labelEntryInfoSurveys['text'] = 'The sheet for SURVEYS: ' + str(mytext)
self.labelEntryInfoSurveys.grid(row=1, column=2, sticky=E)
self.entryInfoSurveysVars = tk.IntVar()
self.entryInfoSurveys = Spinbox(self.infoBL, from_=1, to=10, textvariable= self.entryInfoSurveysVars, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoSurveys.grid(row=1, column=3, sticky=W)
self.labelEntryInfoAnimals = Label(self.infoBL, text=mytext)
self.labelEntryInfoAnimals['text'] = 'The sheet for ANIMALS: ' + str(mytext)
self.labelEntryInfoAnimals.grid(row=2, column=0, sticky=E)
self.entryInfoAnimalsVars = tk.IntVar()
self.entryInfoAnimals = Spinbox(self.infoBL, from_=1, to=10, textvariable= self.entryInfoAnimalsVars, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoAnimals.grid(row=2, column=1, sticky=W)
self.labelEntryInfoLitter = Label(self.infoBL, text=mytext)
self.labelEntryInfoLitter['text'] = 'The sheet for LITTER: ' + str(mytext)
self.labelEntryInfoLitter.grid(row=2, column=2, sticky=E)
self.entryInfoLitterVars = tk.IntVar()
self.entryInfoLitter = Spinbox(self.infoBL, from_=1, to=10, textvariable= self.entryInfoLitterVars, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoLitter.grid(row=2, column=3, sticky=W)
self.openInputFileButton = Button(self.infoBL, text="Load Litter Input File", command=(openfile))
self.openInputFileButton.grid(row=3, column=2, sticky=E)
self.entryInfoInputFile = Entry(self.infoBL, width=20, validate="key")
self.entryInfoInputFile.grid(row=3, column=3, sticky=W)
#self.saveXlsFileButton = Button(self.infoBL, text="Save Litter XLS File", command=(savefilexls))
#self.saveXlsFileButton.grid(row=4, column=2, sticky=E)
self.labelInfoOutputFile = Label(self.infoBL, text=mytext)
self.labelInfoOutputFile['text'] = 'Output file name (.xls): ' + str(mytext)
self.labelInfoOutputFile.grid(row=4, column=2, sticky=E)
self.entryInfoOutputFile = Entry(self.infoBL, width=20,state="readonly", validate="key")
self.entryInfoOutputFile.grid(row=4, column=3, sticky=W)
self.openInputModelFileButton = Button(self.infoBL, text="Load Model", command=(openmodelfile))
self.openInputModelFileButton.grid(row=5, column=2, sticky=E)
self.entryInfoModelInputFile = Entry(self.infoBL, width=20, validate="key")
self.entryInfoModelInputFile.grid(row=5, column=3, sticky=W)
self.labelInfoOutputModelFile = Label(self.infoBL, text=mytext)
self.labelInfoOutputModelFile['text'] = 'Model file name (.csv): ' + str(mytext)
self.labelInfoOutputModelFile.grid(row=6, column=2, sticky=E)
#self.saveModelFileButton = Button(self.infoBL, text="Save Model", command=(savefilemodel))
#self.saveModelFileButton.grid(row=6, column=2, sticky=E)
self.entryInfoOutputModelFile = Entry(self.infoBL, width=20,state="readonly", validate="key")
self.entryInfoOutputModelFile.grid(row=6, column=3, sticky=W)
self.infoBLarea = Text(self.infoBL, height=45, width=106)
self.infoBLarea.grid(row=59, column=0, columnspan=18, rowspan=30)
self.infoBLarea.insert(END, "Marine Litter Manager Infobox:")
self.labellegenda = Label(self.dictionary, text=mytext)
self.labellegenda['text'] = 'Search term: ' + str(mytext)
self.labellegenda.grid(row=1, column=0, sticky=E)
self.entrylegendaTerm = Entry(self.dictionary, width=20, validate="key")
self.entrylegendaTerm.grid(row=1, column=1, sticky=W)
self.openlegendaButton = Button(self.dictionary, text="SEARCH", command=(searchLegendafile))
self.openlegendaButton.grid(row=1, column=2, sticky=E)
self.varVocabBODClvLegenda = IntVar(value=1)
self.buttonvarVocabBODClvLegenda = Checkbutton(self.dictionary, text="EMBEDDED DICTIONARY SEARCH", variable=self.varVocabBODClvLegenda)
self.buttonvarVocabBODClvLegenda.grid(row=2, column=0,columnspan=10, sticky=W)
self.varVocabBODClvA = IntVar()
self.buttonvarVocabBODClvA = Checkbutton(self.dictionary, text="H01 BODC VOCAB - EMODnet micro-litter types (WEB SCRAPING)", variable=self.varVocabBODClvA)
self.buttonvarVocabBODClvA.grid(row=3, column=0,columnspan=10, sticky=W)
self.varVocabBODClvB = IntVar()
self.buttonvarVocabBODClvB = Checkbutton(self.dictionary, text="H02 BODC VOCAB - EMODnet micro-litter shapes (WEB SCRAPING)", variable=self.varVocabBODClvB)
self.buttonvarVocabBODClvB.grid(row=4, column=0,columnspan=10, sticky=W)
self.varVocabBODClvC = IntVar()
self.buttonvarVocabBODClvC = Checkbutton(self.dictionary, text="H03 BODC VOCAB - EMODnet micro-litter size classes (WEB SCRAPING)", variable=self.varVocabBODClvC)
self.buttonvarVocabBODClvC.grid(row=5, column=0,columnspan=10, sticky=W)
self.varVocabBODClvD = IntVar()
self.buttonvarVocabBODClvD = Checkbutton(self.dictionary, text="H04 BODC VOCAB - EMODnet micro-litter colour classes (WEB SCRAPING)", variable=self.varVocabBODClvD)
self.buttonvarVocabBODClvD.grid(row=6, column=0,columnspan=10, sticky=W)
self.varVocabBODClvE = IntVar()
self.buttonvarVocabBODClvE = Checkbutton(self.dictionary, text="H05 BODC VOCAB - EMODnet micro-litter polymer type (WEB SCRAPING)", variable=self.varVocabBODClvE)
self.buttonvarVocabBODClvE.grid(row=7, column=0,columnspan=10, sticky=W)
self.varVocabBODClvF = IntVar()
self.buttonvarVocabBODClvF = Checkbutton(self.dictionary, text="P01 BODC VOCAB - BODC Parameter Usage Vocabulary (WEB SCRAPING). ATTENTION: TIME-CONSUMING SEARCH!", variable=self.varVocabBODClvF)
self.buttonvarVocabBODClvF.grid(row=8, column=0,columnspan=10, sticky=W)
self.legendaarea = Text(self.dictionary, height=45, width=106)
self.legendaarea.grid(row=10, column=0, columnspan=18, rowspan=30, sticky=W)
self.legendaarea.insert(END, "")
root.update()
'''
END INFO BEACH LITTER
'''
'''
START INFO SEA FLOOR
'''
self.labelEntryInfoSurveysSF = Label(self.infoSF, text=mytext)
self.labelEntryInfoSurveysSF['text'] = 'The sheet for SURVEYS: ' + str(mytext)
self.labelEntryInfoSurveysSF.grid(row=1, column=0, sticky=E)
self.entryInfoSurveysVarsSF = tk.IntVar()
self.entryInfoSurveysSF = Spinbox(self.infoSF, from_=1, to=10, textvariable= self.entryInfoSurveysVarsSF, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoSurveysSF.grid(row=1, column=1, sticky=W)
self.labelEntryInfoLitterSF = Label(self.infoSF, text=mytext)
self.labelEntryInfoLitterSF['text'] = 'The sheet for LITTER: ' + str(mytext)
self.labelEntryInfoLitterSF.grid(row=1, column=2, sticky=E)
self.entryInfoLitterVarsSF = tk.IntVar()
self.entryInfoLitterSF = Spinbox(self.infoSF, from_=1, to=10, textvariable= self.entryInfoLitterVarsSF, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entryInfoLitterSF.grid(row=1, column=3, sticky=W)
self.openInputFileButtonSF = Button(self.infoSF, text="Load Litter Input File", command=(openfileSF))
self.openInputFileButtonSF.grid(row=3, column=0, sticky=E)
self.entryInfoInputFileSF = Entry(self.infoSF, width=20, validate="key")
self.entryInfoInputFileSF.grid(row=3, column=1, columnspan=3, sticky=W)
self.labelInfoOutputFileSF = Label(self.infoSF, text=mytext)
self.labelInfoOutputFileSF['text'] = 'Output file name (.xls): ' + str(mytext)
self.labelInfoOutputFileSF.grid(row=4, column=0, sticky=E)
self.entryInfoOutputFileSF = Entry(self.infoSF, width=20,state="readonly", validate="key")
self.entryInfoOutputFileSF.grid(row=4, column=1, columnspan=3, sticky=W)
self.openInputModelFileButtonSF = Button(self.infoSF, text="Load Model", command=(openmodelfileSF))
self.openInputModelFileButtonSF.grid(row=5, column=0, sticky=E)
self.entryInfoModelInputFileSF = Entry(self.infoSF, width=20, validate="key")
self.entryInfoModelInputFileSF.grid(row=5, column=1, columnspan=3, sticky=W)
self.labelInfoOutputModelFileSF = Label(self.infoSF, text=mytext)
self.labelInfoOutputModelFileSF['text'] = 'Model file name (.csv): ' + str(mytext)
self.labelInfoOutputModelFileSF.grid(row=6, column=0, sticky=E)
#self.saveModelFileButtonSF = Button(self.infoSF, text="Save Model", command=(savefilemodelSF))
#self.saveModelFileButtonSF.grid(row=6, column=2, sticky=E)
self.entryInfoOutputModelFileSF = Entry(self.infoSF, width=20,state="readonly", validate="key")
self.entryInfoOutputModelFileSF.grid(row=6, column=1, columnspan=3, sticky=W)
self.labelRadioSeparatorCSV = Label(self.infoSF, text=mytext)
self.labelRadioSeparatorCSV['text'] = 'Define the CSV output/plot separator' + str(mytext)
self.labelRadioSeparatorCSV.grid(row=6, column=2, sticky=E)
self.varRadioOutputCSV = tk.IntVar()
self.varRadioOutputCSV.set(2)
self.R1Output = Radiobutton(self.infoSF, text="Tab", variable=self.varRadioOutputCSV, value=1, command=(changeLabelSep))
self.R1Output.grid(row=6, column=3, sticky=E)
self.R2Output = Radiobutton(self.infoSF, text="Comma", variable=self.varRadioOutputCSV, value=2, command=(changeLabelSep))
self.R2Output.grid(row=6, column=4, sticky=E)
self.infoSFarea = Text(self.infoSF,wrap=NONE, height=45, width=106)
self.infoSFarea.grid(row=59, column=0, columnspan=16, rowspan=30)
self.infoSFarea.insert(END, "Marine Litter Manager Infobox:")
'''
END INFO SEA FLOOR
'''
#Here we add the fields for each tab
#TAB1 (self.beachesBL)
'''
START BEACHES BEACH LITTER
'''
self.OnlyLabel = Label(self.beachesBL, text=mytext)
self.OnlyLabel['text'] = 'Name of the field'
self.OnlyLabel.grid(row=44, column=0, columnspan=8, sticky=W+E)
root.update()
self.labelsBeaches = []
self.entriesBeachesRow = []
self.entriesBeachesCol = []
self.buttonsBeaches = []
tmprow=0
tmpcolumn=4
self.entriesBeachesRowVars = []
self.entriesBeachesColVars = []
for i in range(42):
mytext=self.FIELDBEACHES[i]
if tmpcolumn == 4:
tmpcolumn=0
else:
tmpcolumn=4
if tmprow == 0:
tmprow=1
else:
tmprow=0
self.lbBeaches = Label(self.beachesBL, text=mytext)
self.lbBeaches['text'] = str(mytext)+'('+str(i)+'): '
self.lbBeaches.grid(row=i+tmprow, column=0+tmpcolumn, sticky='E')
self.labelsBeaches.append(self.lbBeaches)
tempentriesBeachesRowVars = tk.IntVar()
self.enBeachesRow = Spinbox(self.beachesBL, from_=1, to=10, width=2, textvariable= tempentriesBeachesRowVars, validate="key", validatecommand=(vcmd, '%P'))
self.entriesBeachesRowVars.append(tempentriesBeachesRowVars)
self.enBeachesRow.grid(row=i+tmprow, column=1+tmpcolumn)
self.entriesBeachesRow.append(self.enBeachesRow)
tempentriesBeachesColVars = tk.IntVar()
self.enBeachesCol = Spinbox(self.beachesBL, values=self.LETTERS_ARRAY, textvariable= tempentriesBeachesColVars, width=3)
self.entriesBeachesColVars.append(tempentriesBeachesColVars)
self.enBeachesCol.grid(row=i+tmprow, column=2+tmpcolumn)
self.entriesBeachesCol.append(self.enBeachesCol)
self.btBeaches = Button(self.beachesBL, text="Check", command=(xlsGrid, int(i)))
self.btBeaches.grid(row=i+tmprow, column=3+tmpcolumn, sticky=E)
self.buttonsBeaches.append(self.btBeaches)
'''
END BEACHES BEACH LITTER
'''
#self.close_button = Button(self.beachesBL, text="Close", command=master.quit)
#self.close_button.grid(row=48, column=1, sticky=W+E)
#TAB2 (self.surveyBL)
'''
START SURVEYS BEACH LITTER
'''
self.OnlyLabelSurveys = Label(self.surveyBL, text=mytext)
self.OnlyLabelSurveys['text'] = 'Name of the field'
self.OnlyLabelSurveys.grid(row=58, column=0, columnspan=8, sticky=W+E)
root.update()
self.labelsSurveys = []
self.entriesSurveysRow = []
self.entriesSurveysCol = []
self.buttonsSurveys = []
tmprow=0
tmpcolumn=4
self.entriesSurveysRowVars = []
self.entriesSurveysColVars = []
for i in range(58):
mytext=self.FIELDSURVEYS[i]
if tmpcolumn == 4:
tmpcolumn=0
else:
tmpcolumn=4
if tmprow == 0:
tmprow=1
else:
tmprow=0
self.lbSurveys = Label(self.surveyBL, text=mytext)
self.lbSurveys['text'] = str(mytext)+'('+str(i)+'): '
self.lbSurveys.grid(row=i+tmprow, column=0+tmpcolumn, sticky='E')
self.labelsSurveys.append(self.lbSurveys)
tempentriesSurveysRowVars = tk.IntVar()
self.enSurveysRow = Spinbox(self.surveyBL, from_=1, to=10, textvariable= tempentriesSurveysRowVars, width=2, validate="key", validatecommand=(vcmd, '%P'))
self.entriesSurveysRowVars.append(tempentriesSurveysRowVars)
self.enSurveysRow.grid(row=i+tmprow, column=1+tmpcolumn)
self.entriesSurveysRow.append(self.enSurveysRow)
tempentriesSurveysColVars = tk.IntVar()
self.enSurveysCol = Spinbox(self.surveyBL, values=self.LETTERS_ARRAY, textvariable= tempentriesSurveysColVars, width=3)
self.entriesSurveysColVars.append(tempentriesSurveysColVars)
self.enSurveysCol.grid(row=i+tmprow, column=2+tmpcolumn)
self.entriesSurveysCol.append(self.enSurveysCol)
self.btSurveys = Button(self.surveyBL, text="Check", command=(xlsGridSurvey, int(i)))
self.btSurveys.grid(row=i+tmprow, column=3+tmpcolumn, sticky=E)
self.buttonsSurveys.append(self.btSurveys)
'''
END SURVEYS BEACH LITTER
'''
'''
START SURVEYS SEA FLOOR
'''
'''
New section to manage timestamp (shot_timestamp) and
haul duration (haul_dur) survey tab area
'''
self.OnlyLabelSurveysSF = Label(self.surveySF, text=mytext)
self.OnlyLabelSurveysSF['text'] = 'Name of the field'
self.OnlyLabelSurveysSF.grid(row=58, column=0, columnspan=8, sticky=W+E)
root.update()
self.labelsSurveysSF = []
self.entriesSurveysRowSF = []
self.entriesSurveysColSF = []
self.buttonsSurveysSF = []
tmprow=0
tmpcolumn=4
self.entriesSurveysRowVarsSF = []
self.entriesSurveysColVarsSF = []
#for i in range(22):
for i in range(24): #two more fields
mytext=self.FIELDSURVEYSSEAFLOOR[i]
if tmpcolumn == 4:
tmpcolumn=0
else:
tmpcolumn=4
if tmprow == 0:
tmprow=1
else:
tmprow=0
'''
New section to manage timestamp (shot_timestamp) and