I am trying to create an application that has a feature of displaying pdf files and decided to use wxpython to do this due to the pdfviewer class.
I made sure that I have pyPDF2 and pyPdf. (can use either but installed both to see if that was the issue.)
However when I run the code at the bottom. (taken from here) (got rid of the ``` on lines 31 and 17. Added wx before .VSCROLL and .SUNKEN_BORDER on line 16) I get the message:
Traceback (most recent call last):
File "E:\Test\pdf.py", line 4, in <module>
from wx.lib.pdfviewer import pdfViewer, pdfButtonPanel
File "C:\Python34\lib\site-packages\wx\lib\pdfviewer\__init__.py", line 124, in <module>
from viewer import pdfViewer
ImportError: No module named 'viewer'
When I then went to that package file to confirm that the module viewer was there I then ran it and line 124 worked. It just doesnt work when running through this example file which I assume is the same as when it will be in my application.
Does anyone know what I need to do to fix this. This module looks perfect for what I plan on doing.
Thanks
import wx
import wx.lib.sized_controls as sc
from wx.lib.pdfviewer import pdfViewer, pdfButtonPanel
class PDFViewer(sc.SizedFrame):
def __init__(self, parent, **kwds):
super(PDFViewer, self).__init__(parent, **kwds)
paneCont = self.GetContentsPane()
self.buttonpanel = pdfButtonPanel(paneCont, wx.NewId(),
wx.DefaultPosition, wx.DefaultSize, 0)
self.buttonpanel.SetSizerProps(expand=True)
self.viewer = pdfViewer(paneCont, wx.NewId(), wx.DefaultPosition,
wx.DefaultSize,
wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
self.viewer.UsePrintDirect = False
self.viewer.SetSizerProps(expand=True, proportion=1)
# introduce buttonpanel and viewer to each other
self.buttonpanel.viewer = self.viewer
self.viewer.buttonpanel = self.buttonpanel
if __name__ == '__main__':
import wx.lib.mixins.inspection as WIT
app = WIT.InspectableApp(redirect=False)
pdfV = PDFViewer(None, size=(800, 600))
pdfV.viewer.UsePrintDirect = False
pdfV.viewer.LoadFile(r'a path to a .pdf file')
pdfV.Show()
app.MainLoop()