Hi,
I’m playing around with Tkinter and don’t understand why I get an error, when
I want to replace a text. The test program should start a new measurement,
but something goes wrong, when the “Repeat”-Button is clicked. The code
I’m playing with it.
using Base.Threads, Tk
l=ReentrantLock()
cn1=Channel{Any}(1)
val1=Atomic{Float64}(0)
val2=Atomic{Float64}(0)
function mt_func()
lock(l)
try
@threads for i = 1:10^6
atomic_add!(val1,1.924)
end
put!(cn1,val1[])
atomic_cas!(val2,val2[],0.5val1[])
atomic_xchg!(val1,fetch(cn1)^0.5)
finally
unlock(l)
end
return take!(cn1),val2[], val1[]
end
function mt_rep(path)
set_value(Info1, "Bla, bla, bla")
end
function prog_end(path)
destroy(w)
end
function main()
global w=Toplevel("Systemtest",1048,570)
pack_stop_propagate(w)
mFr=Frame(w, padding=[5,5,5,5], relief="groove")
pack(mFr,expand=true,fill="both")
grid(Label(mFr,"Info"), 1,1, sticky="nw", pady=5)
Info1=Text(mFr, width=128, height=30, padx=5, relief="flat")
grid(Info1,2,1, sticky="w")
Button1=Button(mFr,"Repeat")
grid(Button1,3,1, sticky="ws", padx=15, pady=15)
bind(Button1, "command", mt_rep)
Button2=Button(mFr,"Quit")
grid(Button2,3,1, sticky="es", padx=15, pady=15)
bind(Button2, "command", prog_end)
et=@elapsed mw,hw,qw=mt_func()
itxt="""
Elapsed time: $et seconds
Threads: $(Sys.CPU_THREADS)
val1[]: $mw
val2[]: $hw
sqrt val1[]: $qw
\n$(Sys.cpu_info())"""
set_value(Info1, "$itxt")
end
main();
The function that produces the error is mt_rep, no matter what it says.
Any hints?
Thank You
btw.
Sorry for my english, I’m no native speaker.