gtk-kn¶
This project provides Kotlin/Native bindings for GTK and related GObject-based libraries.
Example¶
This basic “Hello World” example displays a window with a button and a signal handler.
private const val APP_ID = "org.gtkkn.samples.gtk.helloworld"
fun main() {
// Create a new application
val app = Application(APP_ID, ApplicationFlags.FLAGS_NONE)
// Connect to "activate" signal of `app`
app.connectActivate {
// Create a button with label and margins
val button = Button()
button.setLabel("Click me!")
button.setMargins(12)
// Connect to "clicked" signal of `button`
button.connectClicked {
// Set the label to "Hello World!" after the button has been clicked on
button.setLabel("Hello World!")
}
// Create a window and set the title
val window = ApplicationWindow(app)
window.setTitle("My GTK App")
window.setChild(button)
// Present window
window.present()
}
// Run the application
app.runApplication()
}
For full, step-by-step instructions, see User Guide.
From Setup to Deployment¶
The gtk-kn
User Guide provides step-by-step instructions for integrating gtk-kn
into
Kotlin/Native projects. It offers essential information, from initial setup to advanced features, with detailed examples
and best practices.
Designed to support both new and experienced developers, the guide covers essential setup, code examples, and practical
insights to help you leverage gtk-kn
efficiently in your projects.
Acknowledgments¶
We acknowledge the resources and projects that have informed this documentation:
- The maintainers of GTK libraries, who provide a robust toolkit for GUI development.
- GTK4 Documentation
- PyGObject Documentation
- GTK with Rust
Without these contributions, this documentation would not be possible. We appreciate the commitment to enhancing the GTK ecosystem.
License¶
This guide is licensed under Creative Commons Attribution-ShareAlike 4.0 International, with code snippets under the MIT License.