Here's a preliminary version of a simplified interface to a Tkinter canvas. It's simple enough so that the user just needs to type: ### from graphics import * def drawBox(x1, y1, x2, y2): """Draws a box where the upper left is (x1, y1), and the lower right is (x2, y2).""" positionPen(x1, y1) drawLineTo(x2, y1) drawLineTo(x2, y2) drawLineTo(x1, y2) drawLineTo(x1, y1) drawBox(-100, 100, 100, -100) ### to get a box drawn. By default, the Canvas is 400x400, and the user can send commands like: drawLine drawPoint setRGBColor without having to worry about creating a canvas. Also, it uses normal rectangular coordinates, so (0, 0) is at the center, (200, 200) is the upper right corner, and (-200, -200) is the bottom left. Please give suggestions on this; I just typed this up yesterday, so it surely has room for improvement and clarity. I hope this is useful!
Hi Danny, I'm trying to use your simple graphics module. The problems that I wrote to you about earlier, were related to installing a new version of IDLE that came with VPython and overwrote my default install that came with Python2.0. I've got that fixed, now. So, I've put your graphics module under Python20/Lib/ and when I try to run your little script below, a Tkinter window comes up, but it is blank, and it stays blank. ??? Help? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Wed, 9 May 2001 03:16:29 -0700 (PDT), Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> wrote about [Edu-sig] graphics programming with Python: :Here's a preliminary version of a simplified interface to a Tkinter :canvas. It's simple enough so that the user just needs to type: : :### :from graphics import * : :def drawBox(x1, y1, x2, y2): : """Draws a box where the upper left is (x1, y1), and the : lower right is (x2, y2).""" : positionPen(x1, y1) : drawLineTo(x2, y1) : drawLineTo(x2, y2) : drawLineTo(x1, y2) : drawLineTo(x1, y1) : :drawBox(-100, 100, 100, -100) :### : :to get a box drawn. By default, the Canvas is 400x400, and the user can :send commands like: : : drawLine : drawPoint : setRGBColor : :without having to worry about creating a canvas. Also, it uses normal :rectangular coordinates, so (0, 0) is at the center, (200, 200) is the :upper right corner, and (-200, -200) is the bottom left. : :Please give suggestions on this; I just typed this up yesterday, so it :surely has room for improvement and clarity. : :I hope this is useful!
I take it back. I was trying to put the script into the interactive interpreter in IDLE. That didn't work. When I put it into a saved script file, and ran it from within IDLE, by opening the script in a separate window, then it appeared to work just fine. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Sat, 12 May 2001 11:00:38 -0700, Sheila King <sheila@thinkspot.net> wrote about Re: [Edu-sig] graphics programming with Python: :Hi Danny, I'm trying to use your simple graphics module. : :The problems that I wrote to you about earlier, were related to installing a new :version of IDLE that came with VPython and overwrote my default install that :came with Python2.0. I've got that fixed, now. : :So, I've put your graphics module under Python20/Lib/ and when I try to run your :little script below, a Tkinter window comes up, but it is blank, and it stays :blank. : :??? : :Help?
You can use Daniel's graphics.py in shell mode if you enter the lines sequentially.
from graphics import * clearGraphics() drawLine(0, 0, 100, 0) drawLine(100, 0, 100, 100) drawLine(100, 100, 0, 100) drawLine(0, 100, 0, 0)
This seems tedius because you'd normally want to do more than draw a single line.
import circle circle.testCircles(10,1)
is a more realistic example of interactive use. Kirby -----Original Message----- From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of Sheila King Sent: Saturday, May 12, 2001 12:03 PM To: Daniel Yoo; edu-sig@python.org Subject: Re: [Edu-sig] graphics programming with Python I take it back. I was trying to put the script into the interactive interpreter in IDLE. That didn't work. When I put it into a saved script file, and ran it from within IDLE, by opening the script in a separate window, then it appeared to work just fine.
participants (3)
-
Daniel Yoo
-
Kirby Urner
-
Sheila King