看来wx.lib.pdfwin\u旧具有只转到pdf的上一页和下一页的函数。如何将其修改为转到pdf上的特定页面或转到pdf上的特定页面的代码是什么?你知道吗
import wx
if wx.Platform == '__WXMSW__':
from wx.lib.pdfwin_old import PDFWindow
class MyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, id=-1)
self.pdf = None
sizer = wx.BoxSizer(wx.VERTICAL)
self.pdf = PDFWindow(self, size=(parent.GetSize().width,parent.GetSize().height*3/5),style=wx.SUNKEN_BORDER)
sizer.Add(self.pdf, proportion=3, flag=wx.EXPAND|wx.ALL)
btn = wx.Button(self, wx.NewId(), "Open PDF File")
self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
sizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL)
self.SetSizer(sizer)
def OnOpenButton(self, event):
global current_pdf_path
dlg = wx.FileDialog(self, wildcard="*.pdf")
if dlg.ShowModal() == wx.ID_OK:
wx.BeginBusyCursor()
print(dlg.GetPath())
self.pdf.LoadFile(dlg.GetPath())
wx.EndBusyCursor()
dlg.Destroy()
app = wx.App()
frame = wx.Frame(None, -1, "PDFWindow", size = (640, 480))
MyPanel(frame)
frame.Show(True)
app.MainLoop()
你试过了吗
来自pdfwin_旧的.py地址:
编辑: 对不起,博伊肯,我帮不了你!我没有意识到
pdfwin
仅仅是windows,尽管名字里有线索。我在Linux上运行。作为安慰,我在下面提供了这段代码,一个使用浏览器的方法,它可能会也可能不会给你一些里程。(Python3)
chromium
浏览器似乎是最准确的。就我个人而言,为了在我的项目中显示
help
,我在主文档中使用sections
为每个主题创建了一个main
pdf和一个特定于内容的pdf。随着文档的发展,这种方法避免了页码变化时出现的问题。我建议你不要接受这个答案,因为它显然不能回答你的具体问题。你知道吗
相关问题 更多 >
编程相关推荐