Posts with the tag gtk3:

How to Create File Chooser in Gtk using gotk3 ?

If you just want the complete code snippet, here is it. package main import ( "" "" ) 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.

How to Fix (main:30677): Gtk-WARNING **: cannot open display: ?

If you are facing this error (main:30677): Gtk-WARNING **: 05:40:47.665: cannot open display: just install Gtk+ development library, and set the display screen to 0. Installing Gtk+ using Homebrew If you are using a UNIX-like OS such as Mac OS X, or a Linux distribution. You can use Homebrew package manager to install Gtk+ as following. brew install Gtk+ Install Gtk+ using apt If you are using Debian, Ubuntu, Elementary OS, Linux Mint, .. You can use this command to install Gtk+. sudo apt-get install libgtk-3-dev Set DISPLAY Environment Variable If the error persists, just run this command on terminal to set the display to the current display/monitor/screen.