-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcosystemSim_Array_VIS_FOR_TK.py
More file actions
55 lines (40 loc) · 1.51 KB
/
EcosystemSim_Array_VIS_FOR_TK.py
File metadata and controls
55 lines (40 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''Missionaries_Array_VIS_FOR_TK.py
Version of Aug. 5, 2017.
'''
from bio_show_state_array import initialize_tk, state_array, state_display, STATE_WINDOW, test
from tkinter import font
myFont=None
WIDTH = 1000
HEIGHT = 1000
TITLE = 'Ecosystem Simulator'
def initialize_vis():
initialize_tk(WIDTH, HEIGHT, TITLE)
def render_state(s):
# Note that font creation is only allowed after the Tk root has been
# defined. So we check here if the font creation is still needed,
# and we do it (the first time this method is called).
global myFont
if not myFont:
myFont = font.Font(family="Helvetica", size=18, weight="bold")
# Create the default array of colors
tan = (200,190,128)
blue = (100,100,255)
brown = (100, 80, 0)
purple = (128, 0, 192)
cyan = (100, 200, 200)
row = [tan]*5
the_color_array = [row]
# Now create the default array of string labels.
row = ['' for i in range(5)]
the_string_array = [row]
# Adjust colors and strings to match the state.
animals = s.animal
for count,i in enumerate(animals):
the_string_array[0][count]=i
caption="Current state of the puzzle. Textual version: "+str(s)
the_state_array = state_array(color_array=the_color_array,
string_array=the_string_array,
text_font=myFont,
caption=caption)
print("the_state_array is: "+str(the_state_array))
the_state_array.show(s)