Gtk.jl
Gtk.jl copied to clipboard
Please add an example how to use a checkbox
Using checkboxes is neither documented in the help, nor is there an example how to do that available. Please, add a simple example for a dialog with checkboxes without using Glade.
The following code works:
using Gtk.ShortNames, GtkObservables
# define the default values
OPTION_A = false
OPTION_B = false
finished = false
cb1 = checkbox(OPTION_A, label="Option A")
cb2 = checkbox(OPTION_B, label="Option B")
btnOK = button(label="OK")
win = Window("Dialog", 200, 72) |> (bx = Box(:v))
push!(bx, cb1)
push!(bx, cb2)
push!(bx, btnOK)
function on_button_clicked(win)
global OPTION_A, OPTION_B, finished, win
OPTION_A = observable(cb1)[]
OPTION_B = observable(cb2)[]
destroy(win)
finished = true
end
signal_connect(on_button_clicked, widget(btnOK), "clicked")
Gtk.showall(win)
while ! finished
sleep(0.1)
end
println("Option A: $OPTION_A")
println("Option B: $OPTION_B")
nothing
But it depends on GtkObservables and is not using a modal Gtk Dialog. I would be glad if someone comes up with a better solution.
In the test dir there is the file gui.jl, which should bei more complete than the docs. There is an example on CheckButton.
Thanks for pointing to the file gui.jl ! Nevertheless more examples would be useful.