Skip to main content

Elements that scale with screensize for pygame

Project description

PyGameElements so you dont have to make a gui for pygame every time you write a game

PyGameElements provides you with a way to use elements that scale along with the screen size.

Overview

There are several elements available at this moment:

Core elements (consisting of one thing): Line, Square, Ellipse, Label, Image

Combined elements (consisting of more then one core elements): Button, CheckBox, InputBox

Usage

In the following paragraphs, I am going to describe how you can get and use PyGameElements for your own projects.

Getting it

To download PyGameElements, either fork this github repo or simply use Pypi via pip.

$ pip install pygameElements

Testing it

from testPygameElements import testPygameElements
testPygameElements()

To see an example of what you can do with the elements. You can inspect the file yourself at C:\Users\YOURNAME\AppData\Roaming\Python\YOURPYTHONVERSION\site-packages\pygameElements to see how it works.

Example Square Element

Using it

from pygameElements import *

Here are the variables you can set with each element along with its defaults:

class Line(): def init(self, blitToSurface=None, gameState='', name='', color=(255,255,255), startPosPromille=(0,0), endPosPromille=(1000,1000), widthLine=5, alphaValue=255, visible=True):

class Square(): def init(self, blitToSurface=None, gameState='', name='', color=(255,255,255,255), horizontalMiddlePromille=500, verticalMiddlePromille=500, horizontalSizePromille=100, verticalSizePromille=400, widthBorder=0, borderTopLeft=1, borderTopRight=1, borderBottomLeft=1, borderBottomRight=1, alphaValue=255, visible=True):

class Ellipse(): def init(self, blitToSurface=None, gameState='', name='', color=(255,255,255), horizontalMiddlePromille=500, verticalMiddlePromille=500, horizontalSizePromille=500, verticalSizePromille=500, widthBorder=0, alphaValue=255, visible=True):

class Label(): def init(self, blitToSurface=None, gameState='', name='', text='', colorText=(255,255,255), horizontalMiddlePromille=500, verticalMiddlePromille=500, sysFont=True, fontName='timesnewroman', fontSizePromille=100, isBold=False, isItalic=False, antiAlias=True, alphaValue=255, visible=True, rotation=0):

class Image(): def init(self, blitToSurface=None, gameState='', name='', fileName='', horizontalMiddlePromille=500, verticalMiddlePromille=500, horizontalSizePromille=500, verticalSizePromille=500, rotation=0, stretch=True, alphaValue=255, visible=True):

class Button(): def init(self, blitToSurface=None, gameState='', name='', horizontalMiddlePromille=500, verticalMiddlePromille=500, horizontalSizePromille=500, verticalSizePromille=100, colorNormal=(190,190,190), colorHasFocus=(190,255,190),colorMouseOver=(190,190,255),colorMouseDown=(255,190,190), value=None, alphaValue=255, hasFocus=False, visible=True, onClick=None, text='button', enabled=True, sysFont=True, fontName='timesnewroman', fontSizePromille=80, antiAlias=True):

class CheckBox(): def init(self, blitToSurface=None, gameState='', name='', horizontalMiddlePromille=500, verticalMiddlePromille=500, horizontalSizePromille=500, verticalSizePromille=500, inColor=(190,190,190), outColor=(135,135,135), tickColor=(100,100,100), alphaValue=255, widthMargin=5, widthBorder=5, value=True, hasFocus=False, visible=True, onClick=None):

class InputBox(): def init(self, blitToSurface=None, gameState='', name='', text='', colorText=(255,255,255), horizontalMiddlePromille=500, verticalMiddlePromille=500, sysFont=True, fontName='timesnewroman', fontSizePromille=100, isBold=False, isItalic=True, antiAlias=True, alphaValue=255, visible=True, hasFocus=False, onClick=None, maxSize=15):

License

MIT License

Copyright (c) 2020 Bas Koning

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Hire us: basknng@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygameelements-0.1.56.tar.gz (155.6 kB view details)

Uploaded Source

Built Distribution

pygameelements-0.1.56-py3-none-any.whl (155.6 kB view details)

Uploaded Python 3

File details

Details for the file pygameelements-0.1.56.tar.gz.

File metadata

  • Download URL: pygameelements-0.1.56.tar.gz
  • Upload date:
  • Size: 155.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for pygameelements-0.1.56.tar.gz
Algorithm Hash digest
SHA256 40ab98d702e96120d556a9c80b143975d3c70a8e7f5cbf3cdb3fba9030f1f977
MD5 f3311798a020450e51db622fbac95d80
BLAKE2b-256 818d9655118718ac3d3ee41fd32404310a922f497977dc872f077281abd51f55

See more details on using hashes here.

File details

Details for the file pygameelements-0.1.56-py3-none-any.whl.

File metadata

  • Download URL: pygameelements-0.1.56-py3-none-any.whl
  • Upload date:
  • Size: 155.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for pygameelements-0.1.56-py3-none-any.whl
Algorithm Hash digest
SHA256 82d8e87cafae11aabcc1b946243904b86dbe7719c20b2abee28c0c1e96f74f04
MD5 997f8b31cb2880b65d693fb80dcb7306
BLAKE2b-256 053a259f2e6e8d3459776ec3f05fc21b6b1315a5b0950e42044b5f3d4cef00a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page