# GTK4.jl: Canvas not visible when pushed to a box

**URL:** <https://discourse.julialang.org/t/gtk4-jl-canvas-not-visible-when-pushed-to-a-box/93959>\
**Category:** Visualization\
**Tags:** plotting, gtk\
**Created:** [February 2, 2023, 11:10pm UTC](https://discourse.julialang.org/t/gtk4-jl-canvas-not-visible-when-pushed-to-a-box/93959 "2023-02-02T23:10:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarath-menon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarath-menon/32/46494_2.png) [@sarath-menon](https://discourse.julialang.org/u/sarath-menon)\
**Post date:** [February 2, 2023, 11:10pm UTC](https://discourse.julialang.org/t/gtk4-jl-canvas-not-visible-when-pushed-to-a-box/93959/1 "2023-02-02T23:10:18Z")

</div>

Hello. I am trying to display a canvas GTK4.jl. The documentation example works.

But when I push the canvas to a GTKBox and push the box to the window (instead of pushing the canvas directly to the window), the canvas is not visible

```julia
using Gtk4, Graphics

c = GtkCanvas()
window = GtkWindow("Canvas")

@guarded draw(c) do widget
    ctx = getgc(c)
    h = height(c)
    w = width(c)
    # Paint red rectangle
    rectangle(ctx, 0, 0, w, h/2)
    set_source_rgb(ctx, 1, 0, 0)
    fill(ctx)
    # Paint blue rectangle
    rectangle(ctx, 0, 3h/4, w, h/4)
    set_source_rgb(ctx, 0, 0, 1)
    fill(ctx)
end

#
box = GtkBox(:v) 
push!(box, c)
push!(window,box)

show(window); # trigger rendering

```

Thanks in advance !

---

<div class="post-metadata">

**Author:** ![tknopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tknopp/32/3569_2.png) [@tknopp](https://discourse.julialang.org/u/tknopp)\
**Post date:** [February 3, 2023, 11:32am UTC](https://discourse.julialang.org/t/gtk4-jl-canvas-not-visible-when-pushed-to-a-box/93959/2 "2023-02-03T11:32:02Z")

</div>

`c.hexpand = c.vexpand = true`

solves this. Probably this is a bug and the `Canvas` should expand by default.
