https://github.com/borud/console
a simple Fyne widget to provide a console that shows messages
https://github.com/borud/console
console fyne golang widget
Last synced: 8 months ago
JSON representation
a simple Fyne widget to provide a console that shows messages
- Host: GitHub
- URL: https://github.com/borud/console
- Owner: borud
- License: apache-2.0
- Created: 2024-06-12T08:16:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-12T14:17:52.000Z (about 2 years ago)
- Last Synced: 2025-02-24T10:43:47.758Z (over 1 year ago)
- Topics: console, fyne, golang, widget
- Language: Go
- Homepage:
- Size: 264 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Console Fyne Widget
`Console` is a simple fyne Widget intended for logging messages to a window.
[](https://pkg.go.dev/github.com/borud/console)

## Example
A very simple usage example:
```go
package main
import (
"fmt"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"github.com/borud/console"
)
func main() {
app := app.New()
win := app.NewWindow("Console test")
win.Resize(fyne.NewSize(1000, 1000))
console := console.NewConsole()
console.ScrollToBottom = true
console.MaxLines = 1000
go func() {
for i := 0; ; i++ {
console.Append(fmt.Sprintf("This is log message %d at %s", i, time.Now().Format(time.RFC3339)))
time.Sleep(500 * time.Millisecond)
}
}()
win.SetContent(console)
win.ShowAndRun()
}
```
## Building example
There is a slightly more elaborate example included in `cmd/console` which you can build by running
```shell
make
```
This will produce the binary `bin/console`.
## Notes
Big thank you to [Andy Williams](https://github.com/andydotxyz) for suggesting I use the List widget for the log view.
When the next release of Fyne becomes available it should be possible to get rid of the list item separator.
If you have some tips for how I can improve this, you can talk to me on the [Gophers Slack](https://gophers.slack.com/archives/D026HLJ31H7)