entries between labels dynamically

Artur Skura arturs at iidea.pl
Sat Feb 16 07:41:45 EST 2002


André Larsen Risnes wrote:
>         else:
>             Label(root, text=part).pack(side=LEFT)
>         Label(f, ...)
>         f.pack(side=TOP, anchor=W, fill=X, expand=YES)
> 
> (haven't tested this last part, though)

Works like a miracle (with small modifications):


from Tkinter import *

root = Tk()

file=open("README","r")
for line in file.readlines():
    f = Frame(root)
    for part in line.split("%"):
        if part == "text":
            Text(f, width=8, height=1).pack(side=LEFT)
        else:
            Label(f, text=part).pack(side=LEFT)
        f.pack(side=TOP, anchor=W, fill=X, expand=YES)

root.mainloop()

Some things don't line up still (http://7bulls.com/~askura/tk1.png), 
but it's easy sailing now.

Thanks to everybody!

Regards,
Artur
-- 
http://www.wolneprogramy.org



More information about the Python-list mailing list