Re: Tcl-URL! - weekly Tcl news and links (Jun 12)

That's really interesting. In all my years of doing Tk, I don't think I've ever wished for that feature. I'm not saying the TIP is good or bad, I'm just making an observation.

Well, I've been longing for such a feature a long time, otherwise I wouldn't have submitted the TIP :-)

I find it really annoying to have to define a name for a widget, when that name is in fact irrelevant (i.e. not used in the rest of the code). A widget is usually assigned to a variable, and only referred to by that variable. The variable often gets the same name as the widget, sometimes a slightly different name, sometimes a completely different one. This certainly doesn't improve the readability (and writability) of the code.

When the name of the variable is changed for some reason, you have the option of also changing the name of the widget, or leaving it as it is, increasing potential confusion.

I've in fact been using the patch in the TIP for about half a year now, and I wouldn't want to go back. Of course, I can only speak for myself here, but my personal observation is that I use the auto-naming feature for about 90% of the widgets.

I can see how it would be handy, though the TIP says it won't guarantee a unique name which seems very odd ("Note that there is no protection against already existing window names"). I would think it best if it worked like automatic image names where the system always picks a new, unique name.

It guarantees a unique name as long as you don't intermix "normal" and "automatic" names. Numbers are not normally used as widget names, so I don't see a problem here. If you really want to use numbers for normal names, you can still use a prefix for the automatic names:

frame .1
frame .2
frame ._%

(Of course, if really needed, the implementation could change on this point.)


Relevant Pages

  • Re: query error handling
    ... Doug Miller wrote: ... he is saying "Ah, this feature was introduced in PHP version 5.2". ...
  • Re: Tile frame widget
    ... >I was hoping to see the code needed for creating a tile frame widget ... background color (or one that changes background color depending ... on the widget state) by defining a custom style. ...
  • Re: Newby Q: Getting widgets to appear all at once.
    ... which gets a corresponding Tk widget. ... I looked around for some window manager mechanism to suppress updates ... some new GUI elements. ... What I tend to do is to create all that in a frame in the background ...
  • Re: Packing problems
    ... but the frame there are in is centered horizontally. ... pack your text widget absolutely last and you'll get better resize behavior. ... Many windows applications put both the scrollbar and text widget inside a common frame that is sunken. ... commands and then resize the window to be smaller, you'll see the effect I describe in the article where the scrollbars disappear before the text widget shrinks. ...
  • Re: Work Menu - Word:mac 2008
    ... Word developers know it's a BAD feature on whatever platform ... Certainly not because they're saying 'Well if you'd only ... individual items from the list... ... command, but there are a few points to consider here: ...