0

Can you tell me, please, what is more correct way to use Python in conjunction with C# WPF? I have come across many Python implementations and I confused about them. I can not understand the implementation of even the simplest, for example, entering a value into the Label by clicking a button using Python:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="9*" />
        <RowDefinition Height="2*" />
    </Grid.RowDefinitions>
    <Button x:Name="btn1" Grid.Row="1" Width="200" Height="30" Content="Click" Click="btn1_Click"/>
    <Label x:Name="lbl1" Grid.Row="1" Width="200" Height="30" Margin="79,23,513,23" Content="Nothing..." />  
</Grid>

Button's code:

private void btn1_Click(object sender, RoutedEventArgs e)
    {
        
            ScriptEngine engine = Python.CreateEngine();
            var a = engine.Execute("print('hello world')");
            lbl1.Content = a;
      
    }

Can you tell me about IronPython or .NET Python and C# WPF + Python?

Best wishes.

Dovee
  • 1

1 Answers1

0

here you can find a lot of data about WPF + IronPython: https://livebook.manning.com/book/ironpython-in-action/chapter-9/20 , you can find there examples and different uses for IronPython in c# wpf

R3tr0
  • 50
  • 8