Created
February 20, 2026 15:05
-
-
Save MaxGyver83/e9b442bdcbf5e5a1e91f74cf344dd84d to your computer and use it in GitHub Desktop.
Render test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "strconv" | |
| "strings" | |
| "fyne.io/fyne/v2" | |
| "fyne.io/fyne/v2/app" | |
| "fyne.io/fyne/v2/container" | |
| "fyne.io/fyne/v2/widget" | |
| ) | |
| var ( | |
| a fyne.App | |
| window fyne.Window | |
| textArea *fyne.Container | |
| ) | |
| func main() { | |
| a = app.New() | |
| window = a.NewWindow("Render Test") | |
| loading := widget.NewLabel("Loading content...") | |
| textArea = container.NewMax(container.NewVScroll(loading)) | |
| reloadBtn := widget.NewButton("Reload", nil) | |
| reloadBtn.OnTapped = createRichText | |
| bottom := container.NewHBox(reloadBtn) | |
| main := container.NewBorder(nil, bottom, nil, nil, textArea) | |
| window.SetContent(main) | |
| createRichText() | |
| window.ShowAndRun() | |
| } | |
| func createRichText() { | |
| // create one RichText object per section | |
| objs := []fyne.CanvasObject{} | |
| for i := 0; i < 30; i++ { | |
| letter := rune('a') + rune(i%26) | |
| word := (string(letter)) + "text " | |
| paragraph := strings.Repeat(word, 100) + "\n" | |
| section := "## header " + strconv.Itoa(i+1) + "\n" + paragraph | |
| richText := widget.NewRichTextFromMarkdown(section) | |
| richText.Wrapping = fyne.TextWrapWord | |
| objs = append(objs, richText) | |
| } | |
| scroll := container.NewVScroll(container.NewVBox(objs...)) | |
| textArea.Objects = []fyne.CanvasObject{scroll} | |
| textArea.Refresh() | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you need an icon for testing, here it is: