How to edit the startup data with forms

Hello, I was trying to edit the initial input with the use of forms but it has not worked for me, in addition to them I think that the text can be generated quickly but how would it be if I needed to select object in the forms

Offset.dyn (21.3 KB)

image

@Kulkul @AmolShah @c.poupin
Excuse any ideas, I think you are the ones who know the most about this?

@Christhian
I am not sure to understand the goal what you want, but you can try this

import sys
import clr
import System
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Drawing import Point
from System.Windows.Forms import Application, Button, Form, Label, TextBox

class SimpleTextBoxForm(Form):
    def __init__(self, value):
        self._valueInit = value

        self.Width = 220
        self.Height = 200

        self.textbox = TextBox()
        self.textbox.Text = self._valueInit
        self.textbox.Location = Point(25, 25)
        self.textbox.Width = 150

        self.textbox1 = TextBox()
        self.textbox1.Text = self._valueInit
        self.textbox1.Location = Point(25, 55)
        self.textbox1.Width = 150

        self.button1 = Button()
        self.button1.Text = 'Press Me'
        self.button1.Location = Point(25, 125)
        
        self.AcceptButton = self.button1

        self.Controls.Add(self.textbox)
        self.Controls.Add(self.textbox1)
        self.Controls.Add(self.button1)
        
        self.values = []
        self.button1.Click += self.update

    def update(self, sender, event):
        for control in self.Controls:
            if isinstance(control, TextBox):
              self.values.append(control.Text)
        self.Close()

form = SimpleTextBoxForm(IN[0])
form.ShowDialog()

OUT = form.values

@c.poupin
I want the forms to work like the dynamo player, like the dynamo player inputs which I can modify without the need to enter the editor.
Maybe with an image you can understand me, I really appreciate your answer.

Look into the Data-Shapes package. It has a bunch of UI nodes already created and works really well for this sort of thing.

Here is an example
TestUIWinform

import sys
import clr
import System
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Drawing import Point
from System.Windows.Forms import Application, Button, Form, Label, TextBox

class SimpleTextBoxForm(Form):
    def __init__(self, valueA, valueB):
        self._valueInitA = str(valueA)
        self._valueInitB = str(valueB) 

        self.Width = 220
        self.Height = 200

        self.textbox = TextBox()
        self.textbox.Text = self._valueInitA
        self.textbox.Location = Point(25, 25)
        self.textbox.Width = 150

        self.textbox1 = TextBox()
        self.textbox1.Text = self._valueInitB
        self.textbox1.Location = Point(25, 55)
        self.textbox1.Width = 150

        self.button1 = Button()
        self.button1.Text = 'Press Me'
        self.button1.Location = Point(25, 125)
        
        self.AcceptButton = self.button1

        self.Controls.Add(self.textbox)
        self.Controls.Add(self.textbox1)
        self.Controls.Add(self.button1)
        
        self.values = []
        self.button1.Click += self.update

    def update(self, sender, event):
        for control in self.Controls:
            if isinstance(control, TextBox):
              self.values.append(control.Text)
        self.Close()

form = SimpleTextBoxForm(IN[0], IN[1])
form.ShowDialog()

OUT = form.values
2 Likes

@c.poupin
thanks works very well