Getting RLE in Golly
- Nathaniel
- Site Admin
- Posts: 862
- Joined: December 10th, 2008, 3:48 pm
- Location: New Brunswick, Canada
- Contact:
Getting RLE in Golly
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
Can you copy it into the clipboard and retrieve it from there?
What do you do with ill crystallographers? Take them to the mono-clinic!
- Nathaniel
- Site Admin
- Posts: 862
- Joined: December 10th, 2008, 3:48 pm
- Location: New Brunswick, Canada
- Contact:
Re: Getting RLE in Golly
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.calcyman wrote:Can you copy it into the clipboard and retrieve it from there?
Re: Getting RLE in Golly
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.
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.
- Nathaniel
- Site Admin
- Posts: 862
- Joined: December 10th, 2008, 3:48 pm
- Location: New Brunswick, Canada
- Contact:
Re: Getting RLE in Golly
Awesome, thanks Andrew. As if I needed another reason to want 2.1Andrew 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.
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
You can do things like this: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?
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
...