pdfviewer exceptions if no file loaded

24 views
Skip to first unread message

luvspython

unread,
Aug 18, 2016, 5:21:41 PM8/18/16
to wxPython-users
I'm using Python 2.7 and wxPython 3.0.3.dev2323+9bcccff on Windows 10

Pdfviewer creates exceptions in viewer.py when any button is clicked on buttonpanel.py if no PDF file has been loaded yet.

Seems pretty basic, but all the methods in viewer.py that change what is viewed need to check that a file is loaded, e.g.. \
I've not made patches for myself, but I'm inclined to think that self.pdfpathname should
be initialized to None in the pdfViewer class, and all those methods can first check if self.pdfpathname is not None and do nothing if so.

luvspython

unread,
Aug 18, 2016, 6:50:40 PM8/18/16
to wxPython-users
My suggestion on how to fix the exceptions was inadequate because pdfbuttonpanel.py also does calculations related to the presumably-displayed document prior to calling methods in viewer.py.

So, the following changes fixed the problems for me:

in the __init__ method of class pdfViewer in viewer.py, insert:
self.pdfpathname = None

in the pdfButtonPanel class in buttonpanel.py, at the top of every OnXxxx event-handler, insert:
if not self.viewer.pdfpathname:
          return

David Hughes

unread,
Aug 22, 2016, 5:24:21 AM8/22/16
to wxPython-users

On Thursday, 18 August 2016 22:21:41 UTC+1, luvspython wrote:
I'm using Python 2.7 and wxPython 3.0.3.dev2323+9bcccff on Windows 10

Pdfviewer creates exceptions in viewer.py when any button is clicked on buttonpanel.py if no PDF file has been loaded yet.


Thanks for reporting this issue. As the author of Pdfviewer my only plea in mitigation is that in the application from which this stand-alone viewer was extracted, unlike the demo, the viewer and its associated button panel does not get instantiated until a pdf file has been specified.

I have modified the button panel so all the controls are initially disabled until a PDF file has been specified and loaded and I'm creating a pull request to wxWidgets/Phoenix.

David Hughes
Forestfield Software 

David Hughes

unread,
Aug 26, 2016, 6:34:14 AM8/26/16
to wxPython-users


On Monday, 22 August 2016 10:24:21 UTC+1, David Hughes wrote:

On Thursday, 18 August 2016 22:21:41 UTC+1, luvspython wrote:
I'm using Python 2.7 and wxPython 3.0.3.dev2323+9bcccff on Windows 10

Pdfviewer creates exceptions in viewer.py when any button is clicked on buttonpanel.py if no PDF file has been loaded yet.

I have modified the button panel so all the controls are initially disabled until a PDF file has been specified and loaded and I'm creating a pull request to wxWidgets/Phoenix.


The change has now been accepted into Phoenix and is available in the snapshot build wxPython-Phoenix-3.0.3.dev2470+4ca8c3e

David Hughes
Forestfield Software
 
Reply all
Reply to author
Forward
0 new messages