0
votes

I'm trying to use Julia with GTK and Cairo to draw onto a canvas. I think the following code (adapted from the example fragments on the GTK.jl page) should work, but it does not. (Other GTK widgets work, but not the canvas)

I would appreciate if someone can suggest what is wrong with this code, or give a pointer to a complete example.

using Gtk.ShortNames
using Cairo

function drawfn(w)
    ctx = Gtk.getgc(w)
    Cairo.set_coords(ctx, 0, 0, 800, 600, 0, 800, 0, 600)
    h = Gtk.height(w)
    w = Gtk.width(w)

    Gtk.rectangle(ctx, 0, 0, w/2, h/2)
    Gtk.set_source_rgb(ctx, 0, 0, 1)
    Gtk.fill(ctx)
end


function main()

    win = Gtk.@Window("stuff", 800,600)
    c = Gtk.@Canvas()
    Gtk.push!(win,c)

    Gtk.draw(drawfn, c)
    Gtk.showall(win)

end

main()
1
What error are you getting? In what way is it not working?Alex A.
The window appears with a solid gray background. No drawing commands (e.g. rectangle) work. There is no error message. This suggests the possibility that I need to somehow enable the visibility of the canvas, but I've tried various methods of doing that with no luck.Robert Hooke

1 Answers

1
votes

I think this was a bug in version 0.8.1 of Gtk.jl. I posted an issue to github after which vtjnash fixed it immediately and tagged version 0.8.2.