rhx / SwiftGtk

A Swift wrapper around gtk-3.x and gtk-4.x that is largely auto-generated from gobject-introspection
https://rhx.github.io/SwiftGtk/
BSD 2-Clause "Simplified" License
317 stars 26 forks source link

No easy way to add a label to an app and no docs #14

Closed Elara6331 closed 4 years ago

Elara6331 commented 4 years ago

I would like something like Label(text: "") to add a label into an app as right now, there is no easy way of doing it that I found. Also, you should have documentation on this, it is very confusing when I have to go through the source code trying to find out how to make something work. Thank you.

rhx commented 4 years ago

Documentation is now available at https://rhx.github.io/SwiftGtk

Also, while there are no Swift-specific tutorials, there are a number of example projects (see the README). Also if you look at gtk tutorials for other languages, you can often translate this to the (auto-generated) Swift version fairly easily. For example, gtk_label_new(str) translates to an auto-generated constructor init(str: String) in Swift. So what you want can be achieved by something like:

    let label = Label(str: "Text")
    window.add(widget: label)

You can try this by adding the above code to the SwiftHelloGtk example, right before window.showAll() .