Re: STk: Selection of menu item has no effect

From: Erick Gallesio <eg_at_essi.fr>
Date: Tue, 19 Mar 2002 13:59:52 +0100

On Thu, 14 Mar 2002 16:04:33 +0100 (MET)
Guenther Goerz <goerz_at_informatik.uni-erlangen.de> wrote:

> Dear Erick, dear STkers,
>
> a while ago one of our students wrote a program for Paul Lorenzen's
> dialogue logic as part of his diploma (master's) thesis. Although
> there is a line mode which should run in any Scheme system, he
> implemented a nice graphical interface with STk. With recent STk
> versions (the latest one for Windows as well as that for Linux, which
> I downloaded from your site) the following problem came up:
>
> In the program's main window there is a menu bar. Selecting one of
> its items, a pop-up submenu comes up in which several items can be
> selected. The effect of such a selection is that the value of a
> variable should be set from #f (the default value) to #t which in turn
> should cause the appearance of another window. What happens is that
> the value(s) of the resp. variables are not affected by selecting the
> corresponding menu item (which used to work before). This can easily
> be verifed by asking for the value in the main STk window after
> clicking the corresponding menu item. However, if I set the value in
> the main STk window, everything works as it should do.
>
>From what I understand you have an environment problem. In "recent"
versions (since 4.0 probably), you can associate an environment with
a checkbutton. The following example will make things clearer:

    STk> (define env (let ((x 1)) (the-environment))) ; a local x
    env
    STk> (define x 0) ; a global one
    x
    STk> (menu '.foo)
    #[Tk-command .foo]
    STk> (.foo 'add 'check :label "test" :variable 'x :environment env)
    ()
    STk> (.foo 'post 10 10)
    ()
If you try to click on the menu, you'll see that the global in
untouched, but this is in fact the on in the let which is modified.
To be convinced of that you can do:
    STk> (car (environment->list env))
    ((x . #t))
and try to click on the menu and you'll see
    STk> (car (environment->list env))
    ((x . #f))

So, I suppose that for some reason, you don't capture the global
variable in your code but a local one (by some way, I don' know).
Perhaps, you can try to specify the global environment in your
menu. Something like:
    STk> (.foo 'add 'check :label "test2" :variable 'x :environment
         (global-environment))
    ()

Tell me if it works.

>
> ->> By the way: Is there no way to remove all the junk and spam from
> ->> the mail archive?
>

Oops I should do something for that! I put it on my TODO list.

-- 
Erick
Received on Tue Mar 19 2002 - 14:11:06 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST