JuliaGizmos/GtkReactive.jl

Simple question

evcastelani opened this issue · 2 comments

I was trying to make a simple implementation and I came across a doubt. Consider the following two codes.

Code 1.

using Gtk.ShortNames, GtkReactive
win=Window("My first project using GtkReactive")
bx=Box(:v);
push!(win,bx);
btn=button("Click Here");
push!(bx,btn);
text_out=textarea("1");
push!(bx,text_out);
i=Signal(1)
map(signal(btn)) do _
push!(text_out,string(value(i)))
push!(i,value(i)+1)
end
showall(win);


Code 2
using Gtk.ShortNames, GtkReactive
win=Window("My first project using GtkReactive")
bx=Box(:v);
push!(win,bx);
btn=button("Click Here");
push!(bx,btn);
text_out=textarea("1");
push!(bx,text_out);
i=1
map(signal(btn)) do _
push!(text_out,string(i))
i=i+1
end
showall(win);


The code 1 works fine. The code 2 has an error about definition of i. So, my question is: Any variable in map block must be a signal?

PS. Sorry about my english.

This is actually a Julia variable scope question: there's a distinction between "reading" and "writing" in terms of whether the variable is inherited from the containing scope. Just put global i inside the do-block.

And your English is very clear!

Please close the issue if you're satisfied.

Ok, I get it. Congratulations for the great work!