Progress bar
yakir12 opened this issue · 2 comments
yakir12 commented
It would be nice to have a progress bar. Something like this maybe:
pb = progressbar(4, widget=builder["a_GtkProgressBar_I_made_in_Glade"])
push!(pb, 2) # half way through!
yakir12 commented
Wow, that was a lot easier than I thought (copied what you did with the label
widget):
"""
progressbar(n; widget=nothing, signal=nothing)
Create a progressbar displaying the progress of a process; push to the widget new
iteration integers to update the progressbar. Optionally specify:
- the GtkProgressBar `widget` (by default, creates a new one)
- the (Reactive.jl) `signal` coupled to this progressbar (by default, creates a new signal)
"""
function progressbar(n::Int;
widget=nothing,
signal=nothing,
syncsig=true,
own=nothing)
signalin = signal
signal, value = init_wsigval(Int, signal, 0)
if own == nothing
own = signal != signalin
end
if widget == nothing
widget = GtkProgressBar()
else
setproperty!(widget, :fraction, value)
end
preserved = []
if syncsig
push!(preserved, map(signal) do val
setproperty!(widget, :fraction, val/n)
end)
end
if own
ondestroy(widget, preserved)
end
ProgressBar(signal, widget, preserved)
end
I'll wait for the datetimewidget
PR (#55, #56, #57) to clear off before I do another PR with this. Don't want to overstep my luck with git :|