Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

Draw on a Canvas using GtkBuilder ?

Open gsoleilhac opened this issue 6 years ago • 2 comments

Is there an example showing how to draw on a canvas if the canvas has been generated using Glade ?

The docs show how to draw with a GtkCanvas but I only get a GtkDrawingAreaLeaf from the Builder, and I dont know what to do with it or if I can convert it to a GtkCanvas.

b = GtkBuilder(filename=."___.glade"))
drawingArea = b["drawingarea1"]

typeof(drawingArea) # => Gtk.GtkDrawingAreaLeaf
typeof(@GtkCanvas()) # => Gtk.GtkCanvas

relevant snippet of my .glade file :

<child>
  <object class="GtkDrawingArea" id="drawingarea1">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
  </object>
  <packing>
    <property name="resize">False</property>
    <property name="shrink">True</property>
  </packing>
</child>

Edit: Fixed by leaving an empty container where I wanted my Canvas and then pushing a Canvas into it, is this the proper way ?

gsoleilhac avatar Jun 26 '19 07:06 gsoleilhac

Does leaving an empty container and then pushing a canvas onto it work as expected in that it does not change the layout of the rest of the packed components? Do you have to fix the sizes of the other components are designate restricted fill options?

mantzaris avatar Aug 06 '19 15:08 mantzaris

I did it that way, discussed here: https://discourse.julialang.org/t/drawing-on-widgets-defined-in-a-layout-produced-from-glade/27197/5 and it works. I don't think that there is any other way at least if there is, I have not seen any documentation leading to that

mantzaris avatar Aug 07 '19 03:08 mantzaris