AW: [mailinglist] [Python-de] dynamische Variablennamen

Mathias Uebel mathias.uebel at meeloon.de
Die Jun 8 15:22:18 CEST 2004


Uwe Schmitt wrote:

Hallo Uwe,

[...]

Alles wieder auf Null!
Ich habe das so gemacht: Die Entries an eine Liste anhängen und dann 
auslesen.
Danke nochmals für die Hilfe!
Grusz Mathias

from Tkinter import *
root = Tk()
root.title("Quiz")
q1 = "Favorite color: "
q2 = "Favorite dessert: "
q3 = "Favorite book: "
q4 = "Favorite pet: "

Label(root, text = "My Favorite Things", fg = '#006699', font =
('Papyrus', 20)).grid(row=0, column = 0, columnspan = 2)

list = [q1, q2, q3, q4]
rownum = 1
colnum = 0
liste = []                    #### neu
for item in list:
    lbl = Label(root, text = item)
    lbl.grid(row = rownum, column = colnum, pady = 2, sticky = W)
    entry = Entry(root, width = 20)
    entry.grid(row = rownum, column = colnum+1, pady = 2)
    rownum += 1
    colnum = 0
    liste.append(entry)         ### neu
Button(root, text = "Tell Us").grid(row = rownum, column = 0, columnspan
= 2, sticky = EW, pady = 4)



-- 
Lieber lachende Pinguine als tanzende Büroklammern!

CU in www.meeloon.de
--