beef331 / website

Code for the official Nim programming language website
https://nim-lang.org
19 stars 1 forks source link

Owlkettle #45

Closed can-lehmann closed 2 years ago

can-lehmann commented 2 years ago

Name: Owlkettle

Author: Can Lehmann

Posting:

Owlkettle

Owlkettle is a declarative user interface framework based on GTK. It brings the declarative GUI paradigm you know from many web frameworks to the Linux desktop. Let's look at an example application:

import owlkettle

viewable App:
  counter: int

method view(app: AppState): Widget =
  result = gui:
    Window:
      title = "Counter"
      default_size = (200, 60)
      border_width = 12

      Box(orient = OrientX, spacing = 6):
        Label(text = $app.counter)
        Button:
          text = "+"
          style = {ButtonSuggested}
          proc clicked() =
            app.counter += 1

brew(gui(App()))

This code results in the following interactive application:

An example application

Check out owlkettle on GitHub and take a look at more examples.