Howdy pyRevit folks!
I’m currently working on a pyRevit script that reads a checklist from .xlsx file and formats/outputs it to a
forms.SelectFromLIst object/thingy (thats the correct verbiage right?). The little hiccup that I’m facing right now is that unlike the form only having a checked/unchecked state, there are several states that an item can be in the checklist (i.e. completed, WIP, N/A, Further Discussion).
Has anyone messed with
SelectFromList before where instead of there being a checkbox next to the item, its a dropdown? I’m assuming that at the end of the day I’ll have to venture into the relm of making my own GUI with XAML (have not done that before), but I figured I’d ask first.
The forms.SelectFromList object/thingy is indeed a windows form , a wpf form to be precise.
As far as I know the pyrevit SelectFromList is not flexible enough to allow for dropdowns inside the list sooo yeah… you are going to have to go and create your own form and xaml file.
For me it was a bit of a pain to get into without any formal training but in the end I managed. I’ve experienced that working with wpf can be a bit of a hit or miss. I mean… it is well designed, but the interaction with python sometimes requires a bit more work.
My first tip would be to check how pyrevit creates that SelectFromList form it’s a great example on how ironpython works with WPF
Second tip: (if possible) Name your xaml elements using the
x:Name property. By doing that your can access them directly in your form. For instance if you name your element ok_button, you can access it in your form using self.ok_button.
Third tip would be: CATCH EVERY EXCEPTION in your own Form. Especially when you’re starting to react to user events like button pushes. Raising exceptions in regular functions in your form will probably just propagate their error to the output window. However, if an event function is throwing in error, it will propagate PAST the output window and your process untill it reaches the top. (in other words it will kill your revit process).
If you have more questions feel free to ask, however I might take some time for me to respond.
Thanks for the feedback! I’ve been spending the day crawling around the source code for SelectFromList and geeze is it a doozy. Going from zero to creating something like that is a bit of a jump heh. We’ll see what I end up doing though.
I would look into using revit python wrapper for this. Something like:
# create RPW input FlexForm
FlexFormComponents = [Label("Catégorie"),
CheckBox("ch_option_clear", "Clear source param", default=False),
uInput = FlexForm("Configurer la copie entre params", FlexFormComponents)# returns a FlexForm object.
wow I’ve never heard of this flexform thing I’ll look into that