[Tutor] window graphics

Alan Gauld alan.gauld at btinternet.com
Thu Jul 2 16:07:44 CEST 2009


"David H. Burns" <dhburns at cherokeetel.net> wrote

> All the graphics libraries I've seen are far to complex (and don't seem 
> compatible with 3. 

See the other posts re the wisdom of using Python 3 at this stage, 
however....

> What I really need to know is two things (1) how to 
> set up a graphic window 

>>> from tkinter import *
>>> tk = Tk()
>>> c = Canvas(tk, height=100,width=100)
>>> c.pack()
>>> c.create_line(0,15,30,75)
1
>>> c.create_oval(50,70,80,90)
2
>>> tk.mainloop()

2)how to plot a pixel. Basically that's all  a "graphics package" needs. 

There is no pixel method per say but you can plot a single pixel 
sized oval.

c.create_oval(4,4,4,4)

Which is hard to see but here is a fuller example:

>>> tk = Tk()
>>> c = Canvas(tk, height=100,width=100)
>>> c.pack()
>>> for x in range(25,50):
            c.create_oval(x,x,x,x)

>>> tk.mainloop()

3) Is this the right group?
Yes.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/l2p/




More information about the Tutor mailing list