[Fwd: Re: [Tutor] Recursive Tkinter buttons]

Ismael Garrido ismaelgf at adinet.com.uy
Fri Feb 25 08:53:54 CET 2005


Sent only to Liam... Forwading..

-------- Original Message --------
Subject: 	Re: [Tutor] Recursive Tkinter buttons
Date: 	Fri, 25 Feb 2005 05:45:00 -0200
From: 	Ismael Garrido <ismaelgf at adinet.com.uy>
To: 	Liam Clarke <cyresse at gmail.com>
References: 	<c7ff3855050224141925d5dc88 at mail.gmail.com> 
<421E8CD5.3080708 at tds.net> <c7ff3855050224225377dd598b at mail.gmail.com> 
<f2ff2d05022423194d795e69 at mail.gmail.com>



Liam Clarke wrote:

>>               
>>                for i in range(0,10):
>>                        print i
>>                        buttonlabel = "field " +str(i)
>>                        button[i].append = Button (text=buttonlabel)
>>                        button[i].grid(column=3, row = i+3)
>>
>>The current error is:
>>
>>  File "report.py", line 80, in createWidgets
>>    button[i].append = Button (text=buttonlabel)
>>IndexError: list index out of range
>>
>>    
>>
> button = []
>for i in range(0,10):
>     print i
>     print button[i]
>
>
>Will cause the exact same error as button[i].append. Why? button=[],
>it has no index.
>Perhaps you just mean button[i] = Button (text=buttonlabel)?
>  
>
Nope, that will give an Array Out of Bounds exception. Remember buttons = []

What he meant is:

button.append( Button(text=buttonlabel) )

(I tested it, too!)

Bye
Ismael






More information about the Tutor mailing list