feat: Wonder Ink looks like the classroom, and its preview shows the page
The tab strip is drawn from the classroom's own palette, the one the panel, Parent Call and Presentations read: larger titles, an accent under the active tab, worksheets marked with a document icon. Its one corner widget is the lesson's size and Print — not a new-tab button. With one tab the strip stays hidden, as before; a change of size shows a moment's badge instead, and the right-click menu and keys still work. The window is named "Lesson — Wonder Ink" and carries its own icon. The print preview showed "Page 1 could not be shown" in the real session while printing correctly: poppler 25.03 does not write to stdout when asked for "-" — it writes a file called "-.png" into the current directory, which for Wonder Ink is the teacher's home. Pages are now rendered into a directory of their own, and the lab print check fails any preview that does not draw its page. The teacher's manual has lesson size and printing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
48b3097c43
commit
1cb9fd35d2
+32
-16
@@ -122,24 +122,40 @@ def page_count(pdf):
|
||||
|
||||
|
||||
def render_page(pdf, number, width):
|
||||
"""PNG bytes of one page, WIDTH pixels wide, or None."""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"pdftoppm", "-f", str(number), "-l", str(number),
|
||||
"-scale-to-x", str(int(width)), "-scale-to-y", "-1",
|
||||
"-png", "-singlefile", str(pdf), "-",
|
||||
],
|
||||
capture_output=True,
|
||||
timeout=QUERY_TIMEOUT,
|
||||
)
|
||||
except (OSError, subprocess.TimeoutExpired):
|
||||
return None
|
||||
"""PNG bytes of one page, WIDTH pixels wide, or None.
|
||||
|
||||
if result.returncode != 0 or not result.stdout:
|
||||
return None
|
||||
Rendered into a directory of its own and read back. Measured on
|
||||
poppler 25.03: asked for "-" as its output, pdftoppm does NOT write to
|
||||
stdout — it writes a file called "-.png" (or "--1.png") into whatever
|
||||
directory it was started in, which for Wonder Ink is the teacher's
|
||||
home, and the preview showed nothing at all.
|
||||
"""
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
return result.stdout
|
||||
with tempfile.TemporaryDirectory(prefix="wonderink-page-") as directory:
|
||||
root = Path(directory) / "page"
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"pdftoppm", "-f", str(number), "-l", str(number),
|
||||
"-scale-to-x", str(int(width)), "-scale-to-y", "-1",
|
||||
"-png", "-singlefile", "--", str(pdf), str(root),
|
||||
],
|
||||
capture_output=True,
|
||||
timeout=QUERY_TIMEOUT,
|
||||
)
|
||||
except (OSError, subprocess.TimeoutExpired):
|
||||
return None
|
||||
|
||||
image = root.with_suffix(".png")
|
||||
|
||||
if result.returncode != 0 or not image.is_file():
|
||||
return None
|
||||
|
||||
data = image.read_bytes()
|
||||
return data or None
|
||||
|
||||
|
||||
def parse_pages(text, count):
|
||||
|
||||
Reference in New Issue
Block a user