Skip to main content

Pygame package to easily create dialog boxes for games.

Project description


Text and dialog box package for games created with Pygame.

made-with-pygame Generic badge

dialog box

TextBoxify is a package for easily creating text and dialog boxes in Python games written in Pygame. The package is aiming to give the users of the package a lot of control when it comes to designing the look and feel of their boxes.


Install textboxify from Python Package Index: pip install textboxify


It's recommended to install the package in a virtual environment to avoid conflicts with different versions of the same packages.

  1. Create virtual environment:

python -m venv [dir]

  1. Activate the virtual environment:

source [dir]/bin/activate

  1. Installation:

To install the code from Github, clone the repository and install it in editable mode -e to edit the code without having to reinstall it for the changes to have effect.

git clone
cd TextBoxify
pip install -r requirements.txt -e .


To use the package just write import textboxify in your python modules and start using it.


This example is based of the code in examples/

This is how you could initialize and customize a dialog box with TextBoxFrame, which creates a dialog box with a border and optional features like animated portrait and idling symbol.

dialog_box = textboxify.TextBoxFrame(
    pos=(80, 180),
    padding=(150, 100),
    font_color=(92, 53, 102),
    bg_color=(173, 127, 168),

Add these two lines to create a symbol indicating that the box is idle and a picture representing the character talking.


To implement the text box you could add it to a sprite group, like pygame.sprite.LayeredDirty because the text boxes are subclasses of pygame.sprite.DirtySprite.

To activate the textbox you then add the text box object to the sprite group.

if not dialog_group:

You can check if all words has pin printed, if there are still words to print, you can continue printing the remaining words by reseting the box so the words in the box are erased like this.

if dialog_box.words:

If there isn't any words left to print you can close the box with.


That will deactivate the box and remove it from the sprite group. If you want to reuse the text box, you should first call reset(hard=True) and if you also want to set a new message call set_text().

dialog_box.set_text("Happy coding!")

For a working example of how to implement textboxify see the example module.


Run all tests:

python -m unittest discover -v tests or python -m unittest -v tests/test_*.py

Run specific tests:

python -m unittest -v tests.test_settings

python -m unittest -v tests.test_settings.TestSettings

python -m unittest -v tests.test_settings.TestSettings.test_file_exists

Project details

Download files

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

Files for textboxify, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size textboxify-0.3.1-py3-none-any.whl (24.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size textboxify-0.3.1.tar.gz (18.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page