button module

class ui.button.Button(x, y, color, background_color, screen, size=32)

Bases: object

button class

Parameters
  • x (int) -- x position of button

  • y (int) -- y position of button

  • color (tupple of three int between 0 and 255) -- color of button (text)

  • background_color (tupple of three floats between 0 and 1) -- color of button (background)

  • screen (pygame.Surface) -- surface

  • size (int, optional) -- size of text, defaults to 32

collide(pos)

check collision with button

Parameters

pos ((int x, int y), x and y are the position of the mouse pointer) -- mouse position

Returns

True if collision, otherwise false

Return type

bool

drawButton()

draw the button

initButton(label, center=False)

init button

Parameters
  • label (string) -- text of button

  • center (bool, optional) -- if True => center the button (x, y are now center of the button), defaults to False