Skip to content

Commit 16167af

Browse files
update code
1 parent a5d5af1 commit 16167af

File tree

5 files changed

+49
-22
lines changed

5 files changed

+49
-22
lines changed

src/wmwpy/classes/database.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def export(this, filename : str = None) -> bytes:
8484
return file.rawdata.getvalue()
8585

8686
def execute(this, *args):
87-
"""Execute sql on the database. See sqlite3.Cursor.execute for paramaters.
87+
"""Execute sql on the database. See sqlite3.Cursor.execute for parameters.
8888
8989
Args:
9090
The arguments for sqlite3.Cursor.execute()

src/wmwpy/classes/imagelist.py

+36-9
Original file line numberDiff line numberDiff line change
@@ -459,19 +459,17 @@ def getAtlas(this):
459459
"""Get atlas image.
460460
"""
461461
if this.file in ['', None]:
462-
image = Texture(PIL.Image.new('RGBA', this.imgSize))
463-
this.atlas = image.image.copy()
462+
this.atlas = Texture(PIL.Image.new('RGBA', this.imgSize)).image
464463
else:
465-
image = Texture(
464+
this.atlas = Texture(
466465
this.file,
467466
HD = this.HD,
468467
TabHD = this.TabHD,
469468
filesystem = this.filesystem,
470469
gamepath = this.gamepath,
471470
assets = this.assets,
472471
baseassets = this.baseassets,
473-
)
474-
this.atlas = image.image.copy()
472+
).image
475473

476474
def getImages(this, save_images = False):
477475
"""Get images from xml.
@@ -682,6 +680,16 @@ def _updateAtlas(this) -> PIL.Image.Image:
682680
atlas.paste(image.image, image.rect[0:2])
683681

684682
this.atlas = atlas
683+
684+
# this.atlas = Texture(
685+
# atlas,
686+
# filesystem = this.filesystem,
687+
# gamepath = this.gamepath,
688+
# assets = this.assets,
689+
# baseassets = this.baseassets,
690+
# HD = this.HD,
691+
# TabHD = this.TabHD,
692+
# )
685693
return this.atlas
686694

687695
class Image(GameObject):
@@ -793,7 +801,7 @@ def rect(this, value : tuple | list | str):
793801

794802
@property
795803
def name(this) -> str:
796-
"""The name of the iamge
804+
"""The name of the image
797805
798806
Returns:
799807
str: image name
@@ -835,10 +843,29 @@ def getImage(this) -> PIL.Image.Image:
835843
this._image.save(this.rawdata, format = os.path.splitext(this.name)[1][1::].upper())
836844
return this._image
837845

838-
def show(this):
839-
"""Show image with default image viewer.
846+
def show(this, *args, **kwargs):
847+
"""Calls the PIL.Image.Image.show() method.
848+
849+
---
850+
#### Description copied from the PIL library
851+
852+
Displays this image. This method is mainly intended for debugging purposes.
853+
854+
This method calls PIL.ImageShow.show internally. You can use
855+
PIL.ImageShow.register to override its default behavior.
856+
857+
The image is first saved to a temporary file. By default, it will be in PNG format.
858+
859+
On Unix, the image is then opened using the **display**, **eog** or **xv** utility, depending on which one can be found.
860+
861+
On macOS, the image is opened with the native Preview application.
862+
863+
On Windows, the image is opened with the standard PNG display utility.
864+
865+
Args:
866+
title (str | None, optional): Optional title to use for the image window, where possible.. Defaults to None.
840867
"""
841-
this.image.show()
868+
this.image.show(*args, **kwargs)
842869

