Forms

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.

Parameters
  • name (str) -- The title of the window that will be displayed in the top left corner.

  • ok (bool) -- If True an Ok button will be displayed in the bottom of the window.

  • cancel (bool) -- If True a Cancel button will be displayed in the bottom of the window.

  • width (int) -- The width of the window.

  • height (int) -- The height of the window.

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 True else it will be 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

show()

Displays the window on screen.

Returns

Whether the Ok Button was clicked or not.

Return type

bool

start_group(label=None)

Starts a group of widgets. Widgets added between start_group() and end_group() are added to a frame with a name. end_group() must be called at the end of the group.

Parameters

label (str or None) -- The title of the group.

end_group()

Ends a group started with start_group().

add_button(text='', action=None, pos=Position.LEFT)

Add a button to the window.

Parameters
  • text (str) -- The text that will be displayed on the button.

  • action (Callable[[None], None]) -- The function that will be called when the button is clicked.

  • pos (Position) -- The alignment of the button.

Returns

The button that was created and added to the window.

Return type

Button

add_check_box(name, label=None, state=False, pos=Position.LEFT)

Add a checkbox to the window.

Parameters
  • name (str) -- The name of the checkbox.

  • label (str or None) -- The label that will be displayed on the right of the checkbox.

  • state (bool) -- Whether the checkbox is checked.

  • pos (Position) -- The alignment of the checkbox.

Returns

The checkbox that was created and added to the window.

Return type

CheckBox

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_combo_box(name, label=None, items=[])

Add a combobox to the window.

Parameters
  • name (str) -- The name of the combobox.

  • label (str or None) -- The label that will be displayed on the left of the combobox.

  • items (list(str)) -- The list of items to add in the combobox.

Returns

The combobox that was created and added to the window.

Return type

ComboBox

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_list_box(name, label=None, items=[])

Add a listbox to the window.

Parameters
  • name (str) -- The name of the list.

  • label (str or None) -- The label that will be displayed on the left of the listbox.

  • items (list(str)) -- The list of items to add in the listbox.

Returns

The listbox that was created and added to the window.

Return type

ListBox

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_radio_button_group(name, label=None, items=[])

Add a group composed of radio buttons to the window.

Parameters
  • name (str) -- The name of the group.

  • label (str or None) -- The text that will be displayed at the top of the group.

  • items (list(str)) -- The names of all the radio buttons in the group.

Returns

The radio buttons that were created and added to the window.

Return type

list(RadioButton)

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_separator()

Add an horizontal separator on the window.

add_text(text='', pos=Position.Left)

Displays a text on the window.

Parameters
  • text (str) -- The text that will be displayed on the window.

  • pos (Position) -- The alignment of the text.

Returns

The label that contains the text on the window.

Return type

Label

add_text_input(name, label=None, text='')

Add a text input to the window.

Parameters
  • name (str) -- The name of the text input.

  • label (str or None) -- The label that will be displayed on the left of the text input.

  • text (str) -- The text in the text input.

Returns

The text input that was created and added to the window.

Return type

LineEdit

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_open_file_selector(name, label=None, filter='', dir='/')

Add an open file selector to the window.

Parameters
  • name (str) -- The name of the open file selector.

  • label (str or None) -- The label that will be displayed on the left of the selector.

  • filter (str) -- The types of files that will be visible from the dialog.

  • dir (str) -- The folder in which the dialog will open.

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_open_folder_selector(name, label=None, filter='', dir='/')

Add an open directory selector to the window.

Parameters
  • name (str) -- The name of the open directory selector.

  • label (str or None) -- The label that will be displayed on the left of the selector.

  • filter (str) -- The types of files that will be visible from the dialog.

  • dir (str) -- The folder in which the dialog will open.

Raises

RuntimeError -- If the name is already used for another widget in the form.

add_save_file_selector(name, label=None, filter='', dir='/')

Add a save file selector to the window.

Parameters
  • name (str) -- The name of the save file selector.

  • label (str or None) -- The label that will be displayed on the left of the selector.

  • filter (str) -- The types of files that will be visible from the dialog.

  • dir (str) -- The folder in which the dialog will open.

Raises

RuntimeError -- If the name is already used for another widget in the form.