Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

Rick Johnson rantingrickjohnson at gmail.com
Sun Jun 10 21:47:43 CEST 2012


On Jun 10, 2:36 pm, Rick Johnson <rantingrickjohn... at gmail.com> wrote:

> #
> # Or become a pro and create reusable objects!
> #
> class LE(tk.Frame):
>     def __init__(self, master, **kw):
>         tk.Frame.__init__(self, master)
>         self.l = tk.Label(self, **kw)
>         self.l.pack(side=LEFT)
>         self.e = tk.Entry(self)
>         self.e.pack(side=LEFT, fill=X, expand=YES)
> root = tk.Tk()
> root.title('Pro')
> for x in range(10):
>     le = LE(root, text="Field_"+str(x))
>     le.pack(fill=X, expand=YES)
> root.mainloop()

PS: The keywords argument should have been passed to the entry widget
and NOT the label. Yes, occasionally, even pros make subtle mistakes.


More information about the Python-list mailing list