843870
def getXML(this, tag = 'Image'):
844871
"""Get xml for image.

src/wmwpy/classes/level.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def addObject(
376376
filename (str | Object): Filename for object. If it's a wmwpy.classes.Object class, then it will use that instead.
377377
properties (dict, optional): Object properties. Defaults to {}.
378378
pos (tuple[x,y], optional): Position of object in level. Defaults to (0,0).
379-
name (str, optional): Name of object. May get renamed if object with name alread exists. Defaults to 'Obj'.
379+
name (str, optional): Name of object. May get renamed if object with name already exists. Defaults to 'Obj'.
380380
381381
Returns:
382382
Object: wmwpy Object.
@@ -487,7 +487,7 @@ def readXML(this):
487487
this.id = this.xml.get('id', '')
488488

489489
for element in this.xml:
490-
# so I can acess the attributes in vscode
490+
# so I can access the attributes in vscode
491491
element : etree.ElementBase
492492

493493
if element is etree.Comment:

src/wmwpy/classes/object.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def foreground(this) -> Image.Image:
303303

304304
@property
305305
def foreground_PhotoImage(this) -> 'ImageTk.PhotoImage':
306-
"""Foregound Tkinter PhotoImage
306+
"""Foreground Tkinter PhotoImage
307307
308308
Returns:
309309
ImageTk.PhotoImage: Tkinter PhotoImage
@@ -557,7 +557,7 @@ def getLevelXML(
557557

558558
@property
559559
def filename(this) -> str | None:
560-
"""Object filename based on the `Filename` proprty
560+
"""Object filename based on the `Filename` property
561561
"""
562562
if 'Filename' in this.properties:
563563
return this.properties['Filename']
@@ -757,7 +757,7 @@ def saveGIF(
757757
filename = this.name if this.name not in ['', None] else this.type if this.type not in ['', None] else os.path.basename(this.filename)
758758
filename = os.path.splitext(filename)[0] + '.gif'
759759

760-
print(f'{filename = }')
760+
# print(f'{filename = }')
761761

762762
animation = this.getAnimation(
763763
duration = duration,

src/wmwpy/classes/sprite.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def image(this) -> Image.Image:
135135
image = this.animation.image.copy()
136136
gridSize = numpy.array(this.gridSize)
137137

138-
print(f'{gridSize = }')
139-
print(f'{this.scale = }')
138+
# print(f'{gridSize = }')
139+
# print(f'{this.scale = }')
140140

141141
size = gridSize * this.scale
142142
size = [abs(round(x)) for x in size]
@@ -869,7 +869,7 @@ class Frame(GameObject):
869869
870870
Attributes:
871871
atlas (Imagelist): The atlas for this Frame.
872-
textueBasePath (str): The textureBasePath for this Frame.
872+
textureBasePath (str): The textureBasePath for this Frame.
873873
properties (dict[str,str]): The frame properties.
874874
"""
875875

@@ -897,7 +897,7 @@ def __init__(
897897
super().__init__(filesystem, gamepath, assets, baseassets)
898898

899899
this.atlas = atlas
900-
this.textueBasePath = textureBasePath
900+
this.textureBasePath = textureBasePath
901901
this.properties = properties
902902

903903
this.color_filter : tuple[int,int,int,int] = []
@@ -1150,7 +1150,7 @@ def getXML(this) -> etree.ElementBase:
11501150
this.updateProperties()
11511151
return etree.Element('Frame', **this.properties)
11521152

1153-
def show(this, title: str | None = None):
1153+
def show(this, *args, **kwargs):
11541154
"""Calls the PIL.Image.Image.show() method.
11551155
11561156
---
@@ -1159,7 +1159,7 @@ def show(this, title: str | None = None):
11591159
Displays this image. This method is mainly intended for debugging purposes.
11601160
11611161
This method calls PIL.ImageShow.show internally. You can use
1162-
PIL.ImageShow.register to override its default behaviour.
1162+
PIL.ImageShow.register to override its default behavior.
11631163
11641164
The image is first saved to a temporary file. By default, it will be in PNG format.
11651165
@@ -1172,4 +1172,4 @@ def show(this, title: str | None = None):
11721172
Args:
11731173
title (str | None, optional): Optional title to use for the image window, where possible.. Defaults to None.
11741174
"""
1175-
return this.image.show(title = title)
1175+
return this.image.show(*args, **kwargs)

0 commit comments

Comments
 (0)