simpleguics2pygame — control
simpleguics2pygame module: simpleguics2pygame/control.
Classes Control and TextAreaControl.
Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame
- license
GPLv3 — Copyright (C) 2015-2016, 2020 Olivier Pirson
- author
Olivier Pirson — http://www.opimedia.be/
- version
November 29, 2020
- class SimpleGUICS2Pygame.simpleguics2pygame.control.Control(frame: pygame.Frame, text: str, button_handler: Optional[Callable[[], Any]] = None, width: Optional[int] = None)[source]
Control similar to SimpleGUI Control (button and label) of CodeSkulptor.
- __init__(frame: pygame.Frame, text: str, button_handler: Optional[Callable[[], Any]] = None, width: Optional[int] = None) None [source]
Set a button (if button_handler is not None) or a label (if button_handler is None) in the control panel.
Don’t use directly, use Frame.add_button() or Frame.add_label().
- Parameters
frame – Frame
text – str
button_handler – None or (function () -> *)
width – None or int
- __weakref__
list of weak references to the object (if defined)
- _button_background_pygame_color = '#c0c0c0'
pygame.Color of the background in the button.
- _button_padding_x = 5
Horizontal padding in the button.
- _button_padding_y = 3
Vertical padding in the button.
- _button_pygame_font = None
pygame.font.Font of text in the button.
- _button_selected_background_pygame_color = '#f0f0f0'
pygame.Color of the background in the button when it has pressed.
- _button_text_pygame_color = '#000000'
pygame.Color of text in the button.
- _draw() None [source]
Draw the control object in the control panel.
(Not available in SimpleGUI of CodeSkulptor.)
- _draw_button() None [source]
Draw the the control object as a button.
(Not available in SimpleGUI of CodeSkulptor.)
- _draw_label() None [source]
Draw the the control object as a label.
(Not available in SimpleGUI of CodeSkulptor.)
- _label_pygame_font = None
pygame.font.Font of the label.
- _label_text_pygame_color = '#000000'
pygame.Color of the label.
- _mouse_left_button(pressed: bool) None [source]
Deal a click of left mouse button on the zone of this Control.
If pressed then select this Control, else unselect and run the button handler (if exist).
(Not available in SimpleGUI of CodeSkulptor.)
- Parameters
pressed – bool
- class SimpleGUICS2Pygame.simpleguics2pygame.control.TextAreaControl(frame: pygame.Frame, label_text: str, input_handler: Optional[Callable[[str], Any]], input_width: Union[int, float])[source]
TextAreaControl similar to SimpleGUI TextAreaControl (input) of CodeSkulptor.
- __init__(frame: pygame.Frame, label_text: str, input_handler: Optional[Callable[[str], Any]], input_width: Union[int, float]) None [source]
Set a input box in the control panel.
Don’t use directly, use Frame.add_input().
- Parameters
frame – Frame
label_text – str
input_handler – function (str) -> *
input_width – int or float
- __weakref__
list of weak references to the object (if defined)
- _draw() None [source]
Draw the input box and his label.
(Not available in SimpleGUI of CodeSkulptor.)
- _input_background_pygame_color = '#ffffff'
pygame.Color of the background in the input box.
- _input_mark_pygame_color = '#00ff00'
pygame.Color of the end mark of text in the input box.
- _input_padding_x = 5
Horizontal padding in the input box.
- _input_padding_y = 3
Vertical padding in the input box.
- _input_pygame_color = '#000000'
pygame.Color of the text in the input box.
- _input_pygame_font = None
pygame.font.Font of the text in the input box.
- _input_selected_background_pygame_color = '#ffffff'
pygame.Color of the background in the input box when it has focus.
- _key(pygame_event: pygame.event.Event) None [source]
Deal key pressed when this TextAreaControl have focus.
(Not available in SimpleGUI of CodeSkulptor.)
- Parameters
pygame_event – pygame.Event KEYDOWN or KEYUP
- _label_pygame_font = None
pygame.font.Font of the label of the input box.
- _label_text_pygame_color = '#000000'
pygame.Color of the label of the input box.
- _mouse_left_button(pressed: bool) None [source]
Deal a click of left mouse button on the zone of this TextAreaControl.
If pressed then give it the focus.
(Not available in SimpleGUI of CodeSkulptor.)
- Parameters
pressed – bool
- SimpleGUICS2Pygame.simpleguics2pygame.control.__all__ = ('Control', 'TextAreaControl')
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
[source]