Message333332
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)
``` |
|
Date |
User |
Action |
Args |
2019-01-09 16:52:00 | zach.ware | set | recipients:
+ zach.ware, terry.reedy, gpolo, serhiy.storchaka, Epyxoid |
2019-01-09 16:51:59 | zach.ware | set | messageid: <1547052719.02.0.503473948392.issue35700@roundup.psfhosted.org> |
2019-01-09 16:51:59 | zach.ware | link | issue35700 messages |
2019-01-09 16:51:58 | zach.ware | create | |
|