En Mon, 04 May 2009 10:27:49 -0300, Amr <amrbek...@gmail.com> escribió:
I've been spending the last few days experimenting with Tkinter. The grid manager is nice and easy to use, but I have found that I am often having to specify padx and pady options to every widget I add to my grid. The way I am doing it is to create a dictionary: paddding = {'padx': '1m', 'pady': '1m'} and then apply it to the grid method using **padding. However, I was wondering if there was a way of setting default padx and pady controls for the grid, so that I can just call grid without having to specify any extra parameters.
You have to call grid() once on every widget, so adding **padding at the end doesn't appear too bad to me:
label = Label(master, text="Hello world!") widget.grid(row=3, col=1, **padding) What about a function: def grid_with_padding(widget, padx='1m', pady='1m', **kw): widget.grid(padx=padx, pady=pady, **kw) If you want an uniform padding: def add_padding(container, padx='1m', pady='1m'): nc, nr = container.grid_size() for i in range(nc): container.grid_columnconfigure(i, pad=padx) for i in range(nr): container.grid_rowconfigure(i, pad=pady) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list