nattyfix 2
This commit is contained in:
parent
7c871a6387
commit
8c8a01f1f1
|
@ -2,6 +2,7 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Dict, List, Optional, Sequence, Tuple, TypeAlias
|
from typing import Dict, List, Optional, Sequence, Tuple, TypeAlias
|
||||||
|
|
||||||
|
import PIL.Image
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
|
@ -49,13 +50,12 @@ class PdfPage(Gtk.DrawingArea):
|
||||||
width = widget.get_allocated_width()
|
width = widget.get_allocated_width()
|
||||||
height = widget.get_allocated_height()
|
height = widget.get_allocated_height()
|
||||||
|
|
||||||
cr.set_source_rgba(255, 255, 255)
|
|
||||||
cr.paint()
|
|
||||||
|
|
||||||
sctx = widget.get_style_context()
|
sctx = widget.get_style_context()
|
||||||
Gtk.render_background(sctx, cr, 0, 0, width, height)
|
Gtk.render_background(sctx, cr, 0, 0, width, height)
|
||||||
pix = self.page.get_pixmap(dpi=96, alpha=True) # type: ignore
|
pix = self.page.get_pixmap(dpi=96) # type: ignore
|
||||||
mv: memoryview = pix.samples_mv
|
img = PIL.Image.frombytes("RGBA" if pix.alpha else "RGB", [pix.width, pix.height], pix.samples)
|
||||||
|
img.putalpha(1)
|
||||||
|
mv: memoryview = memoryview(bytearray(img.tobytes()))
|
||||||
ims = cairo.ImageSurface.create_for_data(mv, cairo.Format.RGB24, pix.width, pix.height)
|
ims = cairo.ImageSurface.create_for_data(mv, cairo.Format.RGB24, pix.width, pix.height)
|
||||||
cr.set_source_surface(ims, 0, 0)
|
cr.set_source_surface(ims, 0, 0)
|
||||||
cr.paint()
|
cr.paint()
|
||||||
|
|
|
@ -11,11 +11,14 @@ python = ">=3.11,<3.13"
|
||||||
pygobject = "^3.48.2"
|
pygobject = "^3.48.2"
|
||||||
tabula-py = "^2.9.0"
|
tabula-py = "^2.9.0"
|
||||||
PyMuPDF = "^1.24.0"
|
PyMuPDF = "^1.24.0"
|
||||||
|
pillow = "^10.3.0"
|
||||||
#pdfplumber = "^0.11.0"
|
#pdfplumber = "^0.11.0"
|
||||||
#PySide6 = "^6.6.3" # qt
|
#PySide6 = "^6.6.3" # qt
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pygobject-stubs = "^2.11.0" # this is actually broken lol
|
# this is actually broken lol, fix by running following in venv:
|
||||||
|
# pip uninstall pygobject-stubs && pip install pygobject-stubs --no-cache-dir --config-settings=config=Gtk3,Gdk3,Soup2
|
||||||
|
pygobject-stubs = "^2.11.0"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
|
|
Loading…
Reference in New Issue