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, text, button_handler=None, width=None)[source]

Control similar to SimpleGUI Control (button and label) of CodeSkulptor.

__init__(frame, text, button_handler=None, width=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
__repr__()[source]

Return ‘<Control object>’.

Returns:str
__weakref__

list of weak references to the object (if defined)

_button_background_pygame_color

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

pygame.font.Font of text in the button.

_button_selected_background_pygame_color

pygame.Color of the background in the button when it has pressed.

_button_text_pygame_color

pygame.Color of text in the button.

_draw()[source]

Draw the control object in the control panel.

(Not available in SimpleGUI of CodeSkulptor.)

_draw_button()[source]

Draw the the control object as a button.

(Not available in SimpleGUI of CodeSkulptor.)

_draw_label()[source]

Draw the the control object as a label.

(Not available in SimpleGUI of CodeSkulptor.)

_label_pygame_font

pygame.font.Font of the label.

_label_text_pygame_color

pygame.Color of the label.

_mouse_left_button(pressed)[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
_pos_in(x, y)[source]

If position (x, y) is on the zone of this aControl then return True, else return False.

(Not available in SimpleGUI of CodeSkulptor.)

Parameters:
  • x – int or float
  • y – int or float
Returns:

bool

get_text()[source]

Return the text of the button or the label.

Returns:str
set_text(text)[source]

Change the text of the button or the label.

Parameters:text – str
class SimpleGUICS2Pygame.simpleguics2pygame.control.TextAreaControl(frame, label_text, input_handler, input_width)[source]

TextAreaControl similar to SimpleGUI TextAreaControl (input) of CodeSkulptor.

__init__(frame, label_text, input_handler, input_width)[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
__repr__()[source]

Return ‘<TextAreaControl object>’.

Returns:str
__weakref__

list of weak references to the object (if defined)

_draw()[source]

Draw the input box and his label.

(Not available in SimpleGUI of CodeSkulptor.)

_input_background_pygame_color

pygame.Color of the background in the input box.

_input_mark_pygame_color

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

pygame.Color of the text in the input box.

_input_pygame_font

pygame.font.Font of the text in the input box.

_input_selected_background_pygame_color

pygame.Color of the background in the input box when it has focus.

_key(pygame_event)[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

pygame.font.Font of the label of the input box.

_label_text_pygame_color

pygame.Color of the label of the input box.

_mouse_left_button(pressed)[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
_pos_in(x, y)[source]

If position (x, y) is on the zone of this TextAreaControl then return True, else return False.

(Not available in SimpleGUI of CodeSkulptor.)

Parameters:
  • x – int or float
  • y – int or float
Returns:

bool

get_text()[source]

Return the text of the input box.

Returns:str (or unicode in Python 2)
set_text(input_text)[source]

Change the text in the input box.

Parameters:input_text – str
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]