I have this summarized code to display tabs in a notebook in Gtk. Basically, I have created a custom struct with a embedded label, that is added to the notebook. After that, I want to get back that custom widget, but I get a Invalid type assertion
. I have read a lot about structs and interfaces, but I can't get it to work.
package main
import "github.com/gotk3/gotk3/gtk"
type NotebookPage struct {
gtk.Label
}
func main() {
gtk.Init(nil)
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
notebook, _ := gtk.NotebookNew()
win.Add(notebook)
content1, _ := gtk.LabelNew("Content 1")
page1 := NotebookPage{Label: *content1}
label1, _ := gtk.LabelNew("Label 1")
notebook.AppendPage(&page1, label1)
content2, _ := gtk.LabelNew("Content 2")
page2 := NotebookPage{Label: *content2}
label2, _ := gtk.LabelNew("Label 2")
notebook.AppendPage(&page2, label2)
win.ShowAll()
win.Connect("destroy", func() {
gtk.MainQuit()
})
backwidget1, _ := notebook.GetNthPage(0)
backpage1, _ := backwidget1.(*NotebookPage)
gtk.Main()
}