Oasys.REPORTER.Window class

Constants

Window.CANCEL

Show CANCEL button

Window.NO

Show NO button

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

  • 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

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.REPORTER.Window.Error("Error", "Critical error!\nAbort?", Oasys.REPORTER.Window.YES | Oasys.REPORTER.Window.NO)
if answer == Oasys.REPORTER.Window.YES:
    print("You pressed Yes")
classmethod Window.GetDirectory(initial=Oasys.gRPC.defaultArg)

Map the directory selector box native to your machine, allowing you to choose a directory

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.REPORTER.Window.GetDirectory()
classmethod Window.GetFile(extension=Oasys.gRPC.defaultArg, allow_new=Oasys.gRPC.defaultArg, initial=Oasys.gRPC.defaultArg)

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

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

  • allow_new (boolean) – Optional. Allow creation of new 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.REPORTER.Window.GetFile(".key")
classmethod Window.GetFiles(extension=Oasys.gRPC.defaultArg)

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

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.REPORTER.Window.GetFiles(".key")
classmethod Window.GetInteger(title, message)

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

Returns:

Integer. Value input, (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.REPORTER.Window.GetInteger("Input", "Input integer")
classmethod Window.GetNumber(title, message)

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

Returns:

Real. Value input, (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.REPORTER.Window.GetNumber("Input", "Input number")
classmethod Window.GetOptions(title, message, options)

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

Parameters:
  • title (string) – Title for window

  • message (string) – Message to show in window

  • options (list of dicts) –

    List of objects listing options that can be set. If OK is pressed the objects will be updated with the values from the widgets. If cancel is pressed they will not

    selected (optional):

    (boolean) If checkbox is selected or not

    text:

    (string) Text to show next to option

    type:

    (string) Type of option. Can be “label” (plain text), “text” (a one line text widget), “textbox” (a multi line text widget) or “checkbox” (a checkable option)

    value:

    (string) Text to show for option

Returns:

False if cancel pressed, True if OK pressed

Return type:

bool

Example

To create a window with title Options , message Please give the options with label, text, textbox and checkbox widgets:

options = [{ "text" : "Label example", "type" : "label", "value" : "banana" },
           { "text" : "Text example", "type" : "text", "value" : "single line of text" },
           { "text" : "Textbox example", "type" : "textbox", "value" : "Multiple\\nlines\\nof\\ntext" },
           { "text" : "Checkbox example", "type" : "checkbox", "value" : "Do this?", "selected" : True }]
ok = Oasys.REPORTER.Window.GetOptions("Options", "Please give the options", options)
classmethod Window.GetString(title, message)

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

Returns:

String. Value input, (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.REPORTER.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

  • 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

Returns:

Button pressed

Return type:

int

Example

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

answer = Oasys.REPORTER.Window.Information("Example", "Information", Oasys.REPORTER.Window.OK | Oasys.REPORTER.Window.CANCEL)
if answer == Oasys.REPORTER.Window.CANCEL:
    print("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

  • 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

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.REPORTER.Window.Message("Example", "Press YES or NO", Oasys.REPORTER.Window.YES | Oasys.REPORTER.Window.NO)
if answer == Oasys.REPORTER.Window.NO:
    print("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

  • 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

Returns:

Button pressed

Return type:

int

Example

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

answer = Oasys.REPORTER.Window.Question("Question", "Do you want to continue?")
if answer == Oasys.REPORTER.Window.NO:
    print("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

  • 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

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.REPORTER.Window.Warning("Warning", "Title is blank\nSet to ID?", Oasys.REPORTER.Window.YES | Oasys.REPORTER.Window.NO)
if answer == Oasys.REPORTER.Window.NO:
    print("You pressed No")