[Tkinter-discuss] What do you feel is missing from Tkinter?

Michael Lange klappnase at web.de
Sun Dec 19 16:58:51 CET 2010


Hi,

Thus spoketh python at bdurham.com 
unto us on Sat, 18 Dec 2010 09:26:43 -0500:

> This post was inspired by Craf's recent post on "Tkinter in everyday
> life".
> 
> I'm a recent and enthusiastic convert to Tkinter after having rejected
> this toolkit for many years.
> 
> After digging into Tkinter and through the very generous help on this
> mailing list and elsewhere (stackoverflow.com), I've found that most
> things that I thought Tkinter couldn't do are actually very doable.
> Perhaps if we share our Tkinter concerns and doubts, we can all
> brainstorm ways to fill in missing pieces.
> 
> Here's my short list of Tkinter weaknesses that I've struggled with:
> 
> 1. Drag and drop. In fairness, there's a Tkdnd library and a bunch of
> sample code on the internet. I haven't studied the examples I've
> collected enough to figure out a simple, reusable way to do this. (Most
> of my use cases are simply finding a way for users to re-arrange a row
> of widgets packed or grided into a container)

I agree with this; as Kevin Walzer already pointed out, the Tkdnd module
is nice for DnD within your application, but for "real" DnD you need
George Petasis tkdnd library, which unforunately supports only drops on
unix. In fact there used to be an earlier version of this tkdnd library,
where drag *and* drop worked on unix, which unfortunately is not being
maintained any longer.

> 
> 2. Ability to dynamically stretch and image in real-time. What I would
> like to do is create widgets with a gradient background where the
> background image stretches as the widget itself is resized.
> 
> 3. Creating scrolling containers (I've been spoiled with Tkinter's
> automatic layouts and don't look forward to manually placing widgets).

If you don't need a themed one, you can use the Pmw.ScrolledFrame or the
Tix.ScrolledWidget, which is included in the standard library and even
easier to use than its Pmw counterpart (we've had this topic earlier here,
I admit that I totally forgot about Tix :), see this small example:

from Tix import *
r = Tk()
r.geometry('800x400')
sw = ScrolledWindow(r)
sw.pack(fill='both', expand=1)
for x in range(30):
    for y in range(20):
        Entry(sw.subwidget('window'), bd=0, highlightthickness=1,
                highlightbackground='gray50').grid(row=x, column=y)
r.mainloop()

I agree with you though, that it would be nice to have scrolled widgets
within standard Tk.

A few other things I miss from Tkinter:

* support for image formats other than gif
* text rotation

The Tk-8.6 beta release however adds a -rotate option to the canvas text
item and support for png images, so these issues will be resolved soon :)

* built-in tooltips were also nice, I'd love to be able to do
  Button(master, text='foo', tooltip='bar'...)
* a decent html widget
* on unix some dialogs (file dialog, color chooser...) could be improved

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

A Vulcan can no sooner be disloyal than he can exist without breathing.
		-- Kirk, "The Menagerie", stardate 3012.4


More information about the Tkinter-discuss mailing list