View Module

The "view" module manages the functions which perform drawing operations.

Module name

cri.atomcraft.view

The following functions are defined as:

Function Description Operation object
get_file_path_with_dialog Gets the file path -
show_dialog Shows the dialog -



get_file_path_with_dialog

Gets the path of the selected file using the dialog.
The input argument mode specifies the type of dialog you want to display. The two modes are "open" and "save".

  • "open": Dialog for reading files
  • "save": Dialog for saving files
    The file extension can be specified via the input argument suffix. There are 3 ways to specify it:
  • 1. Indicate only the extension, such as "csv" or "txt"
  • 2. Use names such as "Image (*.png, *jpeg) " and wildcards and extensions
  • 3. Use more complex patterns such as "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    The initial path selected when the dialog appears can be specified in the folder_path argument. If omitted, the "Documents" folder is used as the initial path.

This function was added in Ver.3.46.04.

Attention
This function is not available from the command line.

Format

result = get_file_path_with_dialog(mode, suffix, folder_path = "")

Input parameter

Name Value
modeType of the dialog
suffixFile extension of the files displayed in the dialog
folder_pathDefault folder to open in the dialog

Return value

NameValue
result [ "succeed" ] True if succeeded, False if failed
result [ "data" ] String that contains the selected file path



show_dialog

Shows the dialog.

criatom_tools_atomcraft_api_view_show_dialog.png

The dialog provides the text area which supports copy to clipboard, and up to three buttons.
The input argument message specifies the text to be displayed. Use \n to jump to the next line.
The input argument button_name_list specifies the texts on the buttons as a list. You can specify up to three buttons.

  • (Example 1) If you need to add three buttons "Yes, No, Cancel", specify ["Yes", "No", "Cancel"] in button_name_list .
  • (Example 2) If you only need the OK button, specify ["OK"] in button_name_list .

The return value is given as an associative array.
The associative array have two keys: button_index and button_name.
The value of the button_index key is the index of the button pressed (the index is zero-based).
The value of the button_name key is the text of the button pressed.
If the user closes the dialog by pressing the X button, the index will be -1 and the name will be an empty string.

This function was added in Ver.3.45.00.

Attention
This function is not available from the command line.

Format

result = show_dialog(message, button_name_list)

Input parameter

Name Value
messageText to be shown
button_name_listList of the button names (up to three)

Return value

NameValue
result [ "succeed" ] True if succeeded, False if failed
result [ "data" ] An associative array with button_index and button_name keys
result [ "data" ][ "button_index" ] Index of the button pressed (zero-based)
-1 when no button was pressed
result [ "data" ][ "button_name" ] Text of the button pressed