Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do widgets update themselves? #18

Open
canack opened this issue Jan 18, 2025 · 2 comments
Open

Do widgets update themselves? #18

canack opened this issue Jan 18, 2025 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@canack
Copy link
Member

canack commented Jan 18, 2025

Do widgets update automatically, or do I need to trigger updates manually?

Copy link

🤖 AI Assistant Analysis

In the Skeleton library, widgets do not update automatically by default; you need to trigger updates manually. The library provides mechanisms to update widget values, but it relies on the developer to call the appropriate methods to refresh the widget content.

Overview

Widgets in the Skeleton framework are designed to display dynamic content, such as system metrics or application state. However, the responsibility for updating these widgets lies with the application logic. You can update widget values using specific methods provided by the Skeleton class.

Updating Widgets

To update a widget's value, you can use the UpdateWidgetValue method of the Skeleton struct. This method checks if the widget exists and updates its value accordingly. If the widget does not exist, it will create a new one.

Example Code

Here’s an example of how to update a widget in the Skeleton framework:

// Assuming 's' is an instance of Skeleton
s.UpdateWidgetValue("time", time.Now().Format("15:04:05"))

In this example, the widget with the key "time" is updated with the current time formatted as a string. This method should be called whenever you want to refresh the widget's content.

Triggering Updates Periodically

If you want to update widgets automatically at regular intervals, you can use a goroutine to trigger updates. For example:

go func() {
    for {
        time.Sleep(time.Second) // Update every second
        s.UpdateWidgetValue("time", time.Now().Format("15:04:05"))
    }
}()

This code snippet creates a goroutine that updates the "time" widget every second, ensuring that the displayed time remains current.

Conclusion

In summary, while widgets in the Skeleton framework do not update automatically, you can easily manage their updates by calling the appropriate methods in your application logic. This gives you control over when and how often the widget content is refreshed, allowing for efficient resource management and responsiveness in your terminal applications.


This analysis was performed by Issue Assistant. If you have any questions, please contact the repository maintainers.

@github-actions github-actions bot added help wanted Extra attention is needed question Further information is requested labels Jan 18, 2025
Copy link

🏷️ AI Label Analysis

I've added the following labels to this issue:

  • question
  • help wanted

Explanation:
The issue is primarily asking for clarification about the functionality of widgets, which aligns closely with the 'question' label. The 'help wanted' label is suggested as it indicates that the issue may require additional attention or input from the community to provide a clear answer.


This label analysis was performed by Issue Assistant. If you have any questions, please contact the repository maintainers.

@termkit termkit deleted a comment from github-actions bot Jan 18, 2025
@termkit termkit deleted a comment from github-actions bot Jan 18, 2025
@termkit termkit deleted a comment from github-actions bot Jan 18, 2025
@termkit termkit deleted a comment from github-actions bot Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant