Oasys.PRIMER.Window class

Constants

Window.CANCEL

Show CANCEL button

Window.NO

Show NO button

Window.NONMODAL

Allow Window.Error, Window.Question, Window.Warning etc windows to be non modal

Window.OK

Show OK button

Window.YES

Show YES button

Static methods

classmethod Window.Error(title, error, buttons=Oasys.gRPC.defaultArg)

Show an error message in a window

Parameters:
  • title (string) – Title for window

  • error (string) – Error message to show in window. The maximum number of lines that can be shown is controlled by the Options.max_window_lines option

  • buttons (constant) – Optional. The buttons to use. Can be bitwise OR of Window.OK, Window.CANCEL, Window.YES or Window.NO. If this is omitted an OK button will be used. By default the window will be modal. If Window.NONMODAL is also given the window will be non-modal instead

Returns:

Button pressed

Return type:

int

Example

To show error Critical error!nAbort? in window with title Error with Yes and No buttons:

answer = Oasys.PRIMER.Window.Error("Error", "Critical error!\nAbort?", Oasys.PRIMER.Window.YES | Oasys.PRIMER.Window.NO)
classmethod Window.GetDirectory(initial=Oasys.gRPC.defaultArg)

Map the directory selector box native to your machine, allowing you to choose a directory. On Unix this will be a Motif selector. Windows will use the standard windows directory selector

Parameters:

initial (string) – Optional. Initial directory to start from

Returns:

directory (string), (or None if cancel pressed)

Return type:

str

Example

To select a directory:

dir = Oasys.PRIMER.Window.GetDirectory()
classmethod Window.GetFile(extension=Oasys.gRPC.defaultArg, save=Oasys.gRPC.defaultArg, initial=Oasys.gRPC.defaultArg)

Map a file selector box allowing you to choose a file. See also Window.GetFiles() and Window.GetFilename()

Parameters:
  • extension (string) – Optional. Extension to filter by

  • save (boolean) – Optional. If true the file selector is to be used for saving a file. If false (default) the file selector is for opening a file. Due to native operating system file selector differences, on linux new filenames can only be given when saving a file. On windows it is possible to give new filenames when opening or saving a file

  • initial (string) – Optional. Initial directory to start from

Returns:

filename (string), (or None if cancel pressed)

Return type:

str

Example

To select a file using extension ‘.key’:

file = Oasys.PRIMER.Window.GetFile(".key")
classmethod Window.GetFilename(title, message, extension=Oasys.gRPC.defaultArg, initial=Oasys.gRPC.defaultArg, save=Oasys.gRPC.defaultArg)

Map a window allowing you to input a filename (or select it using a file selector). OK and Cancel buttons are shown. See also Window.GetFile()

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

  • extension (string) – Optional. Extension to filter by

  • initial (string) – Optional. Initial value

  • save (boolean) – Optional. If true the file selector is to be used for saving a file. If false (default) the file selector is for opening a file. Due to native operating system file selector differences, on linux new filenames can only be given when saving a file. On windows it is possible to give new filenames when opening or saving a file

Returns:

filename (string), (or None if cancel pressed)

Return type:

str

Example

To create an file input window with title Choose file and message Choose the file to open and return the filename input:

filename = Oasys.PRIMER.Window.GetFilename("Choose file", "Choose the file to open")
classmethod Window.GetFiles(extension=Oasys.gRPC.defaultArg)

Map a file selector box allowing you to choose multiple files. See also Window.GetFile() and Window.GetFilename()

Parameters:

extension (string) – Optional. Extension to filter by

Returns:

List of filenames (strings), or None if cancel pressed

Return type:

str

Example

To select multiple files using extension ‘.key’:

files = Oasys.PRIMER.Window.GetFiles(".key")
classmethod Window.GetInteger(title, message, initial=Oasys.gRPC.defaultArg)

Map a window allowing you to input an integer. OK and Cancel buttons are shown

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

  • initial (integer) – Optional. Initial value

Returns:

value input (integer), or None if cancel pressed

Return type:

int

Example

To create an input window with title Input and message Input integer and return the value input:

value = Oasys.PRIMER.Window.GetInteger("Input", "Input integer")
classmethod Window.GetNumber(title, message, initial=Oasys.gRPC.defaultArg)

Map a window allowing you to input a number. OK and Cancel buttons are shown

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

  • initial (float) – Optional. Initial value

Returns:

value input (float), or None if cancel pressed

Return type:

float

Example

To create an input window with title Input and message Input number and return the value input:

