[GH-ISSUE #744] Not renderring real-time #544

Closed
opened 2026-03-04 01:05:54 +03:00 by kerem · 4 comments
Owner

Originally created by @ashis0013 on GitHub (Jul 11, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/744

Trying to use a basic counter but the UI doesn't update. Am I doing anything wrong here?

package main

import (
    "fmt"
    "time"
    "github.com/rivo/tview"
)

func main() {
    app := tview.NewApplication()
    status := tview.NewTextView().SetDynamicColors(true).SetWrap(false)

    var t = 0
    go func() {
        for true {
            status.SetText(fmt.Sprintf("Time is %d", t))
            t++
            time.Sleep(time.Second)
        }
    }()
    if err := app.SetRoot(status, true).SetFocus(status).Run(); err != nil {
		panic(err)
	}
}
Originally created by @ashis0013 on GitHub (Jul 11, 2022). Original GitHub issue: https://github.com/rivo/tview/issues/744 Trying to use a basic counter but the UI doesn't update. Am I doing anything wrong here? ```go package main import ( "fmt" "time" "github.com/rivo/tview" ) func main() { app := tview.NewApplication() status := tview.NewTextView().SetDynamicColors(true).SetWrap(false) var t = 0 go func() { for true { status.SetText(fmt.Sprintf("Time is %d", t)) t++ time.Sleep(time.Second) } }() if err := app.SetRoot(status, true).SetFocus(status).Run(); err != nil { panic(err) } } ```
kerem closed this issue 2026-03-04 01:05:54 +03:00
Author
Owner

@sewnie commented on GitHub (Jul 8, 2023):

what did you do to solve this????!?!?!

<!-- gh-comment-id:1627220906 --> @sewnie commented on GitHub (Jul 8, 2023): what did you do to solve this????!?!?!
Author
Owner

@rivo commented on GitHub (Jul 8, 2023):

There are multiple ways this could be done. Either install a listener on the TextView, see SetChangedFunc. Or simply call app.Draw() in your goroutine.

<!-- gh-comment-id:1627234160 --> @rivo commented on GitHub (Jul 8, 2023): There are multiple ways this could be done. Either install a listener on the `TextView`, see [`SetChangedFunc`](https://pkg.go.dev/github.com/rivo/tview#TextView.SetChangedFunc). Or simply call [`app.Draw()`](https://pkg.go.dev/github.com/rivo/tview#Application.Draw) in your goroutine.
Author
Owner

@sewnie commented on GitHub (Jul 8, 2023):

Using SetChangedFunc with app.Draw froze the application. I am using QueueChangedFunc with the changed text inside it and it works. Thanks.

<!-- gh-comment-id:1627235359 --> @sewnie commented on GitHub (Jul 8, 2023): Using `SetChangedFunc` with `app.Draw` froze the application. I am using `QueueChangedFunc` with the changed text inside it and it works. Thanks.
Author
Owner

@rivo commented on GitHub (Jul 8, 2023):

Can you post the version which froze the application? Either there is a bug or the documentation is wrong. Both cases should be investigated.

<!-- gh-comment-id:1627429036 --> @rivo commented on GitHub (Jul 8, 2023): Can you post the version which froze the application? Either there is a bug or the documentation is wrong. Both cases should be investigated.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#544
No description provided.