SyWin Reference

< Previous | Contents | Manuals Home | Boris FX | Next >

focal length and plate width. The focal length and plate width must have the same (arbitrary) units.


SyWin Reference

The SyWin class encapsulates windows and controls within SynthEyes, so that you can click buttons, select options, etc, operating the user interface by remote control. Wherever possible, you should try to directly access and change the scene through SyObj accessors, rather than trying to make the user interface dance around like a crazy puppet.

SyWin objects are created using Main(), Popup(), and Floating() in SyLevel, which access top- level windows. The methods of SyWin let you locate the subwindows you need to control SynthEyes. By design, these functions allow you to control what SynthEyes does, what a user can do, not do arbitrary things to the SynthEyes windows that the underlying program will not support.

You may find the following piece of Python code helpful (or call hlev.Main().Dump()):

for w in hlev.Main().BreadthFirst(): print w.Name(), w.Class(), w.ID()

It prints out the name, window class, and ID of every window in SynthEyes's main window, using recursive descent. While many windows can be reliably picked out by name, sometimes you may need to identify the ID once by hand, then use ByID to locate it in code.

Important : Be aware that SyWin window references can become invalid, typically when the window is closed, the panel containing it is changed, or the viewport configuration has changed. If this is a possibility, use IsValid() to verify the window reference. Operating on invalid windows may crash SynthEyes, especially on Mac OS X.

Some routines come in AndWait and AndContinue versions:

If an operation is short and does not open additional dialogs, or the user must handle any additional operations, you can use the AndWait version. The python interpreter will be locked until the ...AndWait routine finishes.

Use the AndContinue version when python must not be locked, so that you can execute additional code to script out additional dialogs that appear. Be aware that your next python operation might occur before the previously-launched operation has had a chance to be effective.

Usage note: When using SyWin, you are controlling values with user values. For example, angles are in degrees, as are SyObj attributes. In the scene data store, values are in radians. Accessed through SyWin, position coordinates will have been swizzled to the user-selected axis ordering, whereas SyObj values are in the user's ordering unless it has been overridden to some other ordering, and internally the scene store is always Z-up.

Debugging note: popup windows are minimized when another application is active. If you are running a python interpreter by hand, you may need to put a small time.sleep in front of windows commands and re-activate the SynthEyes application by hand before the command activates, so that the popups are in the proper state.

Name() The name of any kind of window, ie the text on the title bar, in a button, a spinner, an edit control, a selector, etc

SetName(newnm) Changes the name or text value of the window to the specified name. DANGER : Use with extreme care.

Changing the value of a spinner or edit field this way will not activate the portions of the program that normally respond to such changes, so the control may show the new value without the underlying scene being affected. Whenever possible, use a SyObj.Set(), SetOption, SetSpinner, etc to make a change.

ID() The window ID of a control, a small integer. This is the best identifier for a window, if it has one.

Class() The class name of the window. Note that classes may differ between PC and Mac, especially DIALOG vs #32770

HWND() Return the window identifier (16 character string)

IsValid() Returns 1 if this SyWin is an actual still-alive window

IsEnabled() Returns 1 if the window is enabled. There is no SetEnabled by design!

Parent() The window's parent

FirstChild() The window's first child, if any

Next() The window's next sibling, which can be used to enumerate all the windows at a given level, used in Children()

Child(nth) The nth child of this window. Use IsNull to stop

Children() An enumerator for all the window's children

BreadthFirst() Returns a breadth-first enumeration of this window and all its children as a list. This window is the first element.

DepthFirst() Returns a depth-first enumeration of this window and all its children as a list. This window is the last element.

ByClass(cls) Find the first child window with this class. Recursive.

ByName(nm) Find the first child window with this name. Recursive.

ByID(id) Find the first child window with this ID. Recursive.

CloseAndWait() Close this window, wait out any required actions to do that, including new dialogs being closed, etc. Do not call Close on dialogs that have no close button on their title bar, click the appropriate button instead.

CloseAndContinue() Start closing this window, return immediately so Python

has a chance to control any subsequent dialogs directly.

Do not call Close on dialogs that have no close button on their title bar, click the appropriate button instead.

ClickAndWait() Click this button, wait for any resulting activities to finish.

Useful for plain buttons, checkboxes, radio buttons.

ClickAndContinue() Click this button, continue immediately.

PerformActionByNameAndWait(nm) Send the action to this window (a viewport) to

simulate right-click menu operations. Use .ByID().Click...() for button actions.

PerformActionByNameAndContinue(nm) Send the action to this window, ie to the viewports

to simulate right-click menu operations. Use

.ByID().Click...() for button actions.

PerformActionByIDAndWait(idno) Send the action to this window (a viewport) to

simulate right-click menu operations. Use .ByID().Click...() for button actions.

PerformActionByIDAndContinue(idno) Send the action to this window (a viewport) to

simulate right-click menu operations. Use .ByID().Click...() for button actions.

IsChecked() Returns 0/1/2 as this checkbox, radiobutton, or button is unchecked/checked/indeterminate.

SetChecked(val) Set the checkbox or radiobutton to the given state by clicking it if necessary.

OptionCount() For a dropdown selector or multi-option button, the number of options.

OptionText(n) The text of the n'th choice of a dropdown selector.

OptionNo() The currently-selected option number of a dropdown selector or button or image preprocessor tab selector.

Option() The text of the currently-selected option

SetOptionNo(n) Select the given option number of a dropdown selector or multi-option button or image preprocessor tab selector.

SetOption(txt) Select the option with this text

EditValue() Text value of an editor (Edit, REdit) field, equivalent to Name()

SetEditValue(txt) Change the text value of an editor field, notifying the rest of

SynthEyes about it correctly. Preferably, use a SyObj attribute instead.

SpnValue() The numeric value of a spinner. Note that textual labels are not part of the spinner, they are separate windows. So you will need to identify spinners originally by value and record the ID. Preferably, use a SyObj attribute instead.

SetSpnValue(val) Set the spinner's value and notify the rest of SynthEyes

correctly. The value is clipped against the spinner's acceptable range. Always use SyObj attributes to change values when possible.

Dump() Prints a recursive breadth-first dump of this window's children.

©2024 Boris FX, Inc. — UNOFFICIAL — Converted from original PDF.