{"id":13413128,"url":"https://github.com/gotk3/gotk3","last_synced_at":"2025-05-13T19:09:41.800Z","repository":{"id":36354608,"uuid":"40659385","full_name":"gotk3/gotk3","owner":"gotk3","description":"Go bindings for GTK3","archived":false,"fork":false,"pushed_at":"2024-08-08T18:05:51.000Z","size":3700,"stargazers_count":2151,"open_issues_count":122,"forks_count":229,"subscribers_count":64,"default_branch":"master","last_synced_at":"2025-04-26T11:52:21.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotk3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-13T13:09:46.000Z","updated_at":"2025-04-25T18:46:47.000Z","dependencies_parsed_at":"2024-02-02T09:41:38.076Z","dependency_job_id":"0abef4f7-4944-4813-b1da-2a03418e2e96","html_url":"https://github.com/gotk3/gotk3","commit_stats":{"total_commits":1166,"total_committers":160,"mean_commits":7.2875,"dds":0.8850771869639794,"last_synced_commit":"3cef00d4dbd8f0db2742fa92b133f8daae0ed369"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotk3%2Fgotk3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotk3%2Fgotk3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotk3%2Fgotk3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotk3%2Fgotk3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotk3","download_url":"https://codeload.github.com/gotk3/gotk3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251089406,"owners_count":21534511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:33.864Z","updated_at":"2025-04-27T04:41:22.009Z","avatar_url":"https://github.com/gotk3.png","language":"Go","readme":"gotk3 [![GoDoc](https://godoc.org/github.com/gotk3/gotk3?status.svg)](https://godoc.org/github.com/gotk3/gotk3)\r\n=====\r\n\r\n[![Build Status](https://travis-ci.org/gotk3/gotk3.svg?branch=master)](https://travis-ci.org/gotk3/gotk3)\r\n\r\nThe gotk3 project provides Go bindings for GTK 3 and dependent\r\nprojects.  Each component is given its own subdirectory, which is used\r\nas the import path for the package.  Partial binding support for the\r\nfollowing libraries is currently implemented:\r\n\r\n- GTK 3 (3.12 and later)\r\n- GDK 3 (3.12 and later)\r\n- GLib 2 (2.36 and later)\r\n- Cairo (1.10 and later)\r\n\r\nCare has been taken for memory management to work seamlessly with Go's\r\ngarbage collector without the need to use or understand GObject's\r\nfloating references.\r\n\r\nfor better understanding see\r\n[package reference documation](https://pkg.go.dev/github.com/gotk3/gotk3/gtk?tab=doc)\r\n\r\nOn Linux, see which version your distribution has [here](https://pkgs.org) with the search terms:\r\n* libgtk-3\r\n* libglib2\r\n* libgdk-pixbuf2\r\n\r\n## Sample Use\r\n\r\nThe following example can be found in [Examples](https://github.com/gotk3/gotk3-examples/).\r\n\r\n```Go\r\npackage main\r\n\r\nimport (\r\n    \"github.com/gotk3/gotk3/gtk\"\r\n    \"log\"\r\n)\r\n\r\nfunc main() {\r\n    // Initialize GTK without parsing any command line arguments.\r\n    gtk.Init(nil)\r\n\r\n    // Create a new toplevel window, set its title, and connect it to the\r\n    // \"destroy\" signal to exit the GTK main loop when it is destroyed.\r\n    win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)\r\n    if err != nil {\r\n        log.Fatal(\"Unable to create window:\", err)\r\n    }\r\n    win.SetTitle(\"Simple Example\")\r\n    win.Connect(\"destroy\", func() {\r\n        gtk.MainQuit()\r\n    })\r\n\r\n    // Create a new label widget to show in the window.\r\n    l, err := gtk.LabelNew(\"Hello, gotk3!\")\r\n    if err != nil {\r\n        log.Fatal(\"Unable to create label:\", err)\r\n    }\r\n\r\n    // Add the label to the window.\r\n    win.Add(l)\r\n\r\n    // Set the default window size.\r\n    win.SetDefaultSize(800, 600)\r\n\r\n    // Recursively show all widgets contained in this window.\r\n    win.ShowAll()\r\n\r\n    // Begin executing the GTK main loop.  This blocks until\r\n    // gtk.MainQuit() is run.\r\n    gtk.Main()\r\n}\r\n```\r\n\r\nTo build the example:\r\n\r\n```shell\r\n$ go build example.go\r\n```\r\n\r\nTo build this example with older gtk version you should use gtk_3_10 tag:\r\n\r\n```shell\r\n$ go build -tags gtk_3_10 example.go\r\n```\r\n\r\n### Example usage\r\n\r\n```Go\r\npackage main\r\n\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n\r\n    \"github.com/gotk3/gotk3/glib\"\r\n    \"github.com/gotk3/gotk3/gtk\"\r\n)\r\n\r\n// Simple Gtk3 Application written in go.\r\n// This application creates a window on the application callback activate.\r\n// More GtkApplication info can be found here -\u003e https://wiki.gnome.org/HowDoI/GtkApplication\r\n\r\nfunc main() {\r\n    // Create Gtk Application, change appID to your application domain name reversed.\r\n    const appID = \"org.gtk.example\"\r\n    application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE)\r\n    // Check to make sure no errors when creating Gtk Application\r\n    if err != nil {\r\n        log.Fatal(\"Could not create application.\", err)\r\n    }\r\n    // Application signals available\r\n    // startup -\u003e sets up the application when it first starts\r\n    // activate -\u003e shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment.\r\n    // open -\u003e opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar.\r\n    // shutdown -\u003e  performs shutdown tasks\r\n    // Setup Gtk Application callback signals\r\n    application.Connect(\"activate\", func() { onActivate(application) })\r\n    // Run Gtk application\r\n    os.Exit(application.Run(os.Args))\r\n}\r\n\r\n// Callback signal from Gtk Application\r\nfunc onActivate(application *gtk.Application) {\r\n    // Create ApplicationWindow\r\n    appWindow, err := gtk.ApplicationWindowNew(application)\r\n    if err != nil {\r\n        log.Fatal(\"Could not create application window.\", err)\r\n    }\r\n    // Set ApplicationWindow Properties\r\n    appWindow.SetTitle(\"Basic Application.\")\r\n    appWindow.SetDefaultSize(400, 400)\r\n    appWindow.Show()\r\n}\r\n```\r\n\r\n```Go\r\npackage main\r\n\r\nimport (\r\n    \"log\"\r\n    \"os\"\r\n\r\n    \"github.com/gotk3/gotk3/glib\"\r\n    \"github.com/gotk3/gotk3/gtk\"\r\n)\r\n\r\n// Simple Gtk3 Application written in go.\r\n// This application creates a window on the application callback activate.\r\n// More GtkApplication info can be found here -\u003e https://wiki.gnome.org/HowDoI/GtkApplication\r\n\r\nfunc main() {\r\n    // Create Gtk Application, change appID to your application domain name reversed.\r\n    const appID = \"org.gtk.example\"\r\n    application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE)\r\n    // Check to make sure no errors when creating Gtk Application\r\n    if err != nil {\r\n        log.Fatal(\"Could not create application.\", err)\r\n    }\r\n\r\n    // Application signals available\r\n    // startup -\u003e sets up the application when it first starts\r\n    // activate -\u003e shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment.\r\n    // open -\u003e opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar.\r\n    // shutdown -\u003e  performs shutdown tasks\r\n    // Setup activate signal with a closure function.\r\n    application.Connect(\"activate\", func() {\r\n        // Create ApplicationWindow\r\n        appWindow, err := gtk.ApplicationWindowNew(application)\r\n        if err != nil {\r\n            log.Fatal(\"Could not create application window.\", err)\r\n        }\r\n        // Set ApplicationWindow Properties\r\n        appWindow.SetTitle(\"Basic Application.\")\r\n        appWindow.SetDefaultSize(400, 400)\r\n        appWindow.Show()\r\n    })\r\n    // Run Gtk application\r\n    application.Run(os.Args)\r\n}\r\n```\r\n\r\n## Documentation\r\n\r\nEach package's internal `go doc` style documentation can be viewed\r\nonline without installing this package by using the GoDoc site (links\r\nto [cairo](http://godoc.org/github.com/gotk3/gotk3/cairo),\r\n[glib](http://godoc.org/github.com/gotk3/gotk3/glib),\r\n[gdk](http://godoc.org/github.com/gotk3/gotk3/gdk), and\r\n[gtk](http://godoc.org/github.com/gotk3/gotk3/gtk) documentation).\r\n\r\nYou can also view the documentation locally once the package is\r\ninstalled with the `godoc` tool by running `godoc -http=\":6060\"` and\r\npointing your browser to\r\nhttp://localhost:6060/pkg/github.com/gotk3/gotk3\r\n\r\n## Installation\r\n\r\ngotk3 currently requires GTK 3.6-3.24, GLib 2.36-2.46, and\r\nCairo 1.10 or 1.12.  A recent Go (1.8 or newer) is also required.\r\n\r\nFor detailed instructions see the wiki pages: [installation](https://github.com/gotk3/gotk3/wiki#installation)\r\n\r\n## Using deprecated features\r\n\r\nBy default, deprecated GTK features are not included in the build.\r\n\r\nBy specifying the e.g. build tag `gtk_3_20`, any feature deprecated in GTK 3.20 or earlier will NOT be available.\r\nTo enable deprecated features in the build, add the tag `gtk_deprecated`.\r\nExample:\r\n```shell\r\n$ go build -tags \"gtk_3_10 gtk_deprecated\" example.go\r\n```\r\n\r\nThe same goes for\r\n* gdk-pixbuf: gdk_pixbuf_deprecated\r\n\r\n## TODO\r\n\r\n- Add bindings for all of GTK functions\r\n- Add tests for each implemented binding\r\n- See the next steps: [wiki page](https://github.com/gotk3/gotk3/wiki/The-future-and-what-happens-next) and add [your suggestion](https://github.com/gotk3/gotk3/issues/576)\r\n\r\n\r\n## License\r\n\r\nPackage gotk3 is licensed under the liberal ISC License.\r\n\r\nActually if you use gotk3, then gotk3 is statically linked into your application (with the ISC licence).\r\nThe system libraries (e.g. GTK+, GLib) used via cgo use dynamic linking.\r\n","funding_links":[],"categories":["GUI","Relational Databases","常用的GUI开发库","Go","\u003cspan id=\"gui\"\u003eGUI\u003c/span\u003e"],"sub_categories":["Search and Analytic Databases","SQL 查询语句构建库","Advanced Console UIs","工具包","检索及分析资料库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotk3%2Fgotk3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotk3%2Fgotk3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotk3%2Fgotk3/lists"}