Thank you for the suggestion. I agree that the ‘simplest’ way is DIY.
I cooked up below code to get started. It displayed a window on screen. The top left
canvas is supposed to be painted with light gray color. THE REPL prints out “canvas name= 1” as expected. (Later, each canvas’ drawing will depend on the name.)
BUT no drawing occurred in this case. I must have missed something ?
Btw, do you know of any example usage of EventBox that you suggested ?
Thanks, HP
using Gtk
function mydraw(widget)
ctx = Gtk.getgc(widget)
println("canvas name= ", get_gtk_property(widget, :name, AbstractString))
# background color
set_source_rgb(ctx,0.8,0.8,0.8); # light gray
rectangle(ctx,0.0,0.0,100.0,100.0); # background
fill(ctx)
end
win = GtkWindow(“A new window”, 200, 200)
g = GtkGrid()
a = GtkCanvas()
set_gtk_property!(a, :name, “1”)
a.draw = mydraw
b = GtkCanvas()
set_gtk_property!(b, :name, “2”)
c = GtkCanvas()
set_gtk_property!(c, :name, “3”)
d = GtkCanvas()
set_gtk_property!(d, :name, “4”)
g[1,1] = a
g[2,1] = b
g[1,2] = c
g[2,2] = d
set_gtk_property!(g, :column_homogeneous, true)
set_gtk_property!(g, :column_spacing, 0)
set_gtk_property!(g, :row_spacing, 0)
push!(win, g)
draw(a)
showall(win)