-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-29: Adding pylint config and initial progress on pylint fixes for …
…the pygame_gui package. Deleted unused pygame_gui.Cursor element.
- Loading branch information
Showing
7 changed files
with
155 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[MASTER] | ||
|
||
# Custom pylint overrides for the project | ||
disable= | ||
too-many-arguments, | ||
too-many-instance-attributes, | ||
too-few-public-methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
""" | ||
A custom set of general UI elements. | ||
Classes: | ||
Text | ||
Image | ||
Button | ||
Checkbox | ||
Entry | ||
Panel | ||
TextButton | ||
""" | ||
|
||
from pygame_gui.text import * | ||
from pygame_gui.image import * | ||
from pygame_gui.button import * | ||
from pygame_gui.checkbox import * | ||
from pygame_gui.entry import * | ||
from pygame_gui.cursor import * | ||
from pygame_gui.panel import * | ||
from pygame_gui.text_button import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,34 @@ | ||
""" | ||
A module holding the pygame_gui Image class. | ||
Classes: | ||
Image | ||
""" | ||
|
||
import pygame | ||
|
||
|
||
class Image: | ||
""" An Image class to hold and display a pygame.image instance. """ | ||
def __init__(self, image_ref, x, y): | ||
""" | ||
Parameters: | ||
image_ref - A file path to the image to load and use. | ||
x - The x position to use for the image, in px. | ||
y - The y position to use for the image, in px. | ||
""" | ||
|
||
self.image = pygame.image.load(image_ref).convert_alpha() | ||
self.rect = self.image.get_rect() | ||
self.rect.x = x | ||
self.rect.y = y | ||
|
||
def draw(self, display): | ||
""" | ||
Blit the image to the given pygame display. | ||
Parameters: | ||
display - A pygame.display instance. | ||
""" | ||
|
||
display.blit(self.image, self.rect.topleft) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,65 @@ | ||
""" | ||
A module holding the pygame_gui Panel class. | ||
Classes: | ||
Panel | ||
""" | ||
|
||
import pygame | ||
|
||
|
||
class Panel: | ||
""" | ||
A Panel class used to display a simple rectangle 'panel' element. | ||
""" | ||
def __init__(self, rect, transparency, colour): | ||
""" | ||
Parameters: | ||
rect - A pygame.Rect compatible declaration such as [x, y, width, height]. | ||
transparency - An alpha value 0 to 255 used to set the Panel opacity. | ||
colour - A valid pygame colour in the form (red, green blue). | ||
""" | ||
|
||
self.rect = pygame.Rect(rect) | ||
self.colour = colour | ||
self.transparency = transparency | ||
self.surface = self.make_surface() | ||
|
||
def reset_rect(self, rect): | ||
""" | ||
Reset the Panel.rect value using the new rect value supplied. | ||
Parameters: | ||
rect - Should be a valid pygame.Rect argument. | ||
""" | ||
|
||
self.rect = pygame.Rect(rect) | ||
self.surface = self.make_surface() | ||
|
||
def reset_width(self, width): | ||
""" | ||
Reset the Panel.rect.width value using the new width value supplied. | ||
Parameters: | ||
width - The new width as an integer. | ||
""" | ||
|
||
self.rect.width = width | ||
self.surface = self.make_surface() | ||
|
||
def make_surface(self): | ||
""" Create a surface that is used when displaying the Panel itself. """ | ||
surface = pygame.Surface([self.rect[2], self.rect[3]]) | ||
surface.set_alpha(self.transparency) | ||
return surface | ||
|
||
def draw(self, display): | ||
""" | ||
Blit the panel surface to the given pygame display. | ||
Arguments: | ||
display - A pygame.display instance. | ||
""" | ||
|
||
self.surface.fill(self.colour) | ||
display.blit(self.surface, [self.rect[0], self.rect[1]]) |