Necrosis
Necrosis

Reputation: 23

Is there a winforms designer for python?

So I was just wondering if there was a winforms editor like this for python?

I saw that iron python exists but I doesn't have a visual editor It's just text...

Image that shows what I am looking for:

Image that shows what I am looking for

Upvotes: -1

Views: 5533

Answers (2)

Miguel Dia
Miguel Dia

Reputation: 1

Try sharpdevelop here https://sharpdevelop.software.informer.com/5.1/. The product seems to be frozen, but it has a built-in form designer and allows you to use both C# and Iron Python**

Upvotes: 0

Reza Aghaei
Reza Aghaei

Reputation: 125332

You can use either of the following options:

Example - Pass parameter from Windows Forms UI to a Python function

Here is an example of using IronPython in a C# Windows Forms app:

  1. Create a Windows Forms application.

  2. Install IronPython nuget package.

  3. Add using IronPython.Hosting; statement to the using statements.

  4. Drop a TextBox on the form (textBox1)

  5. Drop a Button on the form (button1)

  6. Double click on button and add the following code for the click handler:

    private void button1_Click(object sender, EventArgs e)
    {
        var engine = Python.CreateEngine();
        var scope = engine.CreateScope();
        //You can also load script from file
        var source = engine.CreateScriptSourceFromString(
            "def hello(name):" + "\n" +
            "    result = 'Hello, {}!'.format(name)" + "\n" +
            "    return(result)",
            Microsoft.Scripting.SourceCodeKind.Statements);
        var compiled = source.Compile();
        compiled.Execute(scope);
        dynamic hello = scope.GetVariable("hello");
        var result = hello(textBox1.Text);
        MessageBox.Show((string)result);
    }
    
  7. Press F5 to Run the application, enter a text, and click on the button. The function will run and you will see a message box saying hello.

Example source code

You can download or clone the example:

Upvotes: 2

Related Questions