gotk3/gotk3: Go bindings for GTK3 - GitHub
文章推薦指數: 80 %
Partial binding support for the following libraries is currently implemented: GTK 3 (3.12 and later); GDK 3 (3.12 and later); GLib 2 (2.36 and later); Cairo ( ... Skiptocontent {{message}} gotk3 / gotk3 Public Notifications Star 1.7k Fork 205 GobindingsforGTK3 ISCLicense 1.7k stars 205 forks Star Notifications Code Issues 80 Pullrequests 1 Discussions Actions Projects 0 Wiki Security Insights More Code Issues Pullrequests Discussions Actions Projects Wiki Security Insights master Branches Tags Couldnotloadbranches Nothingtoshow Loading {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default Loading 1 branch 7 tags Code Loading Latestcommit Gitstats 1,638 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime .github Creatego.yml Aug12,2021 cairo Mergepullrequest#820fromolabiniV2/fix_finalizer_bad_thread_inter… Jul30,2021 gdk UseglibFinalizerStrategyforallplacesthatuse Jul30,2021 gio clang-formatallCHeaderfiles Dec26,2020 glib adjustfunctionsignaturesintests Nov7,2021 gtk Mergepullrequest#845fromhfmrow/Add-(gtk).FileChooser-Set/GetAction Nov7,2021 internal Moreperformant{Idle,Timeout}Add May4,2021 pango Ishouldn'tfreealistthatisgoingtobeusedlater Aug16,2021 .gitignore AddGomodulefornewerGoversions Apr25,2020 .travis.yml Update.travis.yml Jan3,2021 CHANGES.md UpdateCHANGES.md Aug27,2021 CONTRIBUTIONS.md addascontributor Feb16,2021 LICENSE AddtitletotheLICENSEfile Feb27,2021 README.md correctspellingofpage May26,2020 go.mod AddGomodulefornewerGoversions Apr25,2020 shippable.yml CIforGTK3.10withshippable Jul17,2015 Viewcode gotk3 SampleUse Exampleusage Documentation Installation Usingdeprecatedfeatures TODO License README.md gotk3 Thegotk3projectprovidesGobindingsforGTK3anddependent projects.Eachcomponentisgivenitsownsubdirectory,whichisused astheimportpathforthepackage.Partialbindingsupportforthe followinglibrariesiscurrentlyimplemented: GTK3(3.12andlater) GDK3(3.12andlater) GLib2(2.36andlater) Cairo(1.10andlater) CarehasbeentakenformemorymanagementtoworkseamlesslywithGo's garbagecollectorwithouttheneedtouseorunderstandGObject's floatingreferences. forbetterunderstandingsee packagereferencedocumation OnLinux,seewhichversionyourdistributionhasherewiththesearchterms: libgtk-3 libglib2 libgdk-pixbuf2 SampleUse ThefollowingexamplecanbefoundinExamples. packagemain import( "github.com/gotk3/gotk3/gtk" "log" ) funcmain(){ //InitializeGTKwithoutparsinganycommandlinearguments. gtk.Init(nil) //Createanewtoplevelwindow,setitstitle,andconnectittothe //"destroy"signaltoexittheGTKmainloopwhenitisdestroyed. win,err:=gtk.WindowNew(gtk.WINDOW_TOPLEVEL) iferr!=nil{ log.Fatal("Unabletocreatewindow:",err) } win.SetTitle("SimpleExample") win.Connect("destroy",func(){ gtk.MainQuit() }) //Createanewlabelwidgettoshowinthewindow. l,err:=gtk.LabelNew("Hello,gotk3!") iferr!=nil{ log.Fatal("Unabletocreatelabel:",err) } //Addthelabeltothewindow. win.Add(l) //Setthedefaultwindowsize. win.SetDefaultSize(800,600) //Recursivelyshowallwidgetscontainedinthiswindow. win.ShowAll() //BeginexecutingtheGTKmainloop.Thisblocksuntil //gtk.MainQuit()isrun. gtk.Main() } Tobuildtheexample: $gobuildexample.go Tobuildthisexamplewitholdergtkversionyoushouldusegtk_3_10tag: $gobuild-tagsgtk_3_10example.go Exampleusage packagemain import( "log" "os" "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" ) //SimpleGtk3Applicationwritteningo. //Thisapplicationcreatesawindowontheapplicationcallbackactivate. //MoreGtkApplicationinfocanbefoundhere->https://wiki.gnome.org/HowDoI/GtkApplication funcmain(){ //CreateGtkApplication,changeappIDtoyourapplicationdomainnamereversed. constappID="org.gtk.example" application,err:=gtk.ApplicationNew(appID,glib.APPLICATION_FLAGS_NONE) //ChecktomakesurenoerrorswhencreatingGtkApplication iferr!=nil{ log.Fatal("Couldnotcreateapplication.",err) } //Applicationsignalsavailable //startup->setsuptheapplicationwhenitfirststarts //activate->showsthedefaultfirstwindowoftheapplication(likeanewdocument).Thiscorrespondstotheapplicationbeinglaunchedbythedesktopenvironment. //open->opensfilesandshowstheminanewwindow.Thiscorrespondstosomeonetryingtoopenadocument(ordocuments)usingtheapplicationfromthefilebrowser,orsimilar. //shutdown->performsshutdowntasks //SetupGtkApplicationcallbacksignals application.Connect("activate",func(){onActivate(application)}) //RunGtkapplication os.Exit(application.Run(os.Args)) } //CallbacksignalfromGtkApplication funconActivate(application*gtk.Application){ //CreateApplicationWindow appWindow,err:=gtk.ApplicationWindowNew(application) iferr!=nil{ log.Fatal("Couldnotcreateapplicationwindow.",err) } //SetApplicationWindowProperties appWindow.SetTitle("BasicApplication.") appWindow.SetDefaultSize(400,400) appWindow.Show() } packagemain import( "log" "os" "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" ) //SimpleGtk3Applicationwritteningo. //Thisapplicationcreatesawindowontheapplicationcallbackactivate. //MoreGtkApplicationinfocanbefoundhere->https://wiki.gnome.org/HowDoI/GtkApplication funcmain(){ //CreateGtkApplication,changeappIDtoyourapplicationdomainnamereversed. constappID="org.gtk.example" application,err:=gtk.ApplicationNew(appID,glib.APPLICATION_FLAGS_NONE) //ChecktomakesurenoerrorswhencreatingGtkApplication iferr!=nil{ log.Fatal("Couldnotcreateapplication.",err) } //Applicationsignalsavailable //startup->setsuptheapplicationwhenitfirststarts //activate->showsthedefaultfirstwindowoftheapplication(likeanewdocument).Thiscorrespondstotheapplicationbeinglaunchedbythedesktopenvironment. //open->opensfilesandshowstheminanewwindow.Thiscorrespondstosomeonetryingtoopenadocument(ordocuments)usingtheapplicationfromthefilebrowser,orsimilar. //shutdown->performsshutdowntasks //Setupactivatesignalwithaclosurefunction. application.Connect("activate",func(){ //CreateApplicationWindow appWindow,err:=gtk.ApplicationWindowNew(application) iferr!=nil{ log.Fatal("Couldnotcreateapplicationwindow.",err) } //SetApplicationWindowProperties appWindow.SetTitle("BasicApplication.") appWindow.SetDefaultSize(400,400) appWindow.Show() }) //RunGtkapplication application.Run(os.Args) } Documentation Eachpackage'sinternalgodocstyledocumentationcanbeviewed onlinewithoutinstallingthispackagebyusingtheGoDocsite(links tocairo, glib, gdk,and gtkdocumentation). Youcanalsoviewthedocumentationlocallyoncethepackageis installedwiththegodoctoolbyrunninggodoc-http=":6060"and pointingyourbrowserto http://localhost:6060/pkg/github.com/gotk3/gotk3 Installation gotk3currentlyrequiresGTK3.6-3.24,GLib2.36-2.46,and Cairo1.10or1.12.ArecentGo(1.8ornewer)isalsorequired. Fordetailedinstructionsseethewikipages:installation Usingdeprecatedfeatures Bydefault,deprecatedGTKfeaturesarenotincludedinthebuild. Byspecifyingthee.g.buildtaggtk_3_20,anyfeaturedeprecatedinGTK3.20orearlierwillNOTbeavailable. Toenabledeprecatedfeaturesinthebuild,addthetaggtk_deprecated. Example: $gobuild-tags"gtk_3_10gtk_deprecated"example.go Thesamegoesfor gdk-pixbuf:gdk_pixbuf_deprecated TODO AddbindingsforallofGTKfunctions Addtestsforeachimplementedbinding Seethenextsteps:wikipageandaddyoursuggestion License Packagegotk3islicensedundertheliberalISCLicense. Actuallyifyouusegotk3,thengotk3isstaticallylinkedintoyourapplication(withtheISClicence). Thesystemlibraries(e.g.GTK+,GLib)usedviacgousedynamiclinking. About GobindingsforGTK3 Resources Readme License ISCLicense Releases 6 GOTK3Version0.6.1 Latest Jul14,2021 +5releases Packages0 Nopackagespublished Usedby333 +325 Contributors131 +120contributors Languages Go 96.3% C 3.7% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1gtk - pkg.dev
Go Bindings for Gtk+ 2. Support version 2.16 and later. Index ¶. Constants; func ABOUT_DIALOG(p *...
- 2gtk - pkg.dev
Whenever a native GTK call could return an unexpected NULL pointer, an additional error is return...
- 3mattn/go-gtk: Go binding for GTK - GitHub
Go binding for GTK. Contribute to mattn/go-gtk development by creating an account on GitHub.
- 4Golang gtk.Window函數代碼示例- 純淨天空
本文整理匯總了Golang中github.com/mattn/go-gtk/gtk.Window函數的典型用法代碼示例。如果您正苦於以下問題:Golang Window函數的具體用法?Golan...
- 5go-gtk 研究,在linux 下面使用golang 做gui 开发。 - CSDN博客
目录1,关于go-gtk2,安装3,总结1,关于go-gtkgo-gtk 一个gtk2封装的golang ,需要libgtk±2.0 库,直接安装就行。https://github.com/ma...