[Tutor] Traffic Light

ALAN GAULD alan.gauld at btinternet.com
Sun Jan 20 08:47:36 CET 2013



That must be what I am missing.  How do I call the functions so I can have
>the shapes appear on the canvas?
>
>AG> the same way you call all the other functions.
>AG> The bit I can't answer is *where* you call them. I'm not sure 
>AG> where in your code you want them. 
>AG> Is it before you press the buttons or is it when you press them?
>
>On 1/19/13 5:02 PM, "Alan Gauld" <alan.gauld at btinternet.com> wrote:
>
>>The shapes aren't there because you don't draw them. you have some
>>functions that might draw shapes but you never call them. 
>
>>
>>>      # Display a rectangle
>>>      def displayRect(self):
>>>          self.canvas.create_rectangle(10, 10, 100, 100, tages = "rect")
>>>
>>>      # Display a Oval for the top light
>>>      def displayOval(self):
>>>          self.canvas.create_oval(10, 10, 10, 10)
>
>AG> So somewhere you need to write
>AG>
>AG> self.displayRect()
>
>
>AG> and
>AG>
>AG>self.displayOval()
>AG>
>AG>Except you probably want to modify them so you do it with the location:
>AG>
>AG>self.displayOval(10,10,10,10)
>
>-- 
>Alan G
>Author of the Learn to Program web site
>http://www.alan-g.me.uk/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130120/4a718aaa/attachment.html>


More information about the Tutor mailing list