Original post

I have been unable to use GTK3 Grid to insert an extra row.

I have coded a minimal case which shows my problem. Maybe I am missing something.

Any feedback appreciated. Also any hints on formatting my program code properly are welcomed. tried file upload, but it did not like the . extention.

package main

import ("github.com/gotk3/gotk3/gtk")
import "fmt"

func main(){
    gtk.Init(nil)
    major:=gtk.GetMajorVersion(); minor:=gtk.GetMinorVersion()
    fmt.Println(fmt.Sprintf("GTK version %d.%d",major,minor))
    win,_ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)

    win.SetDefaultSize(500,400)
    win.SetTitle("Grid Test")
    win.Connect("destroy", func() { gtk.MainQuit() })

    grid,_ := gtk.GridNew()

    grid.SetOrientation(gtk.ORIENTATION_VERTICAL)

    lbl,_:=gtk.LabelNew("Label 0")
    grid.Attach(lbl,1,1,1,1)

    lbl1,_:=gtk.LabelNew("Label 1")
    grid.Attach(lbl1,1,2,1,1)

    btn,_:=gtk.ButtonNewWithLabel("Click")
    btn.Connect("clicked", func() {hdrClicked(grid,lbl)})
    grid.Attach(btn,1,3,1,1)

    win.Add(grid)

    win.ShowAll()
    gtk.Main()
    }

func hdrClicked(grid *gtk.Grid, lblRef *gtk.Label){
    fmt.Println("Click")
    lbl,_:=gtk.LabelNew("Added Label")
    grid.InsertRow(2)
    grid.Attach(lbl,1,2,1,1)
    grid.QueueDraw()
    }

test1Atest1B

I tried using “grid.InsertRow(2)” rather than InsertNextTo

Same problem; the grid.Attach does not affect the screen

Adding “grid.QueueDraw()” does not have any effect.

What am I missing ? Is there a problem with gotk3/gtk or even gtk3 itself ?

Any thoughts ?