Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example checkbox.jl #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/checkbox.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This example creates a modal dialog with two checkboxes.

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