GTK Logo GTK in Swift Swift Logo

Create cross-platform interfaces in the language you love

SwiftGtk is a largely auto-generated GTK language binding for Swift that allows you to interact with all of GTK in a way that feels more at home with Swift.

import Gtk

let status = {
    let window = ApplicationWindowRef(application: $0)
    window.title = "Hello, world"
    window.setDefaultSize(width: 320, height: 240)
    let label = LabelRef(str: "Hello, SwiftGtk")
    window.add(widget: label)
Complete List View App Example (main.swift)
import GLibObject
import CGtk
import Gtk

let status = { app in
    let window = ApplicationWindowRef(application: app)
    window.title = "List Demo"
    window.setDefaultSize(width: 640, height: 360)

    let i = TreeIter()
    let store = ListStore(.string, .boolean)
    store.append(asNextRow: i, "First Row", false)
    store.append(asNextRow: i, "Second Row", true)
    store.append(asNextRow: i, "Third Row", false)
    let columns = [
        ("Title", "text",   CellRendererText()),
        ("Check", "active", CellRendererToggle())]
        .enumerated().map { (i: Int,
                    c: (title: String, attr: PropertyName, renderer: CellRenderer))
                    -> TreeViewColumn in
            TreeViewColumn(i, title: c.title, renderer: c.renderer, attribute: c.attr)
    let listView = ListView(model: store)
    window.add(widget: listView)

guard let status = status else {
    fatalError("Could not create Application")
guard status == 0 else {
    fatalError("Application exited with status \(status)")
Swift Logo

Copyright © 2016, 2017, 2018, 2019, 2020 · René Hexel · All Rights Reserved