Hi, I’m trying to make a dynamo-script showing a info-table in revit as a “popo-up” text-box. I have used the following code, which work, but as the font is not monospaced, it looks terrible. I would like to change the font to a monospace font, but I don’t know how.
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Drawing import Point
from System.Windows.Forms import Application, Button, Form, Label, TextBox
IO_liste= IN[0]
max_letters = [None]*len(IO_liste)
IO_liste_string = ""
for j in range(len(IO_liste)) :
max_letters[j] = len(max(IO_liste[j], key=len))+2
transposed_table = zip(*IO_liste)
for i in range(len(IO_liste[0])) :
for j in range(len(IO_liste)) :
f = '{0:<%s}' % (str(max_letters[j]))
IO_liste_string += f.format((IO_liste[j][i]))
IO_liste_string += "\n"
class SimpleTextBoxForm(Form):
def __init__(self):
self.Text = "Simple TextBox Example"
self.Width = 1000
self.Height = 800
self.label = Label()
self.label.Text = IO_liste_string
self.label.Location = Point(25, 25)
self.label.Height = 500
self.label.Width = 800
self.textbox = TextBox()
self.textbox.Text = "The Default Text"
self.textbox.Location = Point(25, 75)
self.textbox.Width = 150
self.button1 = Button()
self.button1.Text = 'Press Me'
self.button1.Location = Point(25, 125)
self.button1.Click += self.update
self.button2 = Button()
self.button2.Text = 'Reset'
self.button2.Location = Point(125, 125)
self.button2.Click += self.reset
self.AcceptButton = self.button1
self.CancelButton = self.button2
self.Controls.Add(self.label)
self.Controls.Add(self.textbox)
self.Controls.Add(self.button1)
self.Controls.Add(self.button2)
def update(self, sender, event):
self.label.Text = self.textbox.Text
def reset(self, sender, event):
self.label.Text = "Nothing So Far"
self.textbox.Text = "The Default Text"
form = SimpleTextBoxForm()
form.ShowDialog()
screenshot of output of above:
image
And yes, I am aware that there is some problems regarding layout on the form, and placement of the buttons etc. Thats not the problem:slight_smile: