Skip to main content

A compilation of utility tools for pygame

Project description

Pygame Utils

A compilation of utility tools (mainly widgets: buttons, checkboxes...) to use with pygame.

Installation

Use the package manager pip to install Pygame Utils.

pip install utils-pygame 

Usage

So far there are 2 widgets: button and checkbox Every widget has a draw function, that draws the widget. To use it simply call yourWidget.draw(win), where yourWidget corresponds to your widget name and win corresponds to your pygame display.

In almost every widget you don't need to specify every single attribute, default values are used instead.

You can run the example.py file to get a general idea of what the widgets look like as well as using it as a reference or template.

Some common concepts across widgets:

  • color: RGB tuple (ex: (125, 100, 200))
  • x: x coordinate
  • y: y coordinate
  • width: width of the widget
  • height: height of the widget
  • text: text associated with the widget
  • size: size of the text
  • font: name of the font to use (make sure it is installed in your system)
  • outline: the outline of the widget

Button

Creating a button:

import PygameUtils as pu
but = pu.button(color, x, y, width, height)

Optional arguments:

  • text
  • size
  • font
  • outline

Interacting with a button:

Using the isOver(pos) function, you can check if a given position ((x, y) tuple, most likely the position of the mouse) is over the button, associating all kinds of pygame events to it (pygame.MOUSEBUTTONDOWN, pygame.MOUSEMOTION).

Checkbox

Creating a checkbox:

import PygameUtils as pu
checkb = pu.checkbox(color, x, y, width, height)

Optional arguments:

  • outline
  • check: if the box starts checked or not (boolean)
  • text
  • size
  • font
  • textGap: the amount of space between the text and the box

Interacting with a checkbox:

Like the button, you can use the isOver(pos) function to check if a given position is over the box.

The convert() function changes the state of the box, from checked to unchecked or vice versa. Most likely you will want to use this function alongside the isOver(pos) function and the pygame.MOUSEBUTTONDOWN event.

The isChecked() function returns the current state of the box (True if checked, False otherwise)

License

MIT

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

utils-pygame-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utils_pygame-0.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file utils-pygame-0.0.1.tar.gz.

File metadata

  • Download URL: utils-pygame-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for utils-pygame-0.0.1.tar.gz
Algorithm Hash digest
SHA256 866de2b82d66ea345e2f05e7c93a829389148fe46891d1a36fff4b4b4dbbff4c
MD5 d10c9d43857cf2516ca9df5ff5463f17
BLAKE2b-256 8f526c9f68df633cc414a38041d701efefd6955abb66fc2e763f9d79ab6b68a8

See more details on using hashes here.

File details

Details for the file utils_pygame-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: utils_pygame-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for utils_pygame-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dc675e0574defc4ac6f88429e696eb4b1a6b3ac267ad2d6b92af62725571540
MD5 c7460fba0895aef03ec0db22b7b698f0
BLAKE2b-256 d20e596aa10df9c99ef64124d6d6e4dbc9c4b12b74c675dda234023c17101ba1

See more details on using hashes here.

Supported by

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