Get outputs of IronPython live in C#(WPF)?

Juliette 1 Reputation point
2022-10-05T15:19:44.157+00:00

I am developing an app in C# WPF. The app should call Python scripts. I use IronPython for this. Unfortunately I have some difficulties. I don't get the prints from Python displayed live.

Is it possible to display the output of Print live in TextBox(like in Python IDE)?

namespace PythonCall  
{  
    public class MainViewModel : BaseViewModel  
    {  
        public string PyOutput { get; set; }  
        public RelayCommand Cmd { get => new RelayCommand(Exec); }  
        private void Exec(object parameter)  
        {  
            switch (parameter.ToString())  
            {  
                case "Start":  
                    try  
                    {  
                        ScriptConfig();  
                        OnPropertyChanged(nameof(PyOutput));  
                    }  
                    catch (Exception ex)  
                    {  
                        MessageBox.Show(ex.Message);  
                    }  
                    break;  
  
                default:  
                    break;  
            }  
        }  
        public void ScriptConfig()  
        {  
             
        }  
    }  
}  

The variable "PyOutput" is prepared for this and this is the binding to TextBox.

Any help is appreciated

Developer technologies Windows Presentation Foundation
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.