Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Here are some examples which demonstrate how to use the Python bindings for ggtag.

If you are on Linux, you may need to install some prerequisites for the ggwave library:

sudo apt install portaudio19-dev python3-pyaudio

Then install all dependencies (preferably into venv) with pip:

pip install -r requirements.txt

demo.py

This script creates a demo tag using the ggtag API:

# Create a demo tag
def create_tag():
    tag = ggtag.GGTag()
    tag.text(204, 122, 3, "ggtag")
    tag.icon(212, 81, 34, "wifi")
    tag.rect(198, 74, 70, 70)
    tag.rect(68, 74, 82, 82)
    tag.qrcode(71, 77, 3, "https://ggtag.io/demo.html")
    tag.text(43, 186, 5, "https://ggtag.io")
    return tag

To program the tag with sound use:

$ ./demo.py sound

To program the tag with USB serial use:

$ ./demo.py serial

To open the tag in a browser:

$ ./demo.py browser

To save the tag in PNG and ASCII:

$ ./demo.py save

badge.py

Creates a badge-like tag for a GitHub user. Some examples are octocat, antirez, ggerganov, rgerganov.

For best results, we suggest to create a personal access token on GitHub and export it as GITHUB_TOKEN environment variable.

$ export GITHUB_TOKEN=<your-github-token>
$ ./badge.py <github-username>
# You can replace the profile picture with QR code, so you can program the tag with sound:
$ ./badge.py --qrcode <github-username>

If you don't set GITHUB_TOKEN, the script will try to fetch and parse the profile information from GitHub website, which is less reliable.

img.py

Creates a tag with PNG image specified either as local file or URL:

# Create a tag with PNG image specified as local file
$ ./img.py mario.png
# Create a tag with PNG image specified as URL
$ ./img.py 'https://ggtag.io/mario.png'