What's new

WizoScript Problem

albie0803

Alibre Super User
I am trying to add DropDown lists to an existing script.

The IF...Else on line 70 is not working.

The dialog box at 60 returns the correct value chosen but 70 doesn't seem to use it.

Where have I gone wrong?

Code:
import glob
import os
import re
 
# default value to show
DefaultProcess = 'Hot'
DefaultLength = 100
DefaultWidth = 75
Extrude = 0
HorC = ' '
Length = 0
Width = 0
Extrude = 0
 
# called when an input changes in the dialog window
def InputChangedP(Index, Value):
  # size changed
  if Index == 0:
    HorC = ProcessNames[Value]
    print HorC

def InputChangedLH(Index, Value):
  # size changed
  if Index == 0:
    Length = HLengthNames[Value]
    print Length

def InputChangedLC(Index, Value):
  # size changed
  if Index == 0:
    Length = CLengthNames[Value]
    print Length

# called when user confirms selections
def SelectionMadeP(Values):
  # get values
  HorC = ProcessNames[Values[0]]
  print HorC
 
def SelectionMadeLH(Values):
  # get values
  Length = HLengthNames[Values[0]]
  print Length

def SelectionMadeLC(Values):
  # get values
  Length = CLengthNames[Values[0]]
  print Length

# get access to windows functionality
Win = Windows()
 
# list of values to choose from
ProcessNames = ['Hot', 'Cold']
HLengthNames = ['50', '60', '76.2', '80', '90', '100', '120', '140', '150', '160']
CLengthNames = ['40', '50', '60', '70', '80', '90', '100', '120', '140', '150', '160']

# create dialog window
Options = []
Options.append(['Process', WindowsInputTypes.StringList, ProcessNames, DefaultProcess])
 
# show dialog window to user
DialogWidth = 100
Win.UtilityDialog('RHS Type', 'Apply', SelectionMadeP, InputChangedP, Options, DialogWidth)

index = 0

Options = []

if HorC == 'Hot':
    Options.append(['Hot RHS', WindowsInputTypes.StringList, HLengthNames, DefaultLength])
    Win.UtilityDialog('Length', 'Apply', SelectionMadeLH, InputChangedLH, Options, DialogWidth)
else:
    Options.append(['Cold RHS', WindowsInputTypes.StringList, CLengthNames, DefaultLength])
    Win.UtilityDialog('Length', 'Apply', SelectionMadeLC, InputChangedLC, Options, DialogWidth)
 

ajayre

Alibre Super User
The utility dialog is like a tool - it only returns from the function call when the user closes the window. This allows an operation to be performed over and over again. Because of this it works on callbacks. See this example: http://www.wizotools.com/category/scripts/
Note the use of the SelectionMade function.

From what you have done so far it seems you might be better off using the OptionsDialog instead? That is designed to capture user inputs before proceeding with the script.

Andy
 
Top