# How to position widgets correctly with the Gtk4 grid

**URL:** <https://discourse.julialang.org/t/how-to-position-widgets-correctly-with-the-gtk4-grid/112617>\
**Category:** Offtopic\
**Created:** [April 6, 2024, 10:20pm UTC](https://discourse.julialang.org/t/how-to-position-widgets-correctly-with-the-gtk4-grid/112617 "2024-04-06T22:20:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_73](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex_73/32/206879_2.png) [@Alex\_73](https://discourse.julialang.org/u/Alex_73)\
**Post date:** [April 6, 2024, 10:20pm UTC](https://discourse.julialang.org/t/how-to-position-widgets-correctly-with-the-gtk4-grid/112617/1 "2024-04-06T22:20:55Z")

</div>

I’m starting to study Gtk4 made available by [https://juliagtk.github.io/Gtk4.jl/dev/manual/layout/#GtkGrid](https://juliagtk.github.io/Gtk4.jl/dev/manual/layout/#GtkGrid)  
And I managed to run the example:

```julia
win = GtkWindow("A new window")
g = GtkGrid()
a = GtkEntry() # a widget for entering text
a.text = "This is Gtk!"
b = GtkCheckButton("Check me!")
c = GtkScale(:h, 0:10) # a slider

# Now let's place these graphical elements into the Grid:
g[1,1] = a # Cartesian coordinates, g[x,y]
g[2,1] = b
g[1:2,2] = c # spans both columns
g.column_homogeneous = true # grid forces columns to have the same width
g.column_spacing = 15 # introduce a 15-pixel gap between columns
push!(win, g)

```

However, if you comment on lines 9 and 11 (a and c), GtkCheckButton b appears in position (1,1) instead of the specification (2,1)

```julia
win = GtkWindow("A new window")
g = GtkGrid()
a = GtkEntry() # a widget for entering text
a.text = "This is Gtk!"
b = GtkCheckButton("Check me!")
c = GtkScale(:h, 0:10) # a slider

# Now let's place these graphical elements into the Grid:
#g[1,1] = a # Cartesian coordinates, g[x,y]
g[2,1] = b
#g[1:2,2] = c # spans both columns
g.column_homogeneous = true # grid forces columns to have the same width
g.column_spacing = 15 # introduce a 15-pixel gap between columns
push!(win, g)

```

Could anyone help me understand the reason for this?

---

<div class="post-metadata">

**Author:** ![jwahlstrand](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@jwahlstrand](https://discourse.julialang.org/u/jwahlstrand)\
**Post date:** [April 7, 2024, 4:04pm UTC](https://discourse.julialang.org/t/how-to-position-widgets-correctly-with-the-gtk4-grid/112617/2 "2024-04-07T16:04:46Z")

</div>

The widget only makes space for a first column if there is a widget occupying it, even when `column_homogeneous = true` is set. If you add anything to the first column, even an empty layout widget, for example using `g[1,1] = GtkBox(:h)`, it does show the empty first column.

---

<div class="post-metadata">

**Author:** ![Alex\_73](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alex_73/32/206879_2.png) [@Alex\_73](https://discourse.julialang.org/u/Alex_73)\
**Post date:** [April 7, 2024, 5:16pm UTC](https://discourse.julialang.org/t/how-to-position-widgets-correctly-with-the-gtk4-grid/112617/3 "2024-04-07T17:16:24Z")

</div>

Huuum I thought it could be that… I’m kind of learning on my own, so as this information wasn’t included in this part of the documentation, I thought I’d better ask. Thanks for the feedback!
