Winforms with dynamo



Good day dears,
i’m trying to learn winforms using python in dynamo to achieve project idea.
the idea that i have 2 inputs:

  • one with changed number values … here in this example i use days name, i shall choose from them using CheckBox
  • the other one with 2 constant value like true false … here in this example i use ( week1, week2), i shall use Radio Button to choose between them

the output must be 2 list , the result from 2 inputs

i have tried to do it , but it keeps give warnings

if anybody could help please

the window should be somthing like this , but with one button


the code :

  import clr

  from System.Windows.Forms import Application, Form, StatusBar
  from System.Windows.Forms import RadioButton, GroupBox, CheckBox, Label, 
  Button, AnchorStyles, DockStyle, PictureBox, PictureBoxSizeMode, TextBox
  from System.Windows.Forms import TrackBar, TickStyle
  from System.Drawing import Size, Point, Font, Color, Image

in1 = IN[0]

class IForm(Form):

def __init__(self):

	self.checkval = []
	self.output1 = []
	self.output2 = []
	self.Font = Font("Arial",12)
	self.BackColor = Color.White
	self.label = Label()
	self.label.Text = "Choose"
	self.label.Location = Point(25, 100)
	self.label.Height = 25
	self.label.Width = 225
	self.label.Font = Font("OpenSans",12)

	for i in range(len(in1)):
	   self.checkbox = CheckBox()
	   self.checkbox.Location = Point(25,j)
	   self.checkbox.Width = 200
	   self.checkbox.Font= Font("OpenSans",10)
	self.button1 = Button()
	self.button1.Text = 'apply and close'
	self.button1.Location = Point(25, j+50)
	self.button1.Click += self.update
	self.button1.Width = 250

	self.AcceptButton = self.button1

	self.AutoSize = True
	gb = GroupBox()
    gb.Text = "Week"
    gb.Size = Size(120, 110)
    gb.Location = Point(20, 20)
    gb.Parent = self

    week1 = RadioButton()
    week1.Text = "Week 1"
    week1.Parent = gb
    week1.Location = Point(10, 30)
    week1.CheckedChanged += self.OnChanged

    week2 = RadioButton()
    week2.Text = "week2"
    week2.Parent = gb
    week2.Location = Point(10, 60)
    week2.CheckedChanged += self.OnChanged
def OnChanged(self, sender, event):
    if sender.Checked:

def update(self, sender, event):
	for f in self.checkval:

form = IForm()
OUT = form.output1, form.output2


first, use the same method for indention, dont mix blank spaces and tabulator. PEP8 recommends to use blank spaces instead of tabulator (many IDE’s use 4 blank spaces for indention).

after a class is introduced you need to indent the definitions belonging to the class.

class IForm(Form):
    def __init__(self):
        self.checkval = []
        self.output1 = []
        self.output2 = [] (2.5 KB)


Dear @erfajo ,
that’s a good advises i should follow and take , really appreciate for your help
thank you


maybe that will answer your questions:


thanks you @Peter_Kompolschek
this website is addition useful source to learn from


have you taked a look in this dynamo packaged?