mentipy
mentipy is a lightweight, self-hosted classroom-polling library for LaTeX
presentations. It generates LaTeX snippets and QR codes for audience questions,
then runs a local HTTP server that collects responses in a local JSON store.
It is meant for lectures where you want Mentimeter-style interaction without a cloud service: put polls in the lecture source, compile the slides or handout, serve the poll locally, and let students answer by scanning the QR code.
Basic Workflow
- Render questions from PythonTeX or from the
mentipy renderCLI. - Compile the LaTeX document so the generated QR codes are embedded.
- Start the polling server with
mentipy serve --store ./mentipy.json. - Let respondents scan the QR codes and answer the questions.
- Watch or export answers with
mentipy watch,mentipy export, or the live results page.
The examples below keep state in ./mentipy.json and write QR artifacts in
mentipy-obj/.
Authoring a Poll
Both authoring paths produce the same kind of LaTeX fragment. Use the Python helpers when your document build already runs PythonTeX; use the CLI when you want to inspect or redirect the generated LaTeX yourself.
PythonTeX-style authoring:
from mentipy.latex import mc
print(
mc(
"How confident do you feel about the course goals?",
["Very confident", "Somewhat confident", "Not yet"],
base_url="http://localhost:8080",
qr_dir="mentipy-obj",
layout="article+qr",
)
)
The matching CLI command:
mentipy render mc "How confident do you feel about the course goals?" \
"Very confident" "Somewhat confident" "Not yet" \
--base-url http://localhost:8080 \
--qr-dir mentipy-obj \
--layout article+qr
The CLI prints LaTeX to standard output, so you can redirect it into a file:
mentipy render mc "Ready for the next section?" \
"Yes" "Need a recap" "Not yet" > poll.tex
Question Kinds
Use the question kind that matches the response shape you want to collect.
| Response shape | Python helper | CLI command |
|---|---|---|
| One listed option | mc(text, options) |
mentipy render mc TEXT OPTION... |
| Several listed options | mc(text, options, multi=True) |
mentipy render mc --multi TEXT OPTION... |
| Free text | open_text(text) |
mentipy render open TEXT |
| Numeric scale | scale(text, low=1, high=5) |
mentipy render scale TEXT --low 1 --high 5 |
| Word cloud | word_cloud(text) |
mentipy render word-cloud TEXT |
Open-text questions can also collect uploaded files. Pass fence="python" or
--fence python when uploaded code should be rendered as a language-tagged
Markdown code block on the results page.
Word-cloud questions default to render="svg". Installing
mentipy[wordcloud] lets that mode use the optional wordcloud layout engine;
without it, mentipy falls back to its built-in SVG renderer.
Layout and LaTeX Integration
Rendering options control the LaTeX wrapper without changing the poll identity.
| Option | Purpose |
|---|---|
layout="slide" / --layout slide |
Render for presentation slides. |
layout="article" / --layout article |
Render a flat, transparent article-style question: the prompt alone, in the running text's weight; no options, form instructions, limits or QR. |
layout="article+qr" / --layout article+qr |
Include the QR image beside the article-style question. |
layout="auto" / --layout auto |
Let mentipy choose from the surrounding context. |
environment="exercise" / --env exercise |
Wrap the question in an existing LaTeX environment. |
show_url=False / --no-url |
Suppress the printed respondent URL when the layout supports it. |
The QR layouts print the respondent URL through the LaTeX macro
\mentipyqrcaption{URL} (default \footnotesize\ttfamily). Redefine it in
your preamble to change the caption's size or allow line breaks, for example
\newcommand{\mentipyqrcaption}[1]{{\tiny\url{#1}}}. Do not replace the
sidecar \input with your own text: that copy is frozen at compile time and
stops following mentipy serve.
The named LaTeX environment must already be defined by your document class or
preamble. For example, a lecture note template can use environment="exercise"
to reuse its existing exercise styling and counters.
Serving Polls
After the questions have been registered during rendering, start the local server:
mentipy serve --store ./mentipy.json
For a lecture, mentipy present starts the same server and, in the same
terminal, follows the question the lecturer opens (as a bare
mentipy watch does, see below). It takes all of serve's options and
watch's --interval, --window and --pin-heat. It reprints the
start-up lines (address, QR warning, admin link) and a count of server
warnings at the top whenever it redraws, that is on every new question
and every refresh of a tally; an open question's answers are appended
below instead, so there they can scroll away. Keep that terminal off
the projector:
mentipy present --store ./mentipy.json
mentipy present --store ./mentipy.json --public ssh
Once the server listens, present also opens its admin index in your
browser and goes straight on to the watch. It does so only when the
server binds every interface or a loopback address (or under
--public ssh, with the admin token): a server bound to one other
address would refuse the browser, and present says so instead. The
command depends on the platform: xdg-open on Linux and other Unix
systems, open on macOS and explorer on Windows. Set
mentipy.open_command to use another (a {url} in it marks where the
URL goes, otherwise it is appended; on Windows a path may be quoted),
or to an empty value or none to never open the browser on that
machine. Pass --open-with CMD for one run, or --no-open to skip
the step. Under --public ssh the URL with the admin token passes
through the opener's command line, so on a shared machine use
--no-open:
mentipy config mentipy.open_command --set "firefox --new-window"
mentipy present --store ./mentipy.json --no-open
Use --results when respondents should land on the live results page after
submitting an answer:
mentipy serve --store ./mentipy.json --results
Terminal helpers use question hash prefixes. List registered questions first, then watch or export one question by prefix:
mentipy list --store ./mentipy.json
mentipy watch f379 --store ./mentipy.json
mentipy export f379 --format csv --store ./mentipy.json
During a lecture, a bare mentipy watch (no prefix) follows the
question the lecturer has opened on the running server, and switches
whenever Next or Skip moves the lecture on. Start it once, beside
mentipy serve, with the same store. It asks the server for /active,
on mentipy.host (its loopback address when the server binds every
interface) at mentipy.port, unless --server names another address.
It needs no admin rights, and it keeps retrying while the server is not
running:
mentipy watch --store ./mentipy.json
mentipy watch --store ./mentipy.json --server http://localhost:9000
Respondent URLs and QR Codes
You can pass base_url / --base-url while rendering, or store a default:
mentipy config set base_url http://localhost:8080
If no base URL is configured, mentipy resolves the current LAN address from
the serving port. Because QR codes are generated when the document compiles,
mentipy serve may regenerate remembered QR images and ask you to recompile the
slides so the PDF embeds the updated codes.
For public access, mentipy serve can expose the local server in two modes:
mentipy serve --store ./mentipy.json --public upnp
mentipy config set ssh_tunnel user@example.org:8080
mentipy serve --store ./mentipy.json --public ssh
The UPnP mode requires the optional mentipy[public] dependency and a router
that accepts temporary port mappings. The SSH mode uses an SSH reverse tunnel;
the remote SSH server must allow the forwarded port to be reached publicly.
The polling server is intentionally simple. Anyone with the URL can submit
answers, and with --results they can view the live tally. Treat a public poll
URL like a shared room link, not like a private admin interface.
Discovering Commands
Useful entry points while learning the tool:
mentipy render --help
python3 -m pydoc mentipy.latex
mentipy tutorial list
mentipy tutorial run using-tutorials
The tutorial sequence mirrors the usage introduction: authoring paths, question kinds, layout and environment choices, respondent URLs, and serving/publication.
Metadata
Release files for mentipy 0.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mentipy-0.16.tar.gz | 5.4 kB | Without provenance | Details for mentipy-0.16.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mentipy-0.16-py3-none-any.whl | Python 3 | none | any | Details for mentipy-0.16-py3-none-any.whl |
Total release size: 94.7 kB
Release files / mentipy-0.16.tar.gz
| Download URL | mentipy-0.16.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de8e411ffa057903b41444eede6cf481761caaff091c2b270c12674e957e7384
|
|
BLAKE2b-256 checksum How to use checksums |
1f7a8c61c816a092cde862008451227418ccc1d942c02c19cb962b283ea59c33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.3 CPython/3.14.4 Linux/7.0.0-31-generic
|
Release files / mentipy-0.16-py3-none-any.whl
| Download URL | mentipy-0.16-py3-none-any.whl |
|---|---|
| Size | 89.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08d2baada28e458c205a5e9f68526a323f7dadfb4eab9d23ce70aeea9431a20c
|
|
BLAKE2b-256 checksum How to use checksums |
c1b9a459a65811591a44fcb7e86d2fa21fdd569f48b60689a772458544fbb49a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.3 CPython/3.14.4 Linux/7.0.0-31-generic
|
Security for mentipy 0.16
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.