I’d like to change the button to read something other than, ‘close’.
How do I do this?
The API docs say
// Set common buttons and default button. If no CommonButton or CommandLink is added,
// task dialog will show a Close button by default
mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
mainDialog.DefaultButton = TaskDialogResult.Close;
Data shapes is written in Python and all open for viewing in the nodes. Given the main input form node goes over 1k lines of code I’d say it’s a teensy bit complicated.
Might be worth looking into pyRevit if you’re going down the Python route. Ehsan provides some great forms to use by default which have customizable button names and outputs:
Here is simple example of a CPython3 Winform with outputs within the Dynamo Core environment to get you going. I have commented the code so you are able to follow what each part is doing, and so can figure out in what direction you might be looking to investigate your UI choices further.
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Drawing import *
from System.Windows.Forms import *
from System import Array, Object
class SimpleForm(Form):
def __init__(self):
# The text to show in the top bar
self.Text = "A Simple Form"
# The width of the form in pixels
self.Width = 250
# The height of the form in pixels
self.Height = 240
# Make the form a fixed size
self.FormBorderStyle = FormBorderStyle.FixedDialog
# Position the form in the center of the screen
self.StartPosition = FormStartPosition.CenterScreen
# Bring the form to the front of all windows
self.TopMost = True
# Show top bar controls
self.ControlBox = True
self.MaximizeBox = False
self.MinimiseBox = True
# Add a button
self.button1 = Button()
# Set the button text
self.button1.Text = 'Value 1'
# Define what happens when you click the button
self.button1.Click += self.save
# Set the button width
self.button1.Width = 100
# Set the button height
self.button1.Height = 180
# Set the button location offset from the top left form pixel
self.button1.Location = Point(10,10)
# Set the background color for the button
self.button1.BackColor = Color.Green
# Add the button the form
self.Controls.Add(self.button1)
# Add another button
self.button2 = Button()
# Set the button text
self.button2.Text = 'Value 2'
# Define what happens when you click the button
self.button2.Click += self.save2
# Set the button width
self.button2.Width = 100
# Set the button height
self.button2.Height = 180
# Set the button location offset from the top left form pixel
self.button2.Location = Point(120,10)
# Set the background color for the button
self.button2.BackColor = Color.Red
# Add the button the form
self.Controls.Add(self.button2)
# Define what happens when you click the button
def save(self, sender, event):
self.output = "Output chosen was Value 1";
# Close the form
self.Close();
# Define what happens when you click the other button
def save2(self, sender, event):
self.output = "Output chosen was Value 2";
# Close the form
self.Close();
runMe = IN[0]
if runMe:
# Create the form
form = SimpleForm()
# Run the form
Application.Run(form)
# Get the output of the form
OUT = form.output
else:
OUT = "Set RunMe to True";