-
Notifications
You must be signed in to change notification settings - Fork 1
/
view_seed.py
51 lines (51 loc) · 1.11 KB
/
view_seed.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
#
# View Seed
#
# Peter Turney, August 9, 2020
#
# Load a seed from a pickle and display it
# in Golly.
#
import golly as g
import model_classes as mclass
import model_functions as mfunc
import model_parameters as mparam
import pickle
#
# Set the colours so they are suitable for printing.
# The background should be light and the foreground
# should be dark.
#
g.setcolors([0,255,255,255,1,0,0,0])
#
# Ask the user to select a pickle.
#
g.note("You will be asked to select a pickled seed file.\n" + \
"The top seed in the file will be inserted into Golly.")
#
pickle_path = g.opendialog("Select a pickled seed file (*.bin)", \
"(*.bin)|*.bin", g.getdir("app"))
#
# Read the pickle file.
#
pickle_handle = open(pickle_path, "rb") # rb = read binary
pickle = pickle.load(pickle_handle)
pickle_handle.close()
#
# Select the top seed from the pickle file.
#
seed = pickle[0]
#
# Write the seed into Golly.
#
for x in range(seed.xspan):
for y in range(seed.yspan):
state = seed.cells[x][y]
g.setcell(x, y, state)
#
# Fit the pattern to the viewport.
#
g.fit()
#
#
#