Aug 10, 2003 Common problems in the path of Tk beginners: * You design the default size and position of your app very carefully. It always starts with the same size. And at the very same spot on your screen. You provide an ideal amount of space between any two individual widgets. The whole set looks perfect. But all is lost in a different screen resolution. * You make a text widget in your app. After some time (minutes or days), you maximize the app for the first time. The app is maximized, but the text widget and everything else keep the same size and is now surrounded by a lot of gray empty space. In HTML, the use of percentage measures is very common and trivial. In Tk, use grid to do the same thing. E.g., to maintain a 10:90 ratio between two columns, try the following: entry .s -width 1 entry .t -width 9 grid .s .t -sticky ew grid columnconf . 0 -weight 10 grid columnconf . 1 -weight 90 wm geometry . 600x20 The widths on the entry widgets become minimum widths, but more importantly, they establish the initial ratio. The weights on the columns maintain the ratio through resizing. The geometry command sets the initial size. Rather than hard-coding initial size, you could use "winfo screenwidth" to base it on the screen width or "font measure" to base it on the number of columns of text to display by default. ---- Using pack or place geometry managers, you would have to calculate and generate the right sizes and proportions yourself. That may not be a lot of fun. You'll spend quite some time working with the dreaded [expr] command, and probably also many levels of nested brackets... ---- [jmn] 2003-08-10 As a Tk beginner, I find all my admittedly modest GUI resizing requirements admirably handled by the pack layout manager and the -expand option. Whilst sometimes it's easy to make a mistake and get the dreaded empty grey space attack when resizing - it only takes a little playing about with the pack options to sort it out. I'm not sure exactly what you're trying to achieve with the resizing that can't be simply handled by pack; perhaps you have more stringent requirements than I with respect to exact widget proportions, but it seems to me that the text above is a touch too negative about the situation for Tk beginners. ---- Suppose you make a notification window which, ideally, should be displayed at 20% the width of the screen and 10% the height (or something like that). You can't use absolute values and expect to get that same position in another screen resolution. You'll have to rely on percentages. Also suppose you design at 800x600 and a text or entry widget looks just fine. Used by someone with higher resolutions, these widgets may look wiiiiiiiide, or looooooooong or aaaaaaaample... OK, designers don't design at 800x600. They like to boast at least 1280x1024. So the opposite is a lot more likely to happen: the app looks fine on your screen, but a user with a lower resolution, like 800x600, is likely to see everything bloated and crammed. Many people have no problem just giving a big shrug to that. I find it terribly sloppy. I have that problem with Web pages very frequently. I inspect the source code and see that many designers use absolute values in tables! Golly, why?!! Why does HTML have percentage values anyway? Is it the designer's job to use the available tools to make their work look as good as possible in every screen or simply tell the user "get a larger screen"? Although Tk doesn't have percentage values unless we calculate them and apply them in the code, maybe their use should be regarded as a very well recommended practice. I guess. ---- [US] It's not so that '''Tk''' doesn't have percentage values, just '''pack''' doesn't have them. Use '''grid''' and the commands '''grid rowconfigure''' and '''grid columnconfigure''' provide a '''-weight''' option. ----