当测试一个更大项目的PDF打开时,代码会抛出一个错误。错误来自于tkPDFViewer。有什么想法吗?
以下是错误:
Exception in thread Thread-1 (add_img): Traceback (most recent call last):
File "C:\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner self.run()
File "C:\Python\Python310\lib\threading.py", line 946, in run self._target(*self._args, *self._kwargs)
File "C:\Python\Python310\lib\site-packages\tkPDFViewer\tkPDFViewer.py", line 46, in add_img
pix = page.getPixmap()
AttributeError: 'Page' object has no attribute 'getPixmap'. Did you mean: 'get_pixmap'?import tkinter as tk
from tkPDFViewer import tkPDFViewer as pdf
print('Starting TestPDF2')
mainWindow = tk.Tk()
# Set the width and height of our root window.
mainWindow.geometry("550x750")
# creating object of ShowPdf from tkPDFViewer.
v1 = pdf.ShowPdf()
# Adding pdf location and width and height.
v2 = v1.pdf_view(mainWindow, pdf_location = 'testpdf.pdf', width = 50, height = 100)
# Placing Pdf in my gui.
v2.pack()
mainWindow.mainloop()
print('End TestPDF2')发布于 2022-08-26 05:32:01
这是tkPDFViewer的内部问题。这个错误是非常不言自明的--在getPixmap的依赖项中,get_pixmap被取消并移除,以支持tkPDFViewer (参见这里)。因此,库需要得到修复(方法需要重命名以匹配新版本),而且它看起来维护得不太好。您可以尝试在其GitHub上打开一个问题或公关。但我可能会倾向于说这个图书馆已经死了,并且找到了一个可行的选择。
https://stackoverflow.com/questions/73496345
复制相似问题