Simple windowed application: Difference between revisions

Content added Content deleted
No edit summary
Line 1,237: Line 1,237:
using Gtk.ShortNames
using Gtk.ShortNames


"""
gtkwait
Keeps the application visible and running until dismissed.
"""
function gtkwait(window)
if !isinteractive()
c = Condition()
endit(w) = notify(c)
signal_connect(endit, window, :destroy)
end
wait(c)
end


"""
clickwindow
A simple window test.
"""
function clickwindow()
function clickwindow()
clicks = 0
clicks = 0
win = Window("Click Counter", 300, 100) |> ((frm = Frame())|> (vbox = Box(:v)))
txt = "There have been no clicks yet."
win = Window("Click Counter", 300, 100) |> (frm = Frame())
lab = Label("There have been no clicks yet.")
vbox = Box(:v)
push!(frm, vbox)
lab = Label(txt)
push!(vbox, lab)
but = Button("click me")
but = Button("click me")
push!(vbox, lab)
push!(vbox, but)
push!(vbox, but)
setproperty!(vbox, :expand, lab, true)
setproperty!(vbox, :expand, lab, true)
Line 1,268: Line 1,249:
callback(w) = (clicks += 1; setproperty!(lab, :label, "There have been $clicks button clicks."))
callback(w) = (clicks += 1; setproperty!(lab, :label, "There have been $clicks button clicks."))
id = signal_connect(callback, but, "clicked")
id = signal_connect(callback, but, "clicked")
c = Condition()
endit(w) = notify(c)
signal_connect(endit, win, :destroy)
showall(win)
showall(win)
gtkwait(win)
wait(c)
end
end