Toolbar Widgets
Contents
Toolbar Widgets#
ToolbarWidget#
- class miniworldmaker.containers.widgets.Widget[source]#
A Widget which can be placed in the Toolbar.
A widget can have ‘text’ and an ‘image’.
Public Data Attributes:
Defines how text is aligned.
Left text_padding
Top text_padding
Top-left text_padding
Width of image.
Margin below widget
Margin above widget
left margin
right margin
Widget height
Widget width (read only value)
The text which is displayed on the widget.
Public Methods:
__init__
()get_local_pos
(position)on_setup
()Overwrite this method if you want to add custom setup-code
on_mouse_left
(mouse_pos)set_background_color
(value)- rtype
clear
()remove
()Removes the widget from toolbar
set_text
(text)Sets text of widget.
set_image
(_img_source)sets image of widget
set_border
([color, width])sets border of widget
__str__
()Return str(self).
register
(method)Used as decorator e.g.
send_message
(text)Private Methods:
_repaint
()Repaints the widget.
- property dirty#
- property img_width: float#
Width of image. (Height will be autoset by padding-left, padding-top and padding.right)
- Return type
- set_border(color=(0, 0, 0, 255), width=1)[source]#
sets border of widget
- Parameters
color (_type_) – _description_
width (_type_) – _description_
- set_image(_img_source)[source]#
sets image of widget
- Parameters
_img_source (str) – path to image or tuple with color
- property text_align#
Defines how text is aligned.
If widget has an image, text is aligned left, else it can be set to “left”, “center” or “right”.
ToolbarLabel#
- class miniworldmaker.containers.widgets.Label(text, img_path=None)[source]#
Public Data Attributes:
Inherited from
Widget
text_align
Defines how text is aligned.
text_padding_left
Left text_padding
text_padding_top
Top text_padding
text_padding_top_left
Top-left text_padding
img_width
Width of image.
margin_bottom
Margin below widget
margin_top
Margin above widget
margin_left
left margin
margin_right
right margin
height
Widget height
width
Widget width (read only value)
background_color
dirty
text
The text which is displayed on the widget.
Public Methods:
__init__
(text[, img_path])Inherited from
Widget
__init__
()get_local_pos
(position)on_setup
()Overwrite this method if you want to add custom setup-code
on_mouse_left
(mouse_pos)set_background_color
(value)- rtype
clear
()remove
()Removes the widget from toolbar
set_text
(text)Sets text of widget.
set_image
(_img_source)sets image of widget
set_border
([color, width])sets border of widget
__str__
()Return str(self).
register
(method)Used as decorator e.g.
send_message
(text)Private Methods:
Inherited from
Widget
_repaint
()Repaints the widget.