首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当使用Python时,tkPDFViewer抛出一个错误,是否有一个错误我没有看到?

当使用Python时,tkPDFViewer抛出一个错误,是否有一个错误我没有看到?
EN

Stack Overflow用户
提问于 2022-08-26 05:13:28
回答 1查看 47关注 0票数 0

当测试一个更大项目的PDF打开时,代码会抛出一个错误。错误来自于tkPDFViewer。有什么想法吗?

以下是错误:

代码语言:javascript
复制
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'?
代码语言:javascript
复制
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')
EN

回答 1

Stack Overflow用户

发布于 2022-08-26 05:32:01

这是tkPDFViewer的内部问题。这个错误是非常不言自明的--在getPixmap的依赖项中,get_pixmap被取消并移除,以支持tkPDFViewer (参见这里)。因此,库需要得到修复(方法需要重命名以匹配新版本),而且它看起来维护得不太好。您可以尝试在其GitHub上打开一个问题或公关。但我可能会倾向于说这个图书馆已经死了,并且找到了一个可行的选择。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73496345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档