Posts with the tag gotk3:

How to Create File Chooser in Gtk using gotk3 ?

If you just want the complete code snippet, here is it. package main import ( "github.com/gotk3/gotk3/gdk" "github.com/gotk3/gotk3/gtk" ) func main() { gtk.Init(nil) win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) win.SetTitle("sample app") win.Connect("destroy", func() { gtk.MainQuit() }) grid, _ := gtk.GridNew() win.Add(grid) imgview, _ := gtk.ImageNew() pbuf, _ := gdk.PixbufNewFromFileAtScale("./img/default.png", 400, 400, true) imgview.SetFromPixbuf(pbuf) grid.Attach(imgview, 0, 0, 1, 1) textentry, _ := gtk.EntryNew() grid.AttachNextTo(textentry, imgview, gtk.POS_BOTTOM, 1, 1) btnChoose, _ := gtk.ButtonNewWithLabel("Choose An Image") grid.AttachNextTo(btnChoose, textentry, gtk.POS_BOTTOM, 1, 1) btnChoose.Connect("clicked", func() { dlg, _ := gtk.FileChooserDialogNewWith2Buttons( "choose an image", nil, gtk.FILE_CHOOSER_ACTION_OPEN, "Open", gtk.RESPONSE_OK, "Cancel", gtk.RESPONSE_CANCEL, ) dlg.SetDefaultResponse(gtk.RESPONSE_OK) filter, _ := gtk.FileFilterNew() filter.SetName("images") filter.AddMimeType("image/png") filter.AddMimeType("image/jpeg") filter.