this was a fun experimante in the 2023 ccc camp, people printed a lot of stickers.
live at > https://print.tami.sh
it currntly a mini obsession. it can do a few things and more to come.
- print images (dithered as its a b/w thing)
- print labels, with QR codes if url provided
- print masks for PCB DIY etching(!), use the transparent ones for best resualts (WIP)
- print text2image using stable diffusion API
- print cats
started as a fork of brother_ql_web and his brother_ql printer driver, this driver is maintained and developed by matmair
network access by the openziti/zrok projects
- wrap text for printing paragraphs
- ???
- profit
Install uv:
uv sync
uv run streamlit run printit.py --server.port 8989Or with pip:
pip install -r requirements.txt
streamlit run printit.py --server.port 8989we use the zrok.io to secure a static url.
```bash
zrok reserve public 8989
zrok share reserved xxxxxx
add you service to keep it alive. change <user> with your username. or any path to the printit folder.
create at /etc/systemd/system/sticker_zrok.service
[Unit]
Description=sticker factory
After=network.target
[Service]
ExecStart=/bin/bash -c 'source /home/<user>/printit/venv/bin/activate && /usr/bin/uv run streamlit run printit.py --server.port 8989'
WorkingDirectory=/home/<user>/printit
Environment="PATH=/home/devdesk/<user>/printit/venv/bin/python"
Restart=always
User=<user>
Group=<user>
[Install]
WantedBy=multi-user.targetsudo systemctl deamon-reload
sudo systemctl enable sticker.service
sudo systemctl start sticker.service
#debug using
sudo journalctl -u sticker.service --follow
sudo journalctl -u botprint.service --follow
we use the zrok.io to secure a static url.
zrok reserve public 8988
zrok share reserved kjvrml0bxatqyou can also run a service for this.
to get the brother_ql lib to detect the printer, you need to install a usb filter
- grab release from zdiag
- refresh device list
- install the filter 'lib-winUSB` ,replacing the ql-XXXX driver
- replug the printer
streamlit had made some update with handling widths, pip install --upgrade streamlit if you see something in the line of
Exception in tab Label: '<=' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
File "/home/pi/stikka-factory/printit.py", line 304, in <module>
label_module.render(
File "/home/pi/stikka-factory/tabs/label.py", line 256, in render
st.image(img, width='stretch')
File "/home/pi/printit/venv/lib/python3.11/site-packages/streamlit/runtime/metrics_util.py", line 410, in wrapped_func
result = non_optional_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/printit/venv/lib/python3.11/site-packages/streamlit/elements/image.py", line 154, in image
WidthBehavior.ORIGINAL if (width is None or width <= 0) else width
- Created
config.tomlin workspace root for all application settings (non-sensitive) - Moved settings from
secrets.tomltoconfig.toml: title, label_type, history_limit, items_per_page, queue_view, txt2img_url secrets.tomlnow contains only API keys (cat_api_key)
- Extracted image processing utilities into
image_utils.py - Extracted printer handling utilities into
printer_utils.py - Updated
printit.pyto import from utility modules instead of defining functions locally
- Updated all
st.image()calls to useuse_container_width=Truefor consistent responsive behavior, updating streamlit is maybe needed.
config.toml- Settings fileimage_utils.py- Image processing functionsprinter_utils.py- Printer handling functionsprintit.py- Main app (refactored)tabs/*.py- Tab modules (updated imports)
- disables history tab
- deletes labels
To prevent the printer going to sleep mode use brother_ql installed on the host. You may need to activate the venv to do that.
-
Discover the printer with
brother_ql discover, it returns something likeFound compatible printer QL-600 at: usb://0x04f9:0x20c0/000H2G258173wereusb://0x04f9:0x20c0/000H2G258173is the printer id -
Set the
power-off-delayto 0:brother_ql -p <PRINTER ID> configure set power-off-delay 0. You can check the set valuebrother_ql -p <PRINTER ID> configure get power-off-delay
