Still widgets, so why remains this "run" empty?

Hello,

so i want a window with colors inside … actually i have no error BUT also no window!

import clr
import sys

clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Application, Form, Label, DockStyle, Panel, FlowLayoutPanel

class Color(Panel):
    def __init__(self, color):
        super(Color, self).__init__()
        self.BackColor = System.Drawing.Color.FromName(color)
        self.Dock = DockStyle.Left

class MainWindow(Form):
    def __init__(self):
        self.Text = "My App"
        self.Width = 300
        self.Height = 100

        layout = FlowLayoutPanel()
        layout.FlowDirection = FlowDirection.LeftToRight

        layout.Controls.Add(Color("red"))
        layout.Controls.Add(Color("green"))
        layout.Controls.Add(Color("blue"))

        self.Controls.Add(layout)

if __name__ == "__main__":
    app = Application()
    window = MainWindow()
    app.Run(window)


#a = MainWindow()
#a.Show()

OUT = "Test"

KR

Andreas

the first if you want use FlowDirection you need call menthod of FlowLayoutPanel() and have not properties LeftToRight.

layout.FlowDirection = FlowLayoutPanel.FlowDirection

I dont know why you set BackColor of Form but this is example with short code:

import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
import System.Drawing
import System.Windows.Forms
from System.Drawing import *
from System.Windows.Forms import *

class MainWindow(Form):
    def __init__(self):
        self.Text = "My App"
        self.Size = Size(500, 350)
        #
        self.Red = RadioButton()
        self.Red.Text = "Red"
        self.Red.Location = System.Drawing.Point(100, 100)
        self.Red.CheckedChanged += self.RedCheckedChanged
        #
        self.Green = RadioButton()
        self.Green.Text = "Green"
        self.Green.Location = System.Drawing.Point(250, 100)
        self.Green.CheckedChanged += self.GreenCheckedChanged
        #
        self.Blue = RadioButton()
        self.Blue.Text = "Blue"
        self.Blue.Location = System.Drawing.Point(400, 100)
        self.Blue.CheckedChanged += self.BlueCheckedChanged
        #
        self.Controls.Add(self.Red)
        self.Controls.Add(self.Green)
        self.Controls.Add(self.Blue)
        #
    def RedCheckedChanged(self,sender,e):
        self.BackColor = System.Drawing.Color.FromName("Red")
    def GreenCheckedChanged(self,sender,e):
        self.BackColor = System.Drawing.Color.FromName("Green")
    def BlueCheckedChanged(self,sender,e):
        self.BackColor = System.Drawing.Color.FromName("Blue")


window = MainWindow()
Application.Run(window)

Why? It’s nice to have different colours?