Bold and coloured text in pop-ups

Is it possible via Dynamo and Python to get bold + coloured text in a pop-up window?

For the built-in Revit dialogs, I don’t believe so.

However, you could explore creating your dialog with Windows Forms or WPF. (Similar to data-shapes)

1 Like

I thought that was probably going to be the answer.

I’m going to go sulk until my C# gets better. :frowning:

This post has some guidance on how to do it in python:


Also, if you are simply wanting to draw more attention to your dialog, the Revit dialogs offer a few icons.

Basically I’ve written a new script that’s a little different from our usual format so I wanted to include a couple of very simple examples in one of the warning pop-ups.

I thought it’d be fun/ useful to make the text, Examples: bold.

1 Like

So you can install visual studio community and start making windows that are pretty much a copy paste into python.

Would result in this:

Admittedly, this is one of the first times I have interacted with WPF in python, but it is pretty neat!


Ooooo! Took me ages to get the basic pop-ups to work in Dyno so I’ve avoided anything scarier. Now I’m going to have to look at this! :grinning:

They seem way easier in C# from what little I’ve done.

Don’t suppose you know if it’s easier in R23?

I don’t believe Revit2023 has any extra ease to it. If anything it is more difficult because you have to reference the IronPython package to load those libraries.

But surely the functionality of Py3 is better and gives you access to more stuff?

To my understanding CPython3 eliminates the ability to use WPF and windows forms in their current state.

(I might be and hope I am wrong, cc @jacob.small )

1 Like

For completeness, here is what I mocked up real quick in visual studio: :slight_smile:

I encourage you to get VS Community installed and start having a play!

Python Code:

import clr	
import sys
import System
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\DLLs')

except IOError:
from System.IO import StringReader
from System.Windows.Markup import XamlReader, XamlWriter
from System.Windows import Window, Application

	import wpf
	import time
except ImportError:
class CreateWindow(Window):
	LAYOUT = '''
             Height="140" Width="400"
            <RowDefinition Height="*"/>
            <RowDefinition Height="36"/>

<TextBox Name="MessageBox" Grid.Row="0" Margin="8" Text="A" TextWrapping="Wrap" Foreground="Red" BorderBrush="{x:Null}" IsHitTestVisible="False"/>

<!--the buttons section-->
        <Grid Grid.Row="1" Background="LightGray">
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            <Button Grid.Column="2" Content="Close" Margin="8 4" IsCancel="True"/>
	def __init__(self):
		self.ui = wpf.LoadComponent(self, StringReader(CreateWindow.LAYOUT))
		self.Title = IN[0]
		self.MessageBox.Text = IN[1]
pb = CreateWindow()

OUT = pb.MessageBox.Text

Had VS for a while… but Dynamo screen is so much more relaxing :smiley:

BUT now you’ve offered me colours I cannot say no! :star_struck:

1 Like

That works in R23 but not R21.

So maybe new python is nicer after all :smiley:

1 Like

Hmm, that is interesting. I did use the code supplied in that thread for the imports and everything though and didn’t test in older versions

Looks like you are correct. I’m watching the IronPython3 development pretty closely as that will solve a lot of the issues if it gets ported in.

Edit: Handy info for running WPF from IronPython where threading isn’t locked by Revit/Civil/whatnot: Python Dispatcher Threads - #2 by Mark.Ackerley

1 Like