How to get this widget?

Hello,

AI is not helping me well… :wink: how to run this window

import clr
clr.AddReference('DynamoCore')
from Dynamo.Graph.Nodes import *

clr.AddReference("PresentationFramework")
from System.Windows import Application, Window, Thickness
from System.Windows.Controls import ComboBox

class MainWindow(Window):
    def __init__(self):
        self.Title = "My App"
        self.Width = 200
        self.Height = 100
        self.Padding = Thickness(10)

        self.widget = ComboBox()
        self.widget.Items.Add("walls")
        self.widget.Items.Add("Floors")
        self.widget.Items.Add("Columns")
        self.widget.Items.Add("Roofs")

        self.widget.SelectionChanged += self.index_changed

        self.Content = self.widget

    def index_changed(self, sender, e):
        return (self.widget.SelectedIndex)

# Dynamo entry point
def RunScript():
    app = Application.Current
    if app is None:
        app = Application()
    window = MainWindow()
    app.Run(window)

OUT = "Script completed."

at least i have no error

grafik

KR

Andreas

You haven’t actually implemented anything. You only have definitions and the output string. Try running RunScript().

2 Likes


thanks, thats a starting point!

i have just bridge the gap to a collector a.s.o…

KR

Andreas

1 Like

@Nick_Boyts ,

oh there is one sideaffect revit closes with closing the window!

how to avoid that?

KR

Andreas

@Nick_Boyts ,

i solved it better this way!

a = MainWindow()
a.Show()
2 Likes