Can't find any way to change the state of the screen programatically
See original GitHub issueI have the following code:
using Terminal.Gui;
namespace TestConsole
{
public class App : Window
{
private Label _label;
public App() : base("Test Screen")
{
X = 0;
Y = 0;
Width = Dim.Fill();
Height = Dim.Fill();
_label = new Label("this is a label")
{
X = 0,
Y = 0,
Width = Dim.Fill(),
};
this.Add(_label);
}
public void SetNewText(string newText)
{
Application.MainLoop.Invoke(() =>
{
_label.Text = newText;
});
}
}
class Program
{
static void Main()
{
Application.Init();
App _consoleApp = new App();
var runToken = Application.Begin(_consoleApp);
Application.RunLoop(runToken);
_consoleApp.SetNewText("this is a new text");
Application.End(runToken);
}
}
}
The point is to open a screen, and later on, depending on some further processes, I want to update what’s on the screen. But whatever I try doesn’t work. What is done wrong in my example?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Change screen orientation in Android without reloading the ...
I want to change the orientation programmatically while running my Android App, with these lines of code: setRequestedOrientation(ActivityInfo.
Read more >Interact programmatically with the Navigation component
The Navigation component provides ways to programmatically create and interact with certain navigation elements. Create a NavHostFragment.
Read more >How to change the language on Android at runtime and ...
The first place is your “Settings” screen or whatever place you use to change the language in your application. Note that after the...
Read more >How do I make a figure full screen programmatically in ...
Starting in MATLAB R2018a, you can use the "WindowState" property to maximize, minimize, or display a figure in full-screen mode.
Read more >Debugging Flutter apps programmatically
This doc describes debugging features that you can enable in code. For a full list of debugging and profiling tools, see the Debugging...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok, I searched yesterday for ages with no solution, but it seems I simply was in lack of inspiration. Here is how the
App
class should be used:Put also “Thread.Sleep(5000);” before “_consoleApp.SetNewText(“this is a new text”);” and you’ll see the old label text before changed to the new one!