Python package for visualizing family trees using graphviz.
Project description
Python Family Tree Visualizing
This is library for visualizing family trees in Python using graphviz. It allows you to create and visualize family trees with ease. The library supports various formats for output, including PDF, JPG, and more. You can customize the appearance of the tree, including node labels and colors.
Features
- Generate family trees in various formats (PDF, JPG, etc.)
- Support for different types of tree generations (e.g., normal, with ancestors, full , circle)
- Customizable node labels and colors
- See relationships between nodes (example: great great grandfather's first son's partner)
Why
So, I have a telegram bot which kind of generates family trees for like 3 years now. I wanted to make it open source and I thought it would be a good idea to make a library for it. So, here we are. This is extracted version from my bot. Also, The Family Tree lies between tree and graph, I tried to find solutions but I couldn't find any. also, family tree + graphviz = family tree viz ! compared to pydot, it has slightly less overhead, hence better performance.
Installation
pip install family-tree-viz
You need to install graphviz for your system. Linux: Debian/Ubuntu:
sudo apt-get install graphviz
Fedora:
sudo dnf install graphviz
Windows: Install from releases: Graphviz releases then install and check it by typing
dot -V
Usage
Sample Usage:
import asyncio
from family_tree_generator import FamilyTreeGenerator, FamilyTreeMember, TreeType
async def main():
t1 = FamilyTreeMember(1,label="T1")
t2 = FamilyTreeMember(2,label="T2")
t1.add_child(t2)
generator = FamilyTreeGenerator()
image = await generator.generate(t1,TreeType.QUICK)
image.show()
# if you want to save it
image.save("family_tree.jpg")
asyncio.run(main())
this will generate a simple family tree with two members and display it.
Detailed Usage:
You can use multiple formats
image = await generator.generate(t1,TreeType.QUICK,format="pdf")
jpg, pdf,svg,json & png are supported
You can save directly to file
image = await generator.generate(t1,TreeType.QUICK,format="pdf",output_path="family_tree.pdf")
it'll append extension if it's not there.
There are 4 types of trees you can generate:
- QUICK: find the root node of current tree and generate a tree with it as the root node. (Aka add from ancestors and descendants)
- FAMILY: current node is taken as root node and all children are added to it. (aka only show your family + descendants)
- FULL: Expand in all directions, cover all nods in connected tree. (Cover everyone in the family tree)
- CUSTOM: A customizable tree generation method that allows for more complex structures.
- FRIEND_CIRCLE: A tree generation method that represents a friend circle.
The friend circle looks like this:
image = await generator.generate(t1,TreeType.FRIEND_CIRCLE)
You can also add images. documentation soon. You can also customize colors. documentation soon.
You can also see relationship between nodes Documentation soon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file family_tree_viz-0.1.0.tar.gz.
File metadata
- Download URL: family_tree_viz-0.1.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f677c094855817fd8331e60b4da41593906f5c3dc8620cd04031f18278a69f8f
|
|
| MD5 |
9e5c62db2082c31c5eeede8affc9f598
|
|
| BLAKE2b-256 |
442363127baf48dbf9046fac3003f701fd81735a8081b598a0dcb6f905c87c44
|
File details
Details for the file family_tree_viz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: family_tree_viz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c40d80639815a90efc96a980f8ee6cc8aa9b68bcfbf2f7390970995a0fbd9db
|
|
| MD5 |
ee2a637be113b3fc4770c7c7a3f80278
|
|
| BLAKE2b-256 |
69f9b40e2bdfafb35b06af4acac67dc0cd87427dab724f6cab1bcd5d9f4a7b62
|