Recently, a new great racket GUI library calls gui-easy-lib is out. The most interesting part is it is a declarative framework, which more like SwiftUI or Flutter, makes development obviously easier. Today, I will use a few examples to show the core idea. First, we can get it with command:
raco pkg install gui-easy-lib
Then have our first tried.
(require racket/gui/easy) (render (window (hpanel (text "hello"))))
The above code shows a hello text. Except that, we have observable variable:
(require racket/gui/easy racket/gui/easy/operator) (define @counter (@ 0)) (render (window (hpanel (button "-" (lambda () (@counter . <~ . sub1))) (text (@counter . ~> . number->string)) (button "+" (lambda () (@counter . <~ . add1))))))
In this example, @ create a new observable with initial state. <~ updates observable with its second argument. ~> apply its second argument with current state. In this simple introduction, you can see a good idea is raising. I hope we will move GUI program on to this, and never go back.