What's new

Example of all WindowsInputTypes for an OptionsDialog

NateLiqGrav

Alibre Super User
Here is a script with all the WindowsInputTypes for an OptionsDialog.
WindowsInputTypes.Url took a little bit of trial and error for its format but I figured it out.

Also includes getting/assigning indexes dynamically to use them for value checking and disabling/DoNotDisable.

Code:
ScriptName = 'Test Window'

print("\n"*20) # lazy mans clear console

Win = Windows()

# called when an input changes in the dialog window
def InputChanged(Index, Value):
    print("You changed index %s!" %Index)
    # do things here depending on value
    if Index == Index_Boolean:
        print("You changed Boolean Value to %s!" %Value)
    UpdateUserInterface()


# updates the user interface based on the current selections made
def UpdateUserInterface():
    for i in range(len(Options)):
        if i not in DoNotDisable:
            Win.DisableInput(i)
            pass


# define options to show in dialog window
Options = []
DoNotDisable =[]

Options.append(['String', WindowsInputTypes.String, 'String'])

Options.append(['Integer', WindowsInputTypes.Integer, 0])

Options.append(['Real', WindowsInputTypes.Real, 0.0])

Options.append(['Boolean', WindowsInputTypes.Boolean, True])
DoNotDisable.append( len(Options)-1) # add this boolean to the DoNotDisable list to test it
Index_Boolean = len(Options) -1 # get the index of the previous item appended even if you put more above it

Options.append(['Face', WindowsInputTypes.Face, None])

# Options.append(['Faces', WindowsInputTypes.Faces, None]) # commented out simply because the window got too big

Options.append(['Plane', WindowsInputTypes.Plane, None])

# Options.append(['Planes', WindowsInputTypes.Planes, None]) # commented out simply because the window got too big

Options.append(['Edge', WindowsInputTypes.Edge, None])

# Options.append(['Edges', WindowsInputTypes.Edges, None]) # commented out simply because the window got too big

Options.append(['Vertex', WindowsInputTypes.Vertex, None])

# Options.append(['Vertices', WindowsInputTypes.Vertices, None]) # commented out simply because the window got too big

Options.append(['Point', WindowsInputTypes.Point, None])

# Options.append(['Points', WindowsInputTypes.Points, None]) # commented out simply because the window got too big

Options.append(['Axis', WindowsInputTypes.Axis, None])

# Options.append(['Axes', WindowsInputTypes.Axes, None]) # commented out simply because the window got too big

Options.append(['Sketch', WindowsInputTypes.Sketch, None])

# Options.append(['Sketches', WindowsInputTypes.Sketches, None]) # commented out simply because the window got too big

Options.append(['Sketch3D', WindowsInputTypes.Sketch3D, None])

Options.append(['File', WindowsInputTypes.File, 'File Path including Name Here'])

Options.append(['Label', WindowsInputTypes.Label, 'Label'])
DoNotDisable.append( len(Options)-1) # must add all Labels to the DoNotDisable list or you get an error

Options.append(['SaveFile', WindowsInputTypes.SaveFile, 'SaveFile Path including Name Here'])

mystringlist = ["test","this",'list']

Options.append(['StringList', WindowsInputTypes.StringList, mystringlist])

Options.append(['Image', WindowsInputTypes.Image, 'MaxCellSize.jpg', 170])

myURL = ['Click Here!','https://www.google.com/', int('0000ff',16)] # first the text to display, then the url, then a hexidecimal rrggbb color converted into an integer
Options.append([None, WindowsInputTypes.Url, myURL])
DoNotDisable.append( len(Options)-1) # must add all Urls to the DoNotDisable list or you get an error

Options.append(['Folder', WindowsInputTypes.Folder, 'Folder Path Here'])

# show dialog to user, get inputs
Values = Win.OptionsDialog(ScriptName, Options, 200, InputChanged, UpdateUserInterface)

if Values == None:
    print("Canceled... Exiting.")
    sys.exit()
# other error checking and program here
 

albie0803

Alibre Super User
Well done, very useful.

Note: you will need to save a pic as MaxCellSize.jpg in the same folder you save the script to before you run it or it will throw an error.
 
  • Like
Reactions: MKR

NateLiqGrav

Alibre Super User
Yes. You can save the script in the Examples folder - that's where the image MaxCellSize.jpg was from.
 
Top