From: Arjan on 3 Feb 2010 09:48 Hi! I have progress, and still some challenges... Below, you'll find an example piece of code demonstrating my problems. It is a simple gui for specification of an option for using meteo-data from a given file, which may contain wind at 1 or at 2 heights. Problem 1: How can I join columns 2 and 3 of row 2 into column 2? There is room enough. The combo-box should have a label included in column 2, but it demands a third column, making the gui unnecessarily wide. Problem 2: On row 3 and 4: The height of the wind levels should be lined-out to the right, as is the case, but the label behind it, specifying the unit [m] should follow immediately and not after an inch of empty space. I have played around with -anchor, -sticky and -just, but I don't seem to be able to get it right. How can I get the desired alignment? Problem3: The possibilities to enter a filename and to specify number of levels and their values, should only be enabled if the user has selected the option to use manual meteo records. Otherwise, the rest makes no sense and consequently should remain disabled. How can I do that? Moreover: the second wind-height should only be enabled if the number of levels equals 2... Thanks! Arjan package require Tk # # Define sets # set nlevels_classes { 1 2 } # # Set defaults # set option_manmet + set manmetfile manmet.dat set nlevels 1 set z1 10 set z2 300 # # Define the global layout of the grid # grid [::ttk::labelframe .meteo -text "Meteo"] -sticky news # # Define line 1 in gui: selector if user wants manual meteo records from file: # set mymanmetbutton [checkbutton .meteo.option_manmet -variable option_manmet \ -onvalue - -offvalue + -anchor w -text "Use meteo records from file"] set mymanmetfilevariable [entry .meteo.mymanmetfile -textvariable manmetfile] grid $mymanmetbutton $mymanmetfilevariable -sticky w # # Define line 2 in gui: number of wind-levels in that file: 1 or 2 # set mylabel [label .meteo.nlevels_label1 -text "with wind at"] ::ttk::combobox .meteo.nlevels -textvariable nlevels -values $nlevels_classes -width 3 label .meteo.nlevels_label2 -text "levels:" -anchor w grid $mylabel .meteo.nlevels .meteo.nlevels_label2 -sticky e # # Define line 3 in gui: height of first wind-level # set myz1variable [entry .meteo.myz1 -textvariable z1 -width 6 -just right] label .meteo.z1_label -text "m" -anchor w grid $myz1variable .meteo.z1_label -sticky e # # Define line 4 in gui: height of second wind-level # set myz2variable [entry .meteo.myz2 -textvariable z2 -width 6 -just right] label .meteo.z2_label -text "m" -anchor w grid $myz2variable .meteo.z2_label -sticky e
From: Arjan on 3 Feb 2010 10:09 Hmm. Some lines are wrapped... This happened at the end of lines 47, 40, 33, 26, 24, 19. Sorry!
From: Ralf Fassel on 3 Feb 2010 11:40 * Arjan <arjan.van.dijk(a)rivm.nl> | Problem 1: --<snip-snip>-- | Problem 2: --<snip-snip>-- | Problem3: + = add line - = remove line # # Define line 1 in gui: selector if user wants manual meteo records from file: # +set row 0 set mymanmetbutton [checkbutton .meteo.option_manmet -variable option_manmet \ -onvalue - -offvalue + -anchor w -text "Use meteo records from file"] set mymanmetfilevariable [entry .meteo.mymanmetfile -textvariable manmetfile] -grid $mymanmetbutton $mymanmetfilevariable -sticky w +grid $mymanmetbutton $mymanmetfilevariable - -sticky w # # Define line 2 in gui: number of wind-levels in that file: 1 or 2 # +incr row set mylabel [label .meteo.nlevels_label1 -text "with wind at"] ::ttk::combobox .meteo.nlevels -textvariable nlevels -values $nlevels_classes -width 3 label .meteo.nlevels_label2 -text "levels:" -anchor w -grid $mylabel .meteo.nlevels .meteo.nlevels_label2 -sticky e +grid $mylabel -sticky e -row $row -column 0 +grid .meteo.nlevels -sticky ew -row $row -column 1 +grid .meteo.nlevels_label2 -sticky w -row $row -column 2 # # Define line 3 in gui: height of first wind-level # +incr row set myz1variable [entry .meteo.myz1 -textvariable z1 -width 6 -just right] label .meteo.z1_label -text "m" -anchor w -grid $myz1variable .meteo.z1_label -sticky e +grid $myz1variable -sticky e -row $row -column 0 +grid .meteo.z1_label -sticky w -row $row -column 1 # # Define line 4 in gui: height of second wind-level # +incr row set myz2variable [entry .meteo.myz2 -textvariable z2 -width 6 -just right] label .meteo.z2_label -text "m" -anchor w -grid $myz2variable .meteo.z2_label -sticky e +grid $myz2variable -sticky e -row 3 -column 0 +grid .meteo.z2_label -sticky w -row 3 -column 1 HTH R'
From: tom.rmadilo on 3 Feb 2010 12:13 On Feb 3, 7:09 am, Arjan <arjan.van.d...(a)rivm.nl> wrote: > Hmm. Some lines are wrapped... > This happened at the end of lines 47, 40, 33, 26, 24, 19. > Sorry! Can't you use the -command option to do anything you wish? Also, when possible move to using ttk and apply styles to your widgets. Then the command can disable/enable the state (among other things): ..mywidget configure -state disabled ..mywidget configure -state normal proc ::my::buttonProc { value } { variable buttonVar set buttonVar $value if {$value} { .mywidget configure -state normal } else { .mywidget configure -state disabled } } ..mybutton.1 configure -command {::my::buttonProc 1} ..mybutton.2 configure -command {::my::buttonProc 2} ..mybutton.clear configure -command {::my::buttonProc 0}
From: Arjan on 3 Feb 2010 15:02 On 3 feb, 17:40, Ralf Fassel <ralf...(a)gmx.de> wrote: > HTH > R' This seems to work, Ralf! Thanks! @tom: thanks for the suggestion. I haven't tried it yet. Will do so after I cleared up the lay-out stuff. Arjan
|
Next
|
Last
Pages: 1 2 Prev: How disable a collection of stuff in 1 go? Next: Hello world and expectk |