simplegui_lib_draw — draw functions

(Version saved in CodeSkulptor https://py3.codeskulptor.org/#user305_SaT1YKoOikl4ax9.py .)

simplegui_lib_draw module.

Draw functions to help in SimpleGUI of CodeSkulptor.

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

license

GPLv3 — Copyright (C) 2013, 2015, 2020 Olivier Pirson

author

Olivier Pirson — http://www.opimedia.be/

version

May 19, 2020

SimpleGUICS2Pygame.simplegui_lib_draw.draw_rect(canvas: simplegui.Canvas, pos: Sequence[Union[int, float]], size: Sequence[Union[int, float]], line_width: int, line_color: str, fill_color: str = None) None[source]

Draw a rectangle.

Parameters
  • canvas – simplegui.Canvas

  • pos – (int or float, int or float) or [int or float, int or float]

  • size – (int or float, int or float) or [int or float, int or float]

  • line_width – int >= 0

  • line_color – str

  • fill_color – str

SimpleGUICS2Pygame.simplegui_lib_draw.draw_text_multi(canvas: simplegui.Canvas, text: Union[str, Sequence[str]], point: Sequence[Union[int, float]], font_size: Union[int, float], font_color: str, font_face: str = 'serif', _font_size_coef: Union[int, float] = 0.75) None[source]

Draw the text (possibly with several lines) at the position point.

If text is a str, then split it on each end of line.

If text is a tuple or a list of str, then print each str on a separated line.

See simplegui.draw_text() .

Parameters
  • canvas – simplegui.Canvas

  • text – str or (tuple of str) or (list of str)

  • point – (int or float, int or float) or [int or float, int or float]

  • font_size – (int or float) >= 0

  • font_color – str

  • font_face – str == ‘monospace’, ‘sans-serif’, ‘serif’

  • _font_size_coef – int or float

Raise

ValueError if text contains unprintable whitespace character

SimpleGUICS2Pygame.simplegui_lib_draw.draw_text_side(frame: simplegui.Frame, canvas: simplegui.Canvas, text: str, point: Sequence[Union[int, float]], font_size: Union[int, float], font_color: str, font_face: str = 'serif', font_size_coef: Union[int, float] = 0.75, rectangle_color: Optional[str] = None, rectangle_fill_color: Optional[str] = None, side_x: Union[int, float] = - 1, side_y: Union[int, float] = 1) None[source]

Draw the text string at the position point.

See simplegui.draw_text() .

If rectangle_color != None then draw a rectangle around the text.

If rectangle_fill_color != None then draw a filled rectangle under the text.

If side_x
< 0 then point[0] is the left of the text,
== 0 then point[0] is the center of the text,
> 0 then point[0] is the right of the text.
If side_y
< 0 then point[1] is the top of the text,
== 0 then point[1] is the center of the text,
> 0 then point[1] is the bottom of the text.
Parameters
  • frame – simplegui.Frame

  • canvas – simplegui.Canvas

  • text – str

  • point – (int or float, int or float) or [int or float, int or float]

  • font_size – (int or float) >= 0

  • font_color – str

  • font_face – str == ‘monospace’, ‘sans-serif’, ‘serif’

  • font_size_coef – int or float

  • rectangle_color – None or str

  • rectangle_fill_color – None or str

  • side_x – int or float

  • side_y – int or float

[source]