Question

Is there a limit on the length or nesting of Tcl/Tk widget pathnames?

For example:

ttk::button .a.b.c -text "Hello World"
pack .a.b.c

creates button .a.b.c inside container .a.b which is inside .a, etc. Is there a limit to the identifier names and nesting level? For example if i rewrote it thus:

ttk::button .extralonga.extralongb.extralongc -text "Hello World"
pack .extralonga.extralongb.extralongc

How long can i go before hitting problems?

Was it helpful?

Solution

Tk itself imposes no such limits at all (though you could have problems if you end up using very large amounts of memory).

The underlying graphics layer might impose limits, I suppose, but I've never encountered them. (Note that from the perspective of that layer, it is only the path within a toplevel that counts.) I guess it's more likely that you'll create an unworkable mess and impractical GUI long before you hit any limits that exist; I tend to try to keep the level of nesting fairly small; using grid rather than pack helps in this, as does making interaction widgets direct children of the toplevel and using the -in option to the geometry managers to set things up right. In fact, I think the only thing that must be correct in terms of parent/child relationships with widgets is where you need the clipping; in Tk, children are clipped by their parents. (This matters if you're using a text or canvas to do different types of scrollable areas, or — IIRC — when using ttk::notebook to overlay several widgets on the one area.)

Summary: Worry about other problems first, OK?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top