Home > Archive > Tcl > May 2006 > Re: can menu or a menubutton have a command associated with it ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: can menu or a menubutton have a command associated with it ?
|
|
| maura.monville@gmail.com 2006-05-26, 10:03 pm |
| Actually I stared out with the simple syntax that you suggest:
if ([catch {check_hist_aint_option} results != 0} {
$base.button_aint configure -state disabled
} else {
$base.button_aint configure -state normal
}
Thesn, as you pointed out, I tried many different desperate naive
variations that increased my level of confusion.
The reason why I did that is because the simple syntax you suggested
causes no message error but what appears on the screen is a tiny (sort
of iconified) window in place of the GUI pannel ...
but the GUI survives .. it's just sort of crippled ....
Here is the proc I changed. Without these changes it works. I mean it
does not work in the elegant way I'd like it to but it's not crippled
....
........ and you all want to persuade me to turn my back to C, C++ for
Tcl/Tk ... Oh my God !
Maura
...............................................................................................................................................
proc pick_hist {} {
global plot
global hist_info
global base
set idx [$hist_info(list) curselection]
if { $idx != "" } {
if { $hist_info(id,$idx) != $hist_info(hid) } {
set hist_info(hid) $hist_info(id,$idx)
set hist_info(binmin) -99
set hist_info(binmax) -99
}
read_hist $hist_info(hid)
set_hist_active $hist_info(hid) 1
set plot(histlbl) ON
append plot(histlbl) ( $hist_info(hid) )
set hist_info(min) [get_hist_min]
set hist_info(max) [get_hist_max]
set plot(mode) 1
draw_canvas 0
if ([catch {check_hist_aint_option} results != 0} {
$base.button_aint configure -state disabled
} else {
$base.button_aint configure -state normal
}
puts "\n HISTOGRAM DRAWN ! "
}
| |
| Donald Arseneau 2006-05-27, 4:14 am |
| "maura.monville@gmail.com" <maura.monville@gmail.com> writes:
> Actually I stared out with the simple syntax that you suggest:
>
> if ([catch {check_hist_aint_option} results != 0} {
That has a syntax error -- mismatched "["
Does the command check_hist_aint_option fail with an error when
there is no AINT histogram? That is when you would use [catch { }].
I would have thought it would just return a boolean value (0 or 1)
as its result.
> Thesn, as you pointed out, I tried many different desperate naive
> variations
That is always a terrible way to proceed. (In any programming language
and in life.)
> set idx [$hist_info(list) curselection]
That could be an error -- It is OK if $hist_info(list) is the name
of a listbox widget (more exactly, if array hist_info has an element
"list" which is the name of a command that takes "curselection" as
an argument).
> if ([catch {check_hist_aint_option} results != 0} {
And, as mentioned, the missing "]; perhaps also a misuse of [catch].
> ....... and you all want to persuade me to turn my back to C, C++ for
> Tcl/Tk ... Oh my God !
Stop panicking! Do you go running to the C support groups every time
you miss a bracket or misspell a variable name? How can you find the
C compiler error for a missing ";" more intelligible than the Tcl
interpreter's error messages? You are panicking, trying random variations
instead of reading your code carefully and reading the Tcl man pages.
There was a post a while back that got to me, and maybe I should answer it.
--
Donald Arseneau asnd@triumf.ca
|
|
|
|
|