Updates gui example and bumps fyne version ahead two patch versions. markdown render is still buggy, hopefully they fix it eventually.

This commit is contained in:
sloum 2022-04-21 16:21:37 -07:00
parent 1123d306ef
commit cda9e9bf94
3 changed files with 26 additions and 17 deletions

View File

@ -7,16 +7,13 @@
(define contents "")
; Set up the widgets
(define l (widget-make-label "Log In" 0))
(define l (widget-make-label "Slope" 0))
; Form widgets
(define l1 (widget-make-label "Text"))
(define e1 (widget-make-entry "Link Text" #f (lambda (s) (if (regex-match? ".+" s) #t "Invalid entry"))))
(define l2 (widget-make-label "URL"))
(define e2 (widget-make-entry "Link URL" #f (lambda (s) (if (regex-match? "[http|https|gemini|gopher|ftp]://.+\..+" s) #t "URL missing scheme"))))
(define cb (widget-make-checkbox "Light Theme"
(lambda (state)
(if state
(gui-use-light-theme app #t)
(gui-use-light-theme app #f)))))
(define b (widget-make-button "Submit"
(lambda ()
(define t (widget-get-text e1))
@ -27,20 +24,32 @@
(widget-set-text e2 "")
(container-add-to contents (container "hbox" (widget-make-spacer) (widget-make-hyperlink t u)))))) 0))
(define sel (widget-make-select ["Seitan" "Tofu" "Veggies" "Kimchi"] (lambda (choice) (display choice (gui-use-light-theme app) "\n")) 0))
(define md (widget-make-markdown "# Title 1\n\nThis is just some paragraph text to see how things will go if I add a _decent_ amount of text.\n\n- List item 1\n- List item 2\n\n[md-link](https://git.rawtext.club)\n" #t))
; Checkbox to toggle the theme
(define cb (widget-make-checkbox "Light Theme"
(lambda (state)
(if state
(gui-use-light-theme app #t)
(gui-use-light-theme app #f)))))
; A select that will trigger an info box and tell you about your selection
(define sel (widget-make-select ["Fun" "Functional" "Hackable" "Portable"] (lambda (choice) (dialog-info app "main" "Your Choice" (string-append "You chose: " choice))) 0))
; A markdown document rendered as a widget. Newlines are not recognized
(define md (widget-make-markdown "# Welcome to GUI\n\nThe slope gui is an experimental feature that can be _optionally_ compiled in with the interpreter.\n\nIt has some basic facilities, but is definitely **fun** to play with.\n\n- Windows\n- Widgets\n- Containers\n - Etc\n\n[Slope Git Org](https://git.rawtext.club/slope-lang) is a good place to check out." #t))
; Set up the container(s)
(set! contents (container "vbox" l md (widget-make-separator) (container "form" l1 e1 l2 e2) cb sel b (widget-make-separator) (container "hbox" (widget-make-spacer) (widget-make-hyperlink "by sloum" "http://sloum.colorfield.space/"))))
(set! contents
(container "vbox" l md (widget-make-separator) cb sel (widget-make-separator) (container "form" l1 e1 l2 e2) b (widget-make-separator) (container "hbox" (widget-make-spacer) (widget-make-hyperlink "slope.colorfield.space" "https://slope.colorfield.space/"))))
; Add the containers to a scroll box
(define scroller (container-scroll contents))
; Configure the window
(gui-add-window app "main")
(window-set-content app "main" scroller)
(window-resize app "main" 400 500)
(window-resize app "main" 400 550)
(window-center app "main")
(window-set-title app "main" "Log In Form")
(window-set-title app "main" "Slope GUI Demo")
; Go time.
(window-show-and-run app "main")

2
go.mod
View File

@ -3,6 +3,6 @@ module git.rawtext.club/sloum/slope
go 1.16
require (
fyne.io/fyne/v2 v2.1.1
fyne.io/fyne/v2 v2.1.3
github.com/peterh/liner v1.2.1
)

10
go.sum
View File

@ -1,5 +1,5 @@
fyne.io/fyne/v2 v2.1.1 h1:3p39SwQ/rBiYODVYI4ggTuwMufWYmqaRMJvXTFg7jSw=
fyne.io/fyne/v2 v2.1.1/go.mod h1:c1vwI38Ebd0dAdxVa6H1Pj6/+cK1xtDy61+I31g+s14=
fyne.io/fyne/v2 v2.1.3 h1:I5qSeENAcq67hmO5Z2hI7sEJm9bdLMDJx59Fv8qJkX0=
fyne.io/fyne/v2 v2.1.3/go.mod h1:p+E/Dh+wPW8JwR2DVcsZ9iXgR9ZKde80+Y+40Is54AQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
@ -14,9 +14,9 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f h1:s0O46d8fPwk9kU4k1jj76wBquMVETx7uveQD9MCIQoU=
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f/go.mod h1:wjpnOv6ONl2SuJSxqCPVaPZibGFdSci9HFocT9qtVYM=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb h1:T6gaWBvRzJjuOrdCtg8fXXjKai2xSDqWTcKFUPuw8Tw=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be h1:Z28GdQBfKOL8tNHjvaDn3wHDO7AzTRkmAXvHvnopp98=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff h1:W71vTCKoxtdXgnm1ECDFkfQnpdqAO00zzGXLA5yaEX8=