Hi, I’m currently working on a GUI interface for PDE solver with Glk
. This Interface should be very basic and just should it make more comfortable to play around with system parameters to reach the best results ffor images. The problem I have is very elementary but unfortunately not covered by the documentation. (See code below)
For my solver I have a file called parameters.jl
which will be included at the beginning, it defines the values of e.g. x_min
. These values are used in the algorithm and to label certain text fields in the GUI via set_gtk_property(name, :label, "string")
. In order to change them, I would like to insert the new values in the text fields and they should be changed by hitting the button Start
. Now the updated values should appear as the “new labels”.
To achieve this I use the callback function on_btn_start_clicked
. The function can read out the value from the text field but it won’t set the variable e.g x_min
to the new value and the GUI won’t be refreshed with the new value (it now should display the updated value for the next run).
(I just posted the relevant pieces of my code here.)
Cheers
using Gtk
include("parameters.jl")
include("solver.jl")
win = Window("PDE Solver", 1000, 1000)
g = Grid()
#current varable values
lbl_boxlength = set_gtk_property!(lbl_boxlength, :label, string("Boxlength=" , x_max - x_min))
lbl_gridpoints = set_gtk_property!(lbl_gridpoints, :label, string("Jx=",Jx))
lbl_timestep = set_gtk_property!(lbl_timestep, :label, string("dt=",dt))
lbl_ending_time = set_gtk_property!(lbl_ending_time, :label, string("T=",T))
lbl_epsilon = set_gtk_property!(lbl_epsilon, :label, string("epsilon=",epsilon))
lbl_current = GtkLabel("current values")
lbl_system_parameters = GtkLabel("System parameters")
lbl_new = GtkLabel("insert new values")
variable_x_min = Entry()
variable_x_max = Entry()
variable_gridpoints = Entry()
variable_timestep = Entry()
variable_ending_time = Entry()
variable_epsilon = Entry()
set_gtk_property!(variable_x_min,:text,"min")
btn_start = GtkButton("Start")
# Cartesian coordinates, g[x,y]
g[3,1] = lbl_system_parameters
g[3,3] = lbl_current
g[4,3] = lbl_new
g[3,4] = lbl_boxlength
g[3,5] = lbl_gridpoints
g[3,6] = lbl_timestep
g[3,7] = lbl_ending_time
g[3,8] = lbl_epsilon
g[4,4] = variable_x_min
g[5,4] = variable_x_max
g[4,5] = variable_gridpoints
g[4,6] = variable_timestep
g[4,7] = variable_ending_time
g[4,8] = variable_epsilon
g[5,10] = btn_start
set_gtk_property!(g, :column_homogeneous, true)
set_gtk_property!(g, :column_spacing, 15) # introduce a 15-pixel gap between columns
push!(win, g)
showall(win)
function on_btn_start_clicked(widget)
str_x_min = get_gtk_property(variable_x_min,:text,String)
x_min = parse(str_x_min)
set_gtk_property!(lbl_boxlength, :label, string("Boxlength=" , x_min))
solver() #this starts the solver routine
end
My version
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = "C:\Users\Noobie\AppData\Local\atom\app-1.44.0\atom.exe" -a
JULIA_NUM_THREADS = 4