===== Forms ===== .. py:currentmodule:: p3dsdk.ui .. py:class:: Forms(name = "Simple UI", ok = True, cancel = True, width = -1, height = -1) A class to create customizable forms. Opens a new window with a forms layout. :param name: The title of the window that will be displayed in the top left corner. :type name: str :param ok: If :py:obj:`True` an Ok button will be displayed in the bottom of the window. :type ok: bool :param cancel: If :py:obj:`True` a Cancel button will be displayed in the bottom of the window. :type cancel: bool :param width: The width of the window. :type width: int :param height: The height of the window. :type height: int .. py:property:: values Contains the values for the added widgets. The key is the name of the widget passed in methods. * For a text input, the value in the dictionary will be the text in the input. * For a check box, if it is checked the value will be :py:obj:`True` else it will be :py:obj:`False`. * For a combobox, the value will be the text of the currently selected item. * For radio button groups, the value will be the label of the selected radio. :type: dict(str, str), read-only .. py:method:: show() Displays the window on screen. :returns: Whether the Ok Button was clicked or not. :rtype: bool .. py:method:: start_group(label = None) Starts a group of widgets. Widgets added between :py:meth:`start_group` and :py:meth:`end_group` are added to a frame with a name. :py:meth:`end_group` must be called at the end of the group. :param label: The title of the group. :type label: str or None .. py:method:: end_group() Ends a group started with :py:meth:`start_group`. .. py:method:: add_button(text = "", action = None, pos = Position.LEFT) Add a button to the window. :param text: The text that will be displayed on the button. :type text: str :param action: The function that will be called when the button is clicked. :type action: Callable[[None], None] :param pos: The alignment of the button. :type pos: Position :returns: The button that was created and added to the window. :rtype: Button .. py:method:: add_check_box(name, label = None, state = False, pos = Position.LEFT) Add a checkbox to the window. :param name: The name of the checkbox. :type name: str :param label: The label that will be displayed on the right of the checkbox. :type label: str or None :param state: Whether the checkbox is checked. :type state: bool :param pos: The alignment of the checkbox. :type pos: Position :returns: The checkbox that was created and added to the window. :rtype: CheckBox :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_combo_box(name, label = None, items = []) Add a combobox to the window. :param name: The name of the combobox. :type name: str :param label: The label that will be displayed on the left of the combobox. :type label: str or None :param items: The list of items to add in the combobox. :type items: list(str) :returns: The combobox that was created and added to the window. :rtype: ComboBox :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_list_box(name, label = None, items = []) Add a listbox to the window. :param name: The name of the list. :type name: str :param label: The label that will be displayed on the left of the listbox. :type label: str or None :param items: The list of items to add in the listbox. :type items: list(str) :returns: The listbox that was created and added to the window. :rtype: ListBox :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_spin_box(name, label = None, value = 0, minimum = 0, maximum = 100, step = 1) Add a spinbox to the window. :param name: The name of the list. :type name: str :param label: The label that will be displayed on the left of the spinbox. :type label: str or None :param value: The initial value. :type value: int :param minimum: The minimum value allowed. :type minimum: int :param maximum: The maximum value allowed. :type maximum: int :param step: The step to use when incrementing or decrementing the value. :type step: int :returns: The spinbox that was created and added to the window. :rtype: SpinBox :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_radio_button_group(name, label = None, items = []) Add a group composed of radio buttons to the window. :param name: The name of the group. :type name: str :param label: The text that will be displayed at the top of the group. :type label: str or None :param items: The names of all the radio buttons in the group. :type items: list(str) :returns: The radio buttons that were created and added to the window. :rtype: list(RadioButton) :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_separator() Add an horizontal separator on the window. .. py:method:: add_text(text = "", pos = Position.Left) Displays a text on the window. :param text: The text that will be displayed on the window. :type text: str :param pos: The alignment of the text. :type pos: Position :returns: The label that contains the text on the window. :rtype: Label .. py:method:: add_text_input(name, label = None, text = "") Add a text input to the window. :param name: The name of the text input. :type name: str :param label: The label that will be displayed on the left of the text input. :type label: str or None :param text: The text in the text input. :type text: str :returns: The text input that was created and added to the window. :rtype: LineEdit :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_open_file_selector(name, label = None, filter = "", dir = "/") Add an open file selector to the window. :param name: The name of the open file selector. :type name: str :param label: The label that will be displayed on the left of the selector. :type label: str or None :param filter: The types of files that will be visible from the dialog. :type filter: str :param dir: The folder in which the dialog will open. :type dir: str :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_open_folder_selector(name, label = None, filter = "", dir = "/") Add an open directory selector to the window. :param name: The name of the open directory selector. :type name: str :param label: The label that will be displayed on the left of the selector. :type label: str or None :param filter: The types of files that will be visible from the dialog. :type filter: str :param dir: The folder in which the dialog will open. :type dir: str :raises RuntimeError: If the name is already used for another widget in the form. .. py:method:: add_save_file_selector(name, label = None, filter = "", dir = "/") Add a save file selector to the window. :param name: The name of the save file selector. :type name: str :param label: The label that will be displayed on the left of the selector. :type label: str or None :param filter: The types of files that will be visible from the dialog. :type filter: str :param dir: The folder in which the dialog will open. :type dir: str :raises RuntimeError: If the name is already used for another widget in the form.