Page 1 of 1
Getting RLE in Golly
Posted: June 21st, 2009, 1:47 pm
by Nathaniel
I'm probably just being dense here or somehow completely missing a command in the documentation, but I want to be able to manipulate a pattern's RLE string in a Golly Python script, and I can't seem to find a way to retrieve the current pattern's RLE string in any less of a roundabout way than calling golly.store() to save the RLE string as a file on the harddrive, and then having Python read in the RLE string from that file. Thoughts?
Re: Getting RLE in Golly
Posted: June 21st, 2009, 2:21 pm
by apg
Can you copy it into the clipboard and retrieve it from there?
Re: Getting RLE in Golly
Posted: June 21st, 2009, 2:33 pm
by Nathaniel
calcyman wrote:Can you copy it into the clipboard and retrieve it from there?
There seems to be a Python library that lets you retrieve clipboard data on Windows machines, but I haven't come across a cross-platform way of doing it.
Re: Getting RLE in Golly
Posted: June 21st, 2009, 6:38 pm
by Andrew
What you're doing is probably the best (only?) way in 2.0. In 2.1 Dave Greene has added a getclipstr() command which makes it very easy:
import golly as g
g.select(g.getrect())
g.copy()
rle = g.getclipstr()
There's also a setclipstr(string) command for putting arbitrary text into the clipboard. Golly 2.1b4 should be available in a couple of days.
Re: Getting RLE in Golly
Posted: June 21st, 2009, 7:10 pm
by Nathaniel
Andrew wrote:What you're doing is probably the best (only?) way in 2.0. In 2.1 Dave Greene has added a getclipstr() command which makes it very easy:
import golly as g
g.select(g.getrect())
g.copy()
rle = g.getclipstr()
There's also a setclipstr(string) command for putting arbitrary text into the clipboard. Golly 2.1b4 should be available in a couple of days.
Awesome, thanks Andrew. As if I needed another reason to want 2.1
Also (this is more of a curiosity than anything) is there a way in a script to determine which version of Golly the user is running?
Re: Getting RLE in Golly
Posted: June 21st, 2009, 7:27 pm
by Andrew
Nathaniel wrote:Also (this is more of a curiosity than anything) is there a way in a script to determine which version of Golly the user is running?
You can do things like this:
Code: Select all
import golly as g
try:
rle = g.getclipstr()
# if we get here then we're using Golly 2.1 or later
...
except:
# we're using Golly 2.0 or older
...