Widgets

class Widget

Base class of all widgets.

property x

The X coordinate of the label.

Type

int

property y

The Y coordinate of the label.

Type

int

property width

The width of the label.

Type

int

property height

The height of the label.

Type

int

class Button(parent=None, text='')

Base class: Widget

When clicked, pressed, or released the corresponding function is called.

Parameters
  • parent (Widget) -- The parent Widget.

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

property text

The text of the button.

Type

str

property on_click

The function that will be called when the button is clicked.

Type

Callable[[None], None]

property on_press

The function that will be called when the button is pressed.

Type

Callable[[None], None]

property on_release

The function that will be called when the button is released.

Type

Callable[[None], None]

class CheckBox(parent=None, text='')

Base class: Widget

A check box with a text label on the left.

Parameters
  • parent (Widget) -- The parent Widget.

  • text (str) -- The text on left of the CheckBox.

property checked

Whether the checkBox is checked or not.

Type

bool

property text

The text of the checkBox.

Type

str

property on_toggle

The function that is called when the check box is toggled.

Type

Callable[[bool], None]

class ComboBox(parent=None, items=[])

Base class: Widget

A comboBox with an unlimited number of items.

Parameters
  • parent (Widget) -- The parent Widget.

  • items (list(str)) -- The list of the names of all the items of the comboBox.

property current_text

The current item of the comboBox.

Type

str

property on_current_text_changed

The function that is called when the comboBox current item changes.

Type

Callable[[str], None]

add_item(item)

Add an item.

Parameters

item (str) -- The name of the new item.

add_items(items)

Add a list of items.

Parameters

items (list(str)) -- The list of the names of the new items of the comboBox.

insert_item(index, text)

Insert an item in the comboBox

Parameters
  • index (int) -- The index in the list of items where the new item will be inserted.

  • text (str) -- The name of the new item.

class Label(parent=None, text='')

Base class: Widget

A Widget which contains text.

Parameters
  • parent (Widget) -- The parent Widget.

  • text (str) -- The text of the label.

property text

The text of the label.

Type

str

adjust_size()

Adjust the size of the label with the size of the text.

class LineEdit(parent=None, text='')

Base class: Widget

A single-line text input.

Parameters
  • parent (Widget) -- The parent Widget.

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

property text

The text of the LineEdit.

Type

str

property on_text_changed

The function that will be called when the text of the LineEdit changes.

Type

Callable[[str], None]

property on_selection_changed

"The function that will be called when the text selection is changed.

Type

Callable[[None], None]

adjust_size()

Adjust the size of the LineEdit with the size of the text.

class ListBox(parent=None, items=[])

Base class: Widget

A ListBox with several items in it which are selectable.

Parameters
  • parent (Widget) -- The parent Widget.

  • items (list(str)) -- The texts of the items in the ListBox.

property current_item

The text of the current selected item.

Type

str

insert_item(text, index=- 1)

Creates and inserts a new item in the list.

Parameters
  • text (str) -- The text of the item.

  • index (int) -- The index where the new item will be inserted. If the index is -1 then it will be at the end of the list.

class RadioButton(parent=None, text='')

Base class: Widget

A RadioButton with a text label on the left.

Parameters
  • parent (Widget) -- The parent Widget.

  • text (str) -- The text on left of the RadioButton.

property checked

Whether the RadioButton is checked or not.

Type

bool

property text

The text of the RadioButton.

Type

str

property on_toggle

The function that is called when the RadioButton is toggled.

Type

Callable[[bool], None]

class Slider(parent=None, orientation=Orientation.HORIZONTAL, minimum=0, maximum=100, tick=Tick.NONE)

Base class: Widget

An horizontal or vertical slider.

Parameters
  • parent (Widget) -- The parent Widget.

  • orientation (Orientation) -- Whether the slider is vertical or horizontal.

  • minimum (int) -- The minimum value of the slider.

  • maximum (int) -- The maximum value of the slider.

  • tick (Tick) -- The tick position of the slider.

property maximum

The maximum value of the slider.

Type

int

property minimum

The minimum value of the slider.

Type

int

property value

The value of the slider.

Type

int

property tick_interval

The tick interval of the slider.

Type

int

property tick_position

The tick position of the slider.

Type

Tick

property on_value_changed

The function that will be called when the value of the slider changes.

Type

Callable[[int], None]

property on_slider_pressed

The function that will be called when the slider is pressed.

Type

Callable[[None], None]

property on_slider_moved

The function that will be called when the slider is moved.

Type

Callable[[int], None]

property on_slider_released

The function that will be called when the slider is released.

Type

Callable[[None], None]

class SpinBox(parent=None, value=0, minimum=0, maximum=100, step=1)

Base class: Widget

An integer input.

Parameters
  • parent (Widget) -- The parent Widget.

  • value (int) -- The default value.

  • minimum (int) -- The minimum value.

  • maximum (int) -- The maximum value.

  • step (int) -- The step between two values of the SpinBox.

property maximum

The maximum value of the SpinBox.

Type

int

property minimum

The minimum value of the SpinBox.

Type

int

property step

The step between two values of the SpinBox.

Type

int

property value

The value of the SpinBox.

Type

int

property prefix

The text that will be printed before the value.

Type

str

property suffix

The text that will be printed after the value.

Type

str

property on_value_changed

The function that is called when the SpinBox value changes.

Type

Callable[[int], None]

property on_text_changed

The function that is called when the SpinBox value changes, as string.

Type

Callable[[str], None]

clean_text()

Remove all non numeric text from the SpinBox.

class TextEdit(parent=None, text='')

Base class: Widget

A multi-line text input.

Parameters
  • parent (Widget) -- The parent Widget.

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

property text

The text of the TextEdit.

Type

str

property on_text_changed

The function that will be called when the text of the TextEdit changes.

Type

Callable[[str], None]

property on_selection_changed

"The function that will be called when the text selection is changed.

Type

Callable[[None], None]

adjust_size()

Adjust the size of the TextEdit with the size of the text.

class VButtonGroup(parent=None, title='')

Base class: Widget

A widget which is a group of button.

Parameters
  • parent (Widget) -- The parent Widget.

  • title (str) -- The text on the top of the group.

class Window(parent=None, name='')

Base class: Widget

An empty widget on which it is possible to add other widgets.

Parameters
show()

Display the window on the screen when Application.exec() is called.

close()

Closes the window.