Forum Archive

Python Spirographs anyone?

ccc

Is anyone willing to do a bit of Spirograph hacking? http://www.eddaardvark.co.uk/python_patterns/spirograph.html has some nice images that might be cool to get working in Pythonista. The code below copies the source files into Pythonista and then shows the webpage. Of course, the Spirograph code will need to be ported to run on Pythonista but it might be an interesting challenge...

# coding: utf-8

'''This script will copy 7 python files locally and then open a webpage...'''

import console, requests, webbrowser

file_names = 'Spirograph SpirographDriver WindowsBMP LineDrawer ColourMap CircleDrawer MakeFileList'
url_root = 'http://www.eddaardvark.co.uk/python_patterns/code/'
fmt = 'Creating local file {}: {}'

for i, file_name in enumerate(''.split()):
    file_name += '.py'
    text = requests.get(url_root + file_name).text
    if text:
        console.hud_alert(fmt.format(i+1, file_name))
        with open(file_name, 'w') as out_file:
            out_file.write(text)

url_root = url_root.rsplit('/', 2)[0]
webbrowser.open(url_root)
#webbrowser.open(url_root + '/spirograph.html')
Webmaster4o

I wrote one in Python for TKinter last year, and started moving it to pythonista UI, but didn't get far, I had already written it and didn't want to take the trouble to move it to pythonista as I saw no real use. I tried implementing with more than two arms, but failed somewhere. That was a long quest on stackoverflow that got me nowhere.

Anyway,My TKinter code is here, you're welcome to use part of it if you want.

Webmaster4o

Actually, looking now, it appears that I did get as far as porting it to canvas, if not UI. My code is working, but probably messy, I left a bunch of unused code in it from my TKinter version. The script is here.

ccc

Cool. I left some comments on the gist.

Also found https://github.com/J-Gamer/Spirograph