问题描述
我正在制作一个简单的程序,可以将网站保存为 pdf。我用 Python (3.8) 在 Spyder (4.2.1) 中编写了代码。我也做了一个 tkinter GUI。代码如下所示。
import pdfkit
import tkinter as tk
def pdf_create():
#get the website in pdf format
url = url_in.get()
path_wkthmltopdf = "path to/wkhtmltopdf.exe"
config = pdfkit.configuration(wkhtmltopdf = path_wkthmltopdf)
pdfkit.from_url(url,"out.pdf",configuration=config)
return
window = tk.Tk()
frm_entry = tk.Frame(master=window)
url_in= tk.Entry(master=frm_entry,width=50)
ent_url = tk.Label(master=frm_entry,text=r"Url")
url_in.grid(row=0,column=1,sticky="e")
ent_url.grid(row=0,column=0,sticky="w")
# # # Create the conversion Button and result display Label
btn_convert = tk.Button(
master=window,text=r"Submit",command=pdf_create)
frm_entry.grid(row=0,padx=20)
btn_convert.grid(row=1,pady=20)
# Run the application
window.mainloop()
好的,所以当我希望通过双击 python_script.py 运行程序时会出现问题。如果我在 spyder 中运行它,它会起作用。如果我从 cmd 提示符运行它,它可以工作,当我双击 python_script.py 运行它时,我得到一个 wkhtmltopdf 错误:raise IOError('wkhtmltopdf reported an error:\n' + stderr
)。知道为什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)