a simple graphic library
tool_man at spamcop.net
Tue Aug 27 18:02:46 CEST 2002
In article <3D6B6C94.9020203 at wanadoo.fr>, polux wrote:
> Miki Tebeka wrote:
>> Hello Polux,
>>>Do you know if there is a simple graphic module for python (like SRGP
>>>for C in exemple) which would trace very simple meshes like points,
>>>rectangles, circles, etc on win32 ?
> It is not exactly what I want (and the setup doesn't work very well on
> my computer)
> I'd like commands like point(10,10) or something like this to trace a
> point on the scree like with old langages like BASIC
Well, to paint on the screen, you need to have some sort of graphic
interface on which to draw. So, you will have to deal with windows, events
and so on anyway, and Tkinter is probably about as simple as you can expect.
If nothing else, you should be able to copy and paste some demo code to
create a single window with a canvas on it, and use the canvas' graphic
primitives to doodle on it.
For example, this will create a window with a white background, and draws
100 random ovals on it:
from Tkinter import *
h = 200
w = 300
self.QUIT = Button(self)
self.QUIT["text"] = "Quit"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.doodle = Canvas(self, bg="#FFFFFF", height=h, width=w)
foo = random.Random()
for i in range(100):
red = foo.randrange(0,255)
green = foo.randrange(0,255)
blue = foo.randrange(0,255)
top = foo.randrange(0,h)
bottom = foo.randrange(top,h)
left = foo.randrange(0,w)
right = foo.randrange(left,w)
fill = '#%.2X%.2X%.2X' % (red,green,blue))
app = Application()
More information about the Python-list