Hi Abe,

the idea of the wait condition is that the program would be immidiately 
closed if run in script mode (from the shell). In the REPL one usually 
wants the program to return so that the REPL is still active.

Cheers,

Tobi 

Am Dienstag, 17. Juni 2014 13:46:32 UTC+2 schrieb Abe Schneider:
>
> Thank you everyone for the fast replies!
>
> After looking at ImageView and the sources, here's the solution I came up 
> with:
>
> w = Gtk.@Window() |>
> (body=Gtk.@Box(:v) |>
>   (canvas=Gtk.@Canvas(600, 600)) |>
> showall
>
> function redraw_canvas(canvas)
>   ctx = getgc(canvas)
>   h = height(canvas)
>   w = width(canvas)
>
>   # draw background
>   rectangle(ctx, 0, 0, w, h)
>   set_source_rgb(ctx, 1, 1, 1)
>   fill(ctx)
>
>   # draw objects
>   # ...
>
>   # tell Gtk+ to redisplay
>   draw(canvas)
> end
>
> function init(canvas, delay::Float64, interval::Float64)
>   update_timer = Timer(timer -> redraw_canvas(canvas))
>   start_timer(update_timer, delay, interval)
> end
>
> update_timer = init(canvas, 2, 1)
> if !isinteractive()
>   wait(Condition())
> end
>
> stop_timer(update_timer)
>
> I haven't looked yet into what is required to do double-buffering (or if 
> it's enabled by default). I also copied the 'wait(Condition())' from the 
> docs, though it's not clear to me what the condition is (if I close the 
> window, the program is still running -- I'm assuming that means I need to 
> connect the signal for window destruction to said condition).
>
> A
>
> On Monday, June 16, 2014 9:33:42 PM UTC-4, Jameson wrote:
>>
>> I would definately use Julia's timers. See `Gtk.jl/src/cairo.jl` for an 
>> example interface to the Cairo backing to a Gtk window (used in 
>> `Winston.jl/src/gtk.jl`). If you are using this wrapper, call `draw(w)` to 
>> force a redraw immediately, or `draw(w,false)` to queue a redraw request 
>> for when Gtk is idle.
>>
>>
>> On Mon, Jun 16, 2014 at 9:12 PM, Tim Holy <[email protected]> wrote:
>>
>>> ImageView's navigation.jl contains an example. The default branch is Tk
>>> (because  as far as binary distribution goes, Tk is "solved" and Gtk 
>>> isn't
>>> yet), but it has a gtk branch you can look at.
>>>
>>> --Tim
>>>
>>> On Monday, June 16, 2014 04:01:46 PM Abe Schneider wrote:
>>> > I was looking for a way to display a simulation in Julia. Originally I 
>>> was
>>> > going to just use PyPlot, but it occurred to me it would be better to 
>>> just
>>> > use Gtk+ + Cairo to do the drawing rather than something whose main 
>>> purpose
>>> > is drawing graphs.
>>> >
>>> > So far, following the examples on the Github page, I have no problem
>>> > creating a window with a Cairo canvas. I can also display content on 
>>> the
>>> > canvas fairly easily (which speaks volumes on the awesomeness of Julia 
>>> and
>>> > the Gtk+ library). However, after looking through the code and samples,
>>> > it's not obvious to me how to redraw the canvas every fraction of a 
>>> second
>>> > to display new content.
>>> >
>>> > I did find an example of animating with Cairo and Gtk+ in C
>>> > (http://cairographics.org/threaded_animation_with_cairo/). However, I
>>> > assume one would want to use Julia's timers instead of of GLibs? 
>>> Secondly,
>>> > there in their function 'timer_exe', call is made directly to Gtk+ to 
>>> send
>>> > a redraw queue to the window. Is there a cleaner way to do it with the 
>>> Gtk+
>>> > library?
>>> >
>>> > Thanks!
>>> > A
>>>
>>>
>>

Reply via email to