http://www.perlmonks.org?node_id=542158


in reply to Re: k-Means Clustering demo program with Tk
in thread k-Means Clustering demo program with Tk

The labels? Ah yes, the cause must be the difference in default font size.

But your entry text box, for the number of clusters, now looks very big, doesn't it? And you resorted to use a fixed width for the coordinates, 3 digits per coordinate, or else the widgets would jump to the left and to the right.

I really really dispise layout managers, Java's AWT is another one like that.

Replies are listed 'Best First'.
Re^3: k-Means Clustering demo program with Tk
by zentara (Archbishop) on Apr 09, 2006 at 19:04 UTC
    Well I just made the minimal changes to make packing work. The way you would normally do it, is pack sub-frames into frames. So I just packed the widgets to side=>left with some padding. But a better way, would be to make separate little frames, one for each label and entry combo ( or whatever), assign them default widths, and pack the frames into the frames. It's more work than I cared to do on a Sunday morning, :-) but that is how you usually do it. The trick with frame packing is to remember that the frame gets it's size from the widgets it contains, so if you want to maintain a frame's width, you must set a widget in it with a -width=>$somemin.

    The sprintf on the digits was the easiest way out, but you could have set them in there own frame, set an alignment on the label packing, and give a -width to the label, to hold it steady.

    Of course in a GUI app, half your time is spent making it appear and resize correctly, and pack makes that easier in the long run.


    I'm not really a human, but I play one on earth. flash japh