simpleguics2pygame — control

simpleguics2pygame/control (April 29, 2016)

Classes Control and TextAreaControl.

Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 — Copyright (C) 2015, 2016 Olivier Pirson http://www.opimedia.be/

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
_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.)

_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
__weakref__

list of weak references to the object (if defined)

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
_draw()[source]

Draw the input box and his label.

(Not available in SimpleGUI of CodeSkulptor.)

_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
_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
__weakref__

list of weak references to the object (if defined)

SimpleGUICS2Pygame.simpleguics2pygame.control.__all__ = ['Control', 'TextAreaControl']

list() -> new empty list list(iterable) -> new list initialized from iterable’s items

[source]