Pygame package to easily create dialog boxes for games.
Text and dialog box package for games created with Pygame.
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.
- Create virtual environment:
python -m venv [dir]
- Activate the virtual environment:
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 https://github.com/hnrkcode/TextBoxify.git 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
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( text=dialog_text, text_width=320, lines=2, pos=(80, 180), padding=(150, 100), font_color=(92, 53, 102), font_size=26, 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
To activate the textbox you then add the text box object to the sprite group.
if not dialog_group: dialog_group.add(dialog_box)
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: dialog_box.reset()
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
dialog_box.reset(hard=True) 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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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 hashes|
|Filename, size textboxify-0.3.1.tar.gz (18.8 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for textboxify-0.3.1-py3-none-any.whl