Added some comments and descriptions.
This commit is contained in:
parent
80af2234a6
commit
67424f067f
1 changed files with 15 additions and 0 deletions
15
pg.py
15
pg.py
|
@ -22,6 +22,9 @@ default_font = pygame.font.Font(pygame.font.get_default_font(), 16)
|
||||||
|
|
||||||
|
|
||||||
class Hover:
|
class Hover:
|
||||||
|
"""
|
||||||
|
Used to execute a function when the mouse hovers over a rectangle.
|
||||||
|
"""
|
||||||
def __init__(self, rect: pygame.Rect, function=None, args: tuple=None):
|
def __init__(self, rect: pygame.Rect, function=None, args: tuple=None):
|
||||||
self.rect = rect
|
self.rect = rect
|
||||||
self.function = function
|
self.function = function
|
||||||
|
@ -47,6 +50,9 @@ class Hover:
|
||||||
|
|
||||||
|
|
||||||
class Button:
|
class Button:
|
||||||
|
"""
|
||||||
|
Creates a button from a pygame.Rect.
|
||||||
|
"""
|
||||||
def __init__(self, rect: pygame.Rect, function=None, args: tuple=None, key: int=0): # key: 0 = left 1 = mouse wheel pressed 2 = right
|
def __init__(self, rect: pygame.Rect, function=None, args: tuple=None, key: int=0): # key: 0 = left 1 = mouse wheel pressed 2 = right
|
||||||
self.rect = rect
|
self.rect = rect
|
||||||
self.function = function
|
self.function = function
|
||||||
|
@ -69,6 +75,9 @@ class Button:
|
||||||
|
|
||||||
|
|
||||||
class TextButton:
|
class TextButton:
|
||||||
|
"""
|
||||||
|
Creates a button from just some string and a position.
|
||||||
|
"""
|
||||||
def __init__(self, text: str, position: tuple, function=None, args: tuple=None, key: int=0, text_color: tuple=white, bg_color: tuple=gray, font: pygame.font.Font=default_font, padding: tuple=(8, 8), border_radius: int=0, line_thickness: int = 0):
|
def __init__(self, text: str, position: tuple, function=None, args: tuple=None, key: int=0, text_color: tuple=white, bg_color: tuple=gray, font: pygame.font.Font=default_font, padding: tuple=(8, 8), border_radius: int=0, line_thickness: int = 0):
|
||||||
self.text = text
|
self.text = text
|
||||||
self.position = position
|
self.position = position
|
||||||
|
@ -121,6 +130,9 @@ class TextButton:
|
||||||
|
|
||||||
|
|
||||||
class TextInput:
|
class TextInput:
|
||||||
|
"""
|
||||||
|
Creates an input object at a given position.
|
||||||
|
"""
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
position: Union[tuple, Callable],
|
position: Union[tuple, Callable],
|
||||||
|
@ -431,6 +443,9 @@ class MultilineText:
|
||||||
|
|
||||||
|
|
||||||
def set_rot_point(img, pos):
|
def set_rot_point(img, pos):
|
||||||
|
"""
|
||||||
|
Blits the image on an empty surface to change the center of rotation.
|
||||||
|
"""
|
||||||
w, h = img.get_size()
|
w, h = img.get_size()
|
||||||
w, h = w * 2, h * 2
|
w, h = w * 2, h * 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue