Message 333332 - Python tracker

Message333332

Author zach.ware
Recipients Epyxoid, gpolo, serhiy.storchaka, terry.reedy, zach.ware
Date 2019-01-09.16:51:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547052719.02.0.503473948392.issue35700@roundup.psfhosted.org>
In-reply-to
Content
I agree with Serhiy that we shouldn't do this; tkinter is (mostly) just a thin wrapper around Tcl/Tk and this isn't enough of a win to deviate from that.  In any case, this would be an enhancement that could only go into 3.8 at this point.

For your particular example, it would prefer to read the following anyway:

```
import tkinter as tk

root = tk.Tk()

labels = []
for i in range(3):
    label = tk.Label(root)
    label.grid(row=0, column=i)
    labels.append(label)
```


Or if you really want this feature in your own code, try this out:

```
import tkinter as tk
from functools import partial

def _mapped(method, widget, *args, **kwargs):
    getattr(widget, method)(*args, **kwargs)
    return widget

packed = partial(_mapped, 'pack')
gridded = partial(_mapped, 'grid')
placed = partial(_mapped, 'place')

root = tk.Tk()

label1 = gridded(tk.Label(root), row=0, column=0)
label2 = gridded(tk.Label(root), row=0, column=1)
label3 = gridded(tk.Label(root), row=0, column=2)
```
History
Date User Action Args
2019-01-09 16:52:00zach.waresetrecipients: + zach.ware, terry.reedy, gpolo, serhiy.storchaka, Epyxoid
2019-01-09 16:51:59zach.waresetmessageid: <1547052719.02.0.503473948392.issue35700@roundup.psfhosted.org>
2019-01-09 16:51:59zach.warelinkissue35700 messages
2019-01-09 16:51:58zach.warecreate