value = Oasys.PRIMER.Window.GetNumber("Input", "Input number")
classmethod Window.GetPassword(title, message)

Map a window allowing you to input a password. OK and Cancel buttons are shown.
This is identical to Window.GetString except the string is hidden and no initial value can be given

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

Returns:

value input (string), or None if cancel pressed

Return type:

str

Example

To create an input window with title Input and message Input password and return the value input:

value = Oasys.PRIMER.Window.GetPassword("Input", "Input password")
classmethod Window.GetString(title, message, initial=Oasys.gRPC.defaultArg)

Map a window allowing you to input a string. OK and Cancel buttons are shown

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

  • initial (string) – Optional. Initial value

Returns:

value input (string), or None if cancel pressed

Return type:

str

Example

To create an input window with title Input and message Input string and return the value input:

value = Oasys.PRIMER.Window.GetString("Input", "Input string")
classmethod Window.Information(title, info, buttons=Oasys.gRPC.defaultArg)

Show information in a window

Parameters:
  • title (string) – Title for window

  • info (string) – Information to show in window. The maximum number of lines that can be shown is controlled by the Options.max_window_lines option

  • buttons (constant) – Optional. The buttons to use. Can be bitwise OR of Window.OK, Window.CANCEL, Window.YES or Window.NO. If this is omitted an OK button will be used. By default the window will be modal. If Window.NONMODAL is also given the window will be non-modal instead

Returns:

Button pressed

Return type:

int

Example

To show information Information in window with title Example with OK and Cancel buttons:

answer = Oasys.PRIMER.Window.Information("Example", "Information", Oasys.PRIMER.Window.OK | Oasys.PRIMER.Window.CANCEL)
if answer == Oasys.PRIMER.Window.CANCEL:
    Oasys.PRIMER.Message("You pressed the Cancel button")
classmethod Window.Message(title, message, buttons=Oasys.gRPC.defaultArg)

Show a message in a window

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window. The maximum number of lines that can be shown is controlled by the Options.max_window_lines option

  • buttons (constant) – Optional. The buttons to use. Can be bitwise OR of Window.OK, Window.CANCEL, Window.YES or Window.NO. If this is omitted an OK button will be used By default the window will be modal. If Window.NONMODAL is also given the window will be non-modal instead

Returns:

Button pressed

Return type:

int

Example

To show message Press YES or NO in window with title Example with YES and NO buttons:

answer = Oasys.PRIMER.Window.Message("Example", "Press YES or NO", Oasys.PRIMER.Window.YES | Oasys.PRIMER.Window.NO)
if answer == Oasys.PRIMER.Window.NO:
    Oasys.PRIMER.Message("You pressed No")
classmethod Window.Question(title, question, buttons=Oasys.gRPC.defaultArg)

Show a question in a window

Parameters:
  • title (string) – Title for window

  • question (string) – Question to show in window. The maximum number of lines that can be shown is controlled by the Options.max_window_lines option

  • buttons (constant) – Optional. The buttons to use. Can be bitwise OR of Window.OK, Window.CANCEL, Window.YES or Window.NO. If this is omitted Yes and No button will be used. By default the window will be modal. If Window.NONMODAL is also given the window will be non-modal instead

Returns:

Button pressed

Return type:

int

Example

To show question Do you want to continue? in window with title Question:

answer = Oasys.PRIMER.Window.Question("Question", "Do you want to continue?")
if answer == Oasys.PRIMER.Window.NO:
    Oasys.PRIMER.Message("You pressed No")
classmethod Window.Warning(title, warning, buttons=Oasys.gRPC.defaultArg)

Show a warning message in a window

Parameters:
  • title (string) – Title for window

  • warning (string) – Warning message to show in window. The maximum number of lines that can be shown is controlled by the Options.max_window_lines option

  • buttons (constant) – Optional. The buttons to use. Can be bitwise OR of Window.OK, Window.CANCEL, Window.YES or Window.NO. If this is omitted an OK button will be used. By default the window will be modal. If Window.NONMODAL is also given the window will be non-modal instead

Returns:

Button pressed

Return type:

int

Example

To show warning Title is blanknSet to ID? in window with title Warning with Yes and No buttons:

answer = Oasys.PRIMER.Window.Warning("Warning", "Title is blank\nSet to ID?", Oasys.PRIMER.Window.YES | Oasys.PRIMER.Window.NO)
if answer == Oasys.PRIMER.Window.NO:
    Oasys.PRIMER.Message("You pressed No")