#r "nuget: GirCore.Gtk-4.0"
open Gtk
// https://mastodon.social/@lamg__/112546558109306665
let label () =
let lb = new Label()
lb.SetText "Hello!"
lb
let button ( label: Label ) =
let btn = new Button ()
btn.SetLabel "click me!"
let mutable counter = 0
let clickHler (_) (_) =
label.SetText $"Hello {counter}"
counter <- counter + 1
btn.add_OnClicked(new GObject.SignalHandler<Button>(clickHler))
btn
let onActivate (sender: Gio.Application) (_) =
let win = ApplicationWindow.New(sender :?> Application)
win.Title <- "GTK4 Window"
win.SetDefaultSize(300, 300)
let box = new Box()
let lb = label()
box.Append lb
win.SetChild( box )
button lb |> box.Append
win.Show()
let applic = Application.New("org.gir.core", Gio.ApplicationFlags.FlagsNone)
applic.add_OnActivate(new GObject.SignalHandler<Gio.Application>(onActivate))
applic.RunWithSynchronizationContext(null)
#fsharp ???? #gtk 4 T
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.