Up | Built-in Python Classes | Scorpion Module | Dialogs | Unsupported Modules

FileOpen | FileSave | InputInt | MessageDlg | SelectDirectory
 

  

 
Dialogs
Some standard dialogs are available from python scripts. These may be used to get user data.
 
Method Returns Description
SelectDirectory(directory[,options=0]) (ok,directory) Shows a directory selection dialog with current selection set to directory parameter.

options - [AllowCreate=1, PerformCreate=2, Prompt=4]

Notes :
PerformCreate is used only in combination with AllowCreate. If the user enters a directory name that does not exist, the directory selection dialog creates it. Prompt is used only in combination with AllowCreate. Displays a message box that informs the user when the entered directory does not exist and asks if the directory should be created. If the user chooses OK, the directory is created if the option set includes PerformCreate. If the option set does not include PerformCreate, the directory is not created.

SelectFileOpen(filename[,filter]) (ok,filename) Shows a file open dialog with current selected file set to filename.
The optional filter parameter enables the user to specify kind of files to view as default. The format of the filter must be "description|mask".
Multiple filters may be given separated by "|".
Examples :
SelectFileOpen('Image.bmp','Bitmaps (*.bmp)|*.bmp')
SelectFileOpen('Image.bmp',''Bitmaps (*.bmp)|*.bmp'|JPEG (*.jpg)|*.jpg')
SelectFileSave(filename[,filter]) (ok,filename) Shows a file save dialog.
The filter and options are described in SelectFileOpen
MessageDlg(msg[,type=2,buttons=4]) Yes=6,
No=7,
OK=1
,
Cancel=2,
Abort=3,
Retry=4,
Ignore=5,
All=8,
NoToAll=9,
YesToAll=10
Shows a message box with given Icon and buttons. The optional type defaults to Info, the buttons may be a set of buttons binary coded due to the enumeration below.

type  - [Warning=0,Error=1,Info=2,Confirmation=3,None=4]
buttons - [Yes=1,No=2,OK=4,Cancel=8,Abort=16,Retry=32,
Ignore=64,All=128,NoToAll=256,YesToAll=512]

Example:
  MessageDlg('ERROR',1,96)
    type = 1 -->Error icon
    buttons = 96 --->Retry=32+Ignore=64
InputInt(caption,prompt[,value]) (ok,value) Shows an input dialog for integer input.
The optional value parameter is the default value
InputFloat(caption,prompt[,value]) (ok,value) Shows an input dialog for float input.
The optional value parameter is the default value
InputStr(caption,prompt[,value]) (ok,value) Shows an input dialog for string input.
The optional value parameter is the default value
StringsDlg(caption,items[,selected]) (ok,selected) Opens a dialog with a list of semicolon separated strings (";"). The optional selection parameter is the default selected string and must be contained in items. Returns selected string if ok
SpbDialog(caption,spbxml) (ok,spbxml) Dialog for editing spbxml strings
PinDialog(pin1,pin2..pinN) (ok,pin) Show a Pin dialog whith multiple pins are allowed. Returns selected pin on ok.
LogonDialog((usr1,usr2,usr3)[,defusr,cancel]) (ok,user,pw) Opens a Logon dialog. Parameters is a tuple of usernames. Optionally a default user and a boolean whether the Cancel  button is visible or not. Returns selected user and the password entered. The password should be explicit evaluated to grant access.
ColorDialog([color='',anycolor=0]) (ok,color) Opens a color selection dialog. Optional default color and any color selection mode. Returns selected color on OK.
FontDialog([font='',size=0,style=0,color='']) (ok,font,size,style,color) Opens a font selection dialog. Returns a fixed size tuple indipendent of optional parameters given.
ImageDialog(name) Form returns a Form object with an image property, see example 7. 


Example 1: Use InputStr

def TestInputStr():
  ok,val=InputStr('Demo - InputStr','Input value','testvalue')
  if ok:
     print 'InputStr returned',val

Example 2: Use StringsDialog

def TestStringsDialog():
  ok,sel=StringsDialog('Demo - StringsDialog', 'Red;Blue;Green;Yellow','Blue')
  if ok:
    print 'The color %s was selected' % sel

Example 3: Use SpbDialog

def TestSpbDialog():
  t=GetTool('Setup')
  ok,cfg=SpbDialog('Demo - SpbDialog',t.config)
  if ok:
    t.config=cfg

Example 4: Use PinDialog - single pin

def TestSpbDialog():
  t=GetTool('Setup')
  ok,cfg=SpbDialog('Demo - SpbDialog',t.config)
  if ok:
    t.config=cfg

Example 5: Use PinDialog - multi pins

def TestPinDialog():
  ok,pin=PinDialog(('1234','911'))
  if ok:
    if pin=='1234':
       print 'you are granted settings access'
    elif pin=='911':
       print 'you are granted service access'

Example 6: Use LogonDialog

def TestLogonDialog():
  ok,usr,pw=LogonDialog(('user1','user2','user3'),'user3',False)
  if ok:
    if (usr=='user1' and pw=='123') or (usr=='user2' and pw=='234') or (usr=='user3' and pw=='456'):
       print '%s is now logged on'%usr
    else:
       print '%s is denied access'%usr

Example 7: Use ImageForm

The sample code is clipped from a DataInput Script Button code
def ScriptButtonClick(Sender,Args):
  #Sender is the clicked button
  #Insert the button handler code
  img=GetImageMatr('Image1')
  if img:
    if GetBoolValue('Register.B1'):
      dec=DecimateMatr(img,(GetFloatValue('Register.S0'),GetFloatValue('Register.S1')))
    else:
      dec=DecimateMatr(img,GetFloatValue('Register.S0'))
    dlg=ImageForm()
    dlg.caption='Decimated image'
    dlg.overlay.addText('txt1','Decimated Image1').textSize=14
    dlg.image=dec
    dlg.showModal()

 

More Examples: 

FileOpen
FileSave
InputInt
MessageDlg
SelectDirectory

 


Scorpion Vision Version XV  : Build 764 - Date: 20200529
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2020 Tordivel AS.