From: SourceForge.net <no...@so...> - 2008-03-03 13:26:35
|
Bugs item #1905656, was opened at 2008-03-02 04:07 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1905656&group_id=12997 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 18. [text] Group: None Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Holger Ewert (ewerth) Assigned to: Joe English (jenglish) Summary: Asking the width of a textwidget don't work like expected. Initial Comment: The following code returns allways the same value (80) for '.t cget -width' even after resizing the window: text .t pack .t -fill both -expand 1 update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 .t insert end [string repeat a 200] update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 # resize window with mouse update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 wm geometry . 1000x500 update wm geometry . ;# returns 1000x500 .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 On the other side: Modifying the width with -width works: text .t pack .t -fill both -expand 1 update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 .t insert end [string repeat a 200] update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 .t configure -width 120 update wm geometry . ;# returns 964x388 ... .t cget -width ;# returns 120 .t configure -width ;# returns -width width Width 80 120 .t configure -width 80 update wm geometry . ;# returns 644x388 ... .t cget -width ;# returns 80 .t configure -width ;# returns -width width Width 80 80 I tried this with ActiveTcl 8.5.1.0, ETcl 1.0-rc25 und Etcl 1.0-rc23. This means this happens on Tcl 8.4 and 8.5. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2008-03-03 05:26 Message: Logged In: NO The thing with the "desired width" is something strange. Everytime we use "configure option value" the value is an desired value. If the widget uses this value it becomes the actual value. Changing the textwidget size with the mouse should like using "configure -width width". In both situations we ask the textwidget to change his width. And in both situations I expect that "cget -width" returns the actual value. If we say there is a different between this two situations, this means the textwidget should never change its size, when user tries to change it with the mouse. Because the programmer has desired the -width and there is no reason not to use the value. In fact we have at least an unclear documentation. ---------------------------------------------------------------------- Comment By: Joe English (jenglish) Date: 2008-03-02 21:53 Message: Logged In: YES user_id=68433 Originator: NO The -width option specifies the application's desired width in characters, not the actual width of the widget. The widget uses this value (and the -font, and other options) to request a width in pixels to its geometry manager. (Use [winfo reqwidth] to see the widget's requested width). The actual width is determined by the geometry manager once geometry propagation completes. [winfo width] returns the actual width in pixels of the widget. The widget may end up larger or smaller than [winfo reqwidth], e.g., if the user resizes the window. This does not change the value of the '-width' option. IOW: this is behaving as expected. (Most Tk widgets with -width and -height options work this way - the options specify a desired size, they don't reflect the actual size.) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=1905656&group_id=12997 |