I can draw on canvases (created via
Gtk.Canvas) which are are then pushed onto containers, and have their draw functions set to functions I have written (eg.
canvasA.draw = drawFnA) and in that draw function use the some alteration from the examples for drawing.
Using the Gtkbuilder I can import glade layouts to produce windows and in the tool options for a panel to draw or place images I see there are ‘images’ and ‘drawing areas’. It appears that ‘images’ would be the most flexible and the XML output from glade is:
<object class="GtkImage" id="imageOne">
How can I reference this object class to then define the methods that will be called by either Gtk or myself explicitly in order to draw images, or place images upon that area?
I tried using an example from
https://github.com/tknopp/Winston.jl/blob/master/src/gtk.jl, where there is the macro usage
c = Gtk.@Canvas() but does not compile as it has ‘too few arguments’.
In general I am struggling to see how I can translate the Gtk documentation into Julia code that I can utilize. (gtk on images
I wish i could help. I just wanted to say that I’m also interested in the answer to your question, and hoping someone can help.
I’m also very interested in seeing your canvas code, if it’s possible for you to share it.
I’m just getting started with it and having problems just figuring out how to get it to be created properly in glade using some sort of container.
(obviously i 'm very new to Gtk).
The macros for widget creation have been deprecated in Gtk.jl - so most likely you need a different call to create a Canvas.
The examples that use getgc have some problems in general Gtk usage, as Gtk.jl actually replaces the ‘plain’ GtkCanvas with julia code that does own logic for keeping a background cairo surface bitmap and redraws from that to the widget on screen. The getgc afaiu is only defined for that setup. I have somehwere an example to use a ‘plain’ canvas and use the cairo context it provides.
In this thread
https://discourse.julialang.org/t/resetting-the-canvas-within-cairo-jl-and-gtk-jl-for-an-image-selection-viewing-gui/24251 there is the key material for the painting on the canvas, but not on an object defined in glade. Tell me if you’d like more info on how I used it.
getgc() can be used in the drawing function for the function that handles the drawing of a specified
canvas of Gtk. My specific question relates to capturing the drawing canvas for the object produced in GLADE so that the layout does not have to be completely defined manually. GLADE appears to describe objects of drawing areas and images; and I cannot see how Gtk.jl can capture that object (Widget) to draw on it.
I am wondering if a work around is to create a canvas that gets pushed onto a container defined in GLADE and then draw onto that…
https://github.com/JuliaGraphics/Gtk.jl/issues/423 in the issues section of
Gtk.jl which describes a similar situation and also a similar workaround)
Yes, the approach of pushing new Widgets onto the boxes does work
build = GtkBuilder(filename="try1.glade")
vBox1 = build["vBox1"]
canvas1 = Gtk.Canvas(500,700)
canvas1.draw = draw1
not a well curated example but the point is that the build array can address the containers which can then have new widgets pushed to it and those will show even if not originally present in the
XML file produce by GLADE