-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrowse_sector.py
859 lines (556 loc) · 24.5 KB
/
browse_sector.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
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 31 23:19:42 2021
@author: sean
"""
import PySimpleGUI as sg
import sqlite3
import pandas as pd
import numpy as np
from PIL import Image, ImageTk
import os
import io
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter # useful for `logit` scale
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import PySimpleGUI as sg
from matplotlib import style
matplotlib.use('TkAgg')
sg.theme('DarkBlue')
# ------------------------------------------------------------------------------
# use PIL to read data of one image
# ------------------------------------------------------------------------------
def get_img_data(f, maxsize=(1200, 850), first=False):
"""Generate image data using PIL
"""
img = Image.open(f)
img.thumbnail(maxsize)
if first: # tkinter is inactive the first time
bio = io.BytesIO()
img.save(bio, format="PNG")
del img
return bio.getvalue()
return ImageTk.PhotoImage(img)
# ------------------------------------------------------------------------------
def clear_images():
for li in list_images:
window[li[0]].hide_row()
def add_image(image_var):
window[image_var].unhide_row()
def select_images(loc_info,system_info,detail_info,economic_info):
if list(detail_info['gravity'])[0] > 1.50:
add_image('heavy')
elif list(detail_info['gravity'])[0] < 0.50:
add_image('light')
if list(detail_info['type'])[0] == "Ocean*":
add_image('ocean')
if list(detail_info['atmos_composition'])[0][0] == "E":
add_image('exotic')
elif list(detail_info['atmos_composition'])[0][0] == "C":
add_image('corrosive')
if list(detail_info['temperature'])[0] > 324:
add_image('hot')
if list(detail_info['temperature'])[0] < 239:
add_image('cold')
if list(detail_info['body'])[0] == 'Impact Moon' or \
list(detail_info['body'])[0] == 'Natural Moon':
add_image('moon')
if list(detail_info['body'])[0] == 'Gas Giant':
add_image('gas giant')
if list(loc_info['atmosphere'])[0] == 0:
add_image('vacuum')
if list(loc_info['size'])[0] == 0:
add_image('asteroid')
importance = list(system_info['ix'])[0]
for i in ['{','}']: importance = importance.strip(i)
importance = int(importance)
if importance >= 4: add_image('important')
bases = list(system_info['bases'])[0]
if 'N' in bases or 'B' in bases:
add_image('naval')
if 'S' in bases or 'B' in bases:
add_image('scout')
for rem in remarks_list:
if rem[0] in list(system_info['remarks'])[0]: add_image(rem[1])
gwp = list(economic_info['gwp'])[0]
gwp_string = "{:,}".format(gwp)
if int(gwp) >= 1000000: add_image('wealthy')
if list(detail_info['stellar_mask'])[0] == 'total': add_image('mask')
def update_stats(loc_info,system_info,detail_info,economic_info,m_labels,s_labels,d_labels,e_labels):
for m in m_labels:
m_value = list(loc_info[m])
m_value = m_value[0]
window[m+'i'].update(m_value)
for s in s_labels:
s_value = list(system_info[s])
s_value = s_value[0]
window[s+'i'].update(s_value)
for d in d_labels:
d_value = list(detail_info[d])
d_value = d_value[0]
window[d+'i'].update(d_value)
for e in e_labels:
e_value = list(economic_info[e])
e_value = e_value[0]
window[e+'i'].update(e_value)
def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg
def delete_figure_agg(figure_agg):
figure_agg.get_tk_widget().forget()
plt.close('all')
# ------------------------------- MATPLOTLIB CODE HERE -------------------------------
# fig = matplotlib.figure.Figure(figsize=(5, 4), dpi=100)
# t = np.arange(0, 3, .01)
# fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t))
######################################################################################
f= Figure(figsize=(4,5),dpi=100)
style.use("dark_background")
a = f.add_subplot(111)
a.clear()
a.set_xticks([])
a.set_yticks([])
xcoordinates = []
ycoordinates = []
location = '-99'
detail_flag = 'main_world' # flag used to mark whether the details should be main world or exo worlds.
def get_coordinates(thedataframe):
xcoordinates = []
ycoordinates = []
coord_list = list(thedataframe['location'])
for coord in coord_list:
x_axis = int(coord[0:2])
mod = x_axis % 2
if mod > 0:
top_y_limit = 41
else: top_y_limit = 40.5
y_axis = (top_y_limit-int(coord[2:4]))
xcoordinates.append(x_axis)
ycoordinates.append(y_axis)
return(xcoordinates,ycoordinates)
def animate(chart_title,color_choice,plot_size,label_choice,*args):
a.clear()
a.set_xticks([])
a.set_yticks([])
xcoordinates = []
ycoordinates = []
for arg_num, arg in enumerate(args):
color_choice_s = color_choice[arg_num]
xcoordinates,ycoordinates = get_coordinates(arg)
a.set_title(chart_title, color='white')
a.scatter(xcoordinates,ycoordinates,c=color_choice_s,s=plot_size)
if label_choice == "num":
name_list = arg['location'].tolist()
else:
name_list = arg['system_name'].tolist()
label_color = 'White'
if len(name_list) <= 100:
name_coords = list(zip(xcoordinates,ycoordinates))
row_num = 0
for each_item in name_coords:
row_name = name_list[row_num]
a.text(each_item[0]-2,each_item[1],row_name,fontsize = 10,color = label_color)
row_num += 1
f.tight_layout()
f.canvas.draw_idle()
def draw_map():
print('Map is selected')
if values['-NUM-'] is True:
print('Numbers were chosen')
label_choice = 'num'
else:
print('Names were chosen')
label_choice = 'name'
if values['-FULL-'] is True:
print('Full Sector was chosen')
stell_colors =['dimgray','Blue']
plot_list = [30]
animate(location_orb_name,stell_colors,plot_list,label_choice,df,loc_info)
else:
print('Earth Like Planets was chosen')
df_special_earth = (df_details.query('type == "Ocean*"'))
stell_colors =['dimgray','Green']
plot_list = [30,65]
animate('Earth-like worlds',stell_colors,plot_list,label_choice,df,df_special_earth)
folder = 'images/'
# PIL supported image types
img_types = (".png", ".jpg", "jpeg", ".tiff", ".bmp")
# get list of files in folder
flist0 = os.listdir(folder)
# create sub list of image files (no sub folders, no wrong file types)
fnames = [f for f in flist0 if os.path.isfile(
os.path.join(folder, f)) and f.lower().endswith(img_types)]
option_list = []
db_name = 'C:/Users/sean/Documents/GitHub/traveller-universe-creator/sector_db/example-66.db'
list_images = [['mask','Completely Stellar Masked'],
['ocean','Ocean or Earth-like World'],
['exotic','Exotic Atmosphire'],
['corrosive','Corrosive Atmosphire'],
['vacuum','Vacuum World'],
['asteroid','Object is Planetary Belt'],
['light','Low Gravity World'],
['heavy','High Gravity World'],
['hot','Unhinhabitable Heat'],
['cold','Uninhabitable Cold'],
['hipop','High Population World'],
['wealthy','Wealthy System'],
['industrial','Industrial Economy'],
['agricultural','Agricultural Economy'],
['important','Important System'],
['naval','Naval Base Present'],
['scout','Scout Base Present'],
['prison','Interplanetary Prison Present'],
['moon','Object is a moon'],
['gas giant','Object is a gas giant']
]
remarks_list = [['In', 'industrial'],
['Ag', 'agricultural'],
['Hi', 'hipop'],
['Px', 'prison']]
conn = sqlite3.connect(db_name)
c = conn.cursor()
new_main_query = '''SELECT *
FROM traveller_stats
WHERE main_world = 1'''
df_new_main = pd.read_sql_query(new_main_query,conn)
m_labels = []
m_labels = list(df_new_main.columns)
m_labels_len = len(m_labels)
system_main_query = '''SELECT location,
remarks,
ix,
ex,
cx,
n,
bases,
zone,
pbg,
w,
allegiance,
stars
FROM system_stats
'''
df_system_main = pd.read_sql_query(system_main_query,conn)
s_labels = []
s_labels = list(df_system_main.columns)
s_labels.remove('location')
s_labels_len = len(s_labels)
new_detail_sql_query = '''SELECT t.system_name, t.location, o.body, o.wtype as type, o.day, o.year,
o.gravity, o.atmos_pressure, o.atmos_composition, o.temperature, o.climate,
o.impact_moons, o.natural_moons,
j.stellar_distance as stellar_distance,
j.jump_point_Mm as jump_point_distance,
j.planet_stellar_masked as stellar_mask,
j.hrs_1g,j.hrs_2g,j.hrs_3g,j.hrs_4g,j.hrs_5g,j.hrs_6g,
e.mainworld_calc
FROM traveller_stats t
LEFT JOIN orbital_bodies o
ON t.location_orb = o.location_orbit
LEFT JOIN journey_data j
ON j.location_orbit = t.location_orb
LEFT JOIN main_world_eval e
ON t.location_orb = e.location_orbit
WHERE t.main_world = 1
'''
df_details = pd.read_sql_query(new_detail_sql_query,conn)
d_labels = []
d_labels = list(df_details.columns)
d_labels.remove('location')
d_labels.remove('system_name')
d_labels_len = len(d_labels)
economic_sql_query = '''SELECT * FROM far_trader'''
df_economic = pd.read_sql_query(economic_sql_query,conn)
e_labels = []
e_labels = list(df_economic.columns)
e_labels.remove('location')
e_labels.remove('id')
e_labels_len = len(e_labels)
conn.commit()
c.close()
conn.close()
###################Layouts
def make_win1():
column_one = [
[sg.Text("SYSTEMS")],
[sg.Listbox(option_list,enable_events=True,size=(20,32),key=('-LOCATIONS-'))]
]
column_two = [[sg.Text("UWP Categories")],
[sg.HSeparator()],]
column_three = [[sg.Text("World Details")],
[sg.HSeparator()],]
for m in m_labels:
column_two += [sg.Text(m+':',enable_events = True,key=(m),pad=(0,0))],
column_three += [sg.Text('|',enable_events = True,key=(m+'i'),pad=(0,0))],
column_two += [[sg.Text("System Categories",pad=(5,(15,2)))],
[sg.HSeparator()],]
column_three += [[sg.Text("System-wide Details",pad=(5,(15,2)))],
[sg.HSeparator()],]
for s in s_labels:
column_two += [sg.Text(s+':',enable_events = True,key=(s),pad=(0,0))],
column_three += [sg.Text('|',enable_events = True,key=(s+'i'),pad=(0,0))],
column_four = [[sg.Text("Scientific Categories")],
[sg.HSeparator()],]
column_five = [[sg.Text("World Details")],
[sg.HSeparator()],]
for d in d_labels:
column_four += [sg.Text(d+':',enable_events = True,key=(d),pad=(0,0))],
column_five += [sg.Text('|',enable_events = True,key=(d+'i'),pad=(0,0))],
column_four += [[sg.Text("Economic Categories",pad=(5,(15,2)))],
[sg.HSeparator()],]
column_five += [[sg.Text("System-wide Details",pad=(5,(15,2)))],
[sg.HSeparator()],]
for e in e_labels:
column_four += [sg.Text(e+':',enable_events = True,key=(e),pad=(0,0))],
column_five += [sg.Text('|',enable_events = True,key=(e+'i'),pad=(0,0))],
map_options = [
[sg.Radio('Show Selected','-DISPLAY-',key=('-FULL-'),default=True,pad=(0,0))],
[sg.Radio('Find Earth Like','-DISPLAY-',key=('-EARTH-'),pad=(0,0))],
]
label_options = [
[sg.Radio('Num','-OVERLAY-',key=('-NUM-'),default=True,pad=(0,0))],
[sg.Radio('Name','-OVERLAY-',key=('-NAME-'),pad=(0,0))],
]
column_six = [[sg.Canvas(key='-CANVAS-')],
[sg.Column(map_options),
sg.Column(label_options),
sg.Button('Map',key=('-MAP-'))],
]
# [sg.Radio('Sector',key=('-SECTOR-')),sg.Button('Earth-like',key=('-EARTH-')),
# sg.Button('Subsector'),sg.Button('System'),
image_layout = []
for li in list_images:
filename = os.path.join(folder,li[0]+'.png')
image_layout += [sg.Image(data=get_img_data(filename, first=True),
tooltip=li[1], enable_events = True,key=(li[0]))],
layout = [
[sg.Text("""Browse Window""")],
[sg.HSeparator()],
[
sg.Text('Choose A Sector', size=(15, 1), auto_size_text=False, justification='right'),
sg.In(size=(20,1),enable_events=True,key=('-DB-'),justification='right'),
sg.FileBrowse(file_types=(("Database Files","*.db"),),
enable_events=True,
initial_folder=("sector_db")),
sg.VSeparator(),
sg.Button('Stellar',key=('-STELLAR-')),
sg.Button('Main World',key=('-MAIN-')),
sg.Button('Full System', key=('-SYSTEM-')),
sg.VSeparator(),
sg.VSeparator(),
sg.Button('Exit'),
],
[sg.HSeparator(),
],
[
sg.Column(column_one),
sg.VSeparator(),
sg.Column(column_two),
sg.Column(column_three),
sg.Column(image_layout),
sg.VSeparator(),
sg.Column(column_four),
sg.Column(column_five),
sg.VSeparator(),
sg.Column(column_six),
],
]
return sg.Window("""Bartleby's Sector Builder""", layout,size=(1200,700),finalize=True)
def make_win2(star_columns,star_list,location):
# if star_list.len ==1:
try:
# star_column_one = [sg.Text("Stellar Details"),]
# star_column_two = [sg.Text(location),]
star_column_one = []
star_column_two = []
star_column_three = []
star_column_four = []
star_width = 300
print('Entering star loop')
for s_num, s in enumerate(star_list[0]):
star_column_one += [sg.Text(star_columns[s_num]+':')],
star_column_two += [sg.Text(s)],
if len(star_list) > 1:
star_width = 350
for s_num, s in enumerate(star_list[1]):
star_column_three += [sg.Text(s)],
if len(star_list) == 3:
star_width = 400
for s_num, s in enumerate(star_list[2]):
star_column_four += [sg.Text(s)],
print('Setting new layout')
star_layout = [
[sg.Column(star_column_one),sg.Column(star_column_two),
sg.Column(star_column_three),sg.Column(star_column_four)],
[sg.Button('Exit')]
]
except:
sg.Popup('Failed star layout')
# else:
# layout = [[sg.Text('More than one star')],
# [sg.Button('Exit')]]
return sg.Window('Stellar Details',star_layout,size=(star_width,800),finalize=True)
# Create the Window
window1, window2 = make_win1(), None # start off with 1 window open
# Event Loop to process "events" and get the "values" of the inputs
fig_canvas_agg = None
while True:
window, event, values = sg.read_all_windows()
if event == sg.WIN_CLOSED or event == 'Exit':
window.close()
if window == window2: # if closing win 2, mark as closed
window2 = None
elif window == window1: # if closing win 1, exit program
break
if event == '-DB-':
db_name = values['-DB-']
conn = sqlite3.connect(db_name)
c = conn.cursor()
df = pd.read_sql_query(new_main_query,conn)
df_system = pd.read_sql_query(system_main_query,conn)
df_stellar = pd.read_sql_query('SELECT * FROM stellar_bodies',conn)
df_details = pd.read_sql_query(new_detail_sql_query,conn)
print('made it out of df')
df_details['atmos_pressure'] = round(df_details['atmos_pressure'],2)
df_details['jump_point_distance'] = round(df_details['jump_point_distance'],1)# otherwise crazy decimals added
df_details['mainworld_calc'] = round(df_details['mainworld_calc'],2)
df_economic = pd.read_sql_query(economic_sql_query,conn)
df_economic['exchange'] = round(df_economic['exchange'],2) # otherwise crazy decimals added
exo_sql_query = '''SELECT t.*,
s.remarks,
s.ix,
s.ex,
s.cx,
s.n,
s.bases,
s.zone,
s.pbg,
s.w,
s.allegiance,
stars
FROM traveller_stats t
LEFT JOIN system_stats s ON s.location=t.location'''
df_exo = pd.read_sql_query(exo_sql_query,conn)
exo_detail_sql_query = '''SELECT t.system_name, t.location, t.location_orb,
o.body, o.wtype as type, o.day, o.year,
o.gravity, o.atmos_pressure, o.atmos_composition, o.temperature, o.climate,
o.impact_moons, o.natural_moons,
j.stellar_distance as stellar_distance,
j.jump_point_Mm as jump_point_distance,
j.planet_stellar_masked as stellar_mask,
j.hrs_1g,j.hrs_2g,j.hrs_3g,j.hrs_4g,j.hrs_5g,j.hrs_6g,
e.mainworld_calc
FROM traveller_stats t
LEFT JOIN orbital_bodies o
ON t.location_orb = o.location_orbit
LEFT JOIN journey_data j
ON j.location_orbit = t.location_orb
LEFT JOIN main_world_eval e
ON t.location_orb = e.location_orbit
'''
df_exo_details = pd.read_sql_query(exo_detail_sql_query,conn)
df_exo_details['atmos_pressure'] = round(df_exo_details['atmos_pressure'],2)
df_exo_details['jump_point_distance'] = round(df_exo_details['jump_point_distance'],1)
df_exo_details['mainworld_calc'] = round(df_exo_details['mainworld_calc'],2)
df['loc_name'] = df['location'] + '-' + df['system_name']
df_details['loc_name'] = df_details['location'] + '-' + df_details['system_name']
option_list = list(df['loc_name'])
window['-LOCATIONS-'].update(option_list)
if fig_canvas_agg:
# ** IMPORTANT ** Clean up previous drawing before drawing again
delete_figure_agg(fig_canvas_agg)
conn.commit()
c.close()
conn.close()
if event == '-MAIN-':
detail_flag = 'main_world'
window['-LOCATIONS-'].update(option_list)
elif event == '-LOCATIONS-':
try:
location = values['-LOCATIONS-'][0][0:4]
if detail_flag == 'main_world':
location_orb_name = values['-LOCATIONS-'][0]
loc_info = df.loc[df['location'] == location]
system_info = df_system.loc[df_system['location'] == location]
detail_info = df_details[df_details['location'] == location]
economic_info = df_economic[df_economic['location'] == location]
update_stats(loc_info,system_info,detail_info,economic_info,m_labels,s_labels,d_labels,e_labels)
try:
clear_images()
select_images(loc_info,system_info,detail_info,economic_info)
except:
sg.Popup('Failed during Mainworld image creation')
else:
print('Exo Flag')
location_orb_name = values['-LOCATIONS-'][0]
try:
loc_info = df_exo.loc[df_exo['location_orb'] == location_orb_name]
detail_info = df_exo_details[df_exo_details['location_orb'] == location_orb_name]
economic_info = df_economic[df_economic['location'] == location]
except:
sg.Popup('Loc Info fail in Exo assignments')
try:
update_stats(loc_info,system_info,detail_info,economic_info,m_labels,s_labels,d_labels,e_labels)
except:
sg.Popup('for loops failed in Exo Assignments')
try:
clear_images()
select_images(loc_info,system_info,detail_info,economic_info)
except:
sg.Popup('Failed during non-mainworld Image creation')
try:
if fig_canvas_agg:
# ** IMPORTANT ** Clean up previous drawing before drawing again
delete_figure_agg(fig_canvas_agg)
print('Map is selected')
draw_map()
fig_canvas_agg = draw_figure(window['-CANVAS-'].TKCanvas, f)
except:
print('Failed Map button')
except:
sg.popup('Error in LOCATION: '+detail_flag)
elif event == '-STELLAR-' and not window2:
try:
print('pressed STELLAR')
star_list=[]
df_star = df_stellar.loc[df_stellar['location'] == location]
star_columns = list(df_star.columns)
for s in range(0,df_star.shape[0]):
row = ''
row=df_star.iloc[s]
star_list.append(row)
window2 = make_win2(star_columns,star_list,location)
except:
print('Failed Stellar button')
elif event == '-SYSTEM-':
try:
print('pressed SYSTEM')
detail_flag = 'exo_world'
loc_info = df_exo.loc[df_exo['location_orb'] == location_orb_name]
detail_info = df_exo_details[df_exo_details['location_orb'] == location_orb_name]
economic_info = df_economic[df_economic['location'] == location]
exo_location_orb_name = values['-LOCATIONS-'][0]
exo_location = values['-LOCATIONS-'][0][0:4]
exo_loc_info = df_exo.loc[df_exo['location'] == location]
exo_detail_info = df_details[df_details['location'] == location]
economic_info = df_economic[df_economic['location'] == location]
economic_info['exchange'] = round(economic_info['exchange'],2) # otherwise crazy decimals added
exo_loc_info['loc_name'] = exo_loc_info['location_orb']
exo_list = list(exo_loc_info['loc_name'])
exo_list.sort()
window['-LOCATIONS-'].update(exo_list)
except:
print('Failed System button. Location was:',location)
elif event == '-MAP-':
try:
if fig_canvas_agg:
# ** IMPORTANT ** Clean up previous drawing before drawing again
delete_figure_agg(fig_canvas_agg)
draw_map()
fig_canvas_agg = draw_figure(window['-CANVAS-'].TKCanvas, f)
except:
print('Failed draw_map()')
window.close()