From 2819c48076180571004b52f18183f3a7d29758bc Mon Sep 17 00:00:00 2001 From: Niki Laptop <2212719@stud.hs-mannheim.de> Date: Wed, 11 Jun 2025 11:44:36 +0200 Subject: [PATCH] replace step textbox with slider --- scripts/run_simulation.jl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/run_simulation.jl b/scripts/run_simulation.jl index effc9a6..4949395 100644 --- a/scripts/run_simulation.jl +++ b/scripts/run_simulation.jl @@ -132,7 +132,17 @@ fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false) btn_step = Button(buttongrid[1, 1], width=50, label="Step") btn_start = Button(buttongrid[1, 2], width=50, label=run_label) btn_reset = Button(buttongrid[1, 3], width=50, label="Reset") -step_box = Textbox(buttongrid[1, 4], width=50, validator=Int, placeholder="Stepsize", stored_string="$(stepsize[])") +slidergrid = SliderGrid(fig[3, 1], (label="Speed", range=1:1:100, format="{}x", width=350, startvalue=stepsize[])) + +speed_slider = slidergrid.sliders[1].value +on(speed_slider) do s + try + stepsize[] = s + println("Changed stepsize to $s") + catch + @warn "Invalid input for $s" + end +end gh[1, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false) rowsize!(gh, 1, Relative(1.0)) @@ -170,15 +180,7 @@ on(running) do r run_label[] = r ? "Pause" : "Run" end -on(step_box.stored_string) do s - try - stepsize[] = parse(Int, s) - println("Changed stepsize to $s") - catch - @warn "Invalid input for $labeltxt: $s" - end -end # Button Listeners on(btn_step.clicks) do _ multi_step!((U, V), stepsize[])