PDFviewer - make it run under Phoenix

Hi Robin,

I am not sure how you would like the patches for PDFviewer for Phoenix, let me know if you want just one with it all or ....

Attached patch makes the PDFviewer run under Phoenix, i.e. I can run the demo and load a PDF file to view, I can zoom and can print.

This patch is before I apply the patch I sent on the 23rd.

Next I will do the documentation updates and add the tags etc.

Werner

pdfviewer.patch (1.07 KB)

Hi Robin and David,

This is a combined patch.

- it includes the patch for classic submitted on 23.3.
- make it run under Phoenix patch from earlier today
- update the documentation strings to Phoenix format
- replaced wx.EmptyBitmap with wx.Bitmap to remove deprecation warning

The documentation strings need further work, I plan on reviewing them again after this has been applied and documentation has been rebuild.

Currently there are some tests in wx.lib.pfdviewer.vec2d, I assume they should move to the test folder?

Will work on the test stuff, but no promise that I'll figure it out.

Werner

pdfviewer doc plus.patch (53 KB)

Hi Robin,

Attached what I came up with as tests.

- test_lib_pdfviewer_vec2d - is what was in the wx.lib.pdfviewer.vec2d
- test_lib.pdfviewer_pdfviewer, checks that the button panel and viewer can be created and that a sample pdf file can be loaded

For the last test it assumes that a "sample.pdf" file is present in a folder "unittests/data".

Werner

test_lib_pdfviewer_pdfviewer.py (1.67 KB)

test_lib_pdfviewer_vec2d.py (4.25 KB)

Cellarbook listing - portrait.pdf (67.1 KB)

Werner wrote:

Hi Robin and David,

This is a combined patch.

- it includes the patch for classic submitted on 23.3.
- make it run under Phoenix patch from earlier today
- update the documentation strings to Phoenix format
- replaced wx.EmptyBitmap with wx.Bitmap to remove deprecation warning

Thanks again.

···

--
Robin Dunn
Software Craftsman

Werner wrote:

Hi Robin,

Attached what I came up with as tests.

- test_lib_pdfviewer_vec2d - is what was in the wx.lib.pdfviewer.vec2d
- test_lib.pdfviewer_pdfviewer, checks that the button panel and viewer
can be created and that a sample pdf file can be loaded

For the last test it assumes that a "sample.pdf" file is present in a
folder "unittests/data".

Since pdfviewer requires one of the 3rd-party pypdf modules then we should probably not consider the unitests as failed if pydf is not installed. I added a decorator from the unitest module to skip the tests if there was an ImportError.

BTW, I'm getting the following error on Mac:

···

======================================================================
ERROR: test_lib_pdfviewer_loadFile (__main__.lib_pdfviewer_pdfviewer_Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "unittests/test_lib_pdfviewer_pdfviewer.py", line 48, in test_lib_pdfviewer_loadFile
     self.viewer.LoadFile(samplePdf)
   File "/Users/robind/projects/wx/2.9/Phoenix/wx/lib/pdfviewer/viewer.py", line 212, in LoadFile
     self.CalculateDimensions(True) # to get initial visible page range
   File "/Users/robind/projects/wx/2.9/Phoenix/wx/lib/pdfviewer/viewer.py", line 339, in CalculateDimensions
     self.frompage = min(self.y0/self.Ypagepixels, self.numpages-1)
ZeroDivisionError: integer division or modulo by zero

--
Robin Dunn
Software Craftsman

David,

Any chance you could have a look at this?

On windows I get an initial value of 23 with my test script and then things around a 1000. Could it be that on Mac the initial value is 0?

Werner

···

On Monday, 25 March 2013 09:56:47 UTC+1, werner wrote:

Hi Robin,

I am not sure how you would like the patches for PDFviewer for Phoenix,
let me know if you want just one with it all or …

Attached patch makes the PDFviewer run under Phoenix, i.e. I can run the
demo and load a PDF file to view, I can zoom and can print.

This patch is before I apply the patch I sent on the 23rd.

Next I will do the documentation updates and add the tags etc.

Werner

Hi Robin,

======================================================================
ERROR: test_lib_pdfviewer_loadFile (main.lib_pdfviewer_pdfviewer_Tests)

Traceback (most recent call last):
File “unittests/test_lib_pdfviewer_pdfviewer.py”, line 48, in
test_lib_pdfviewer_loadFile
self.viewer.LoadFile(samplePdf)
File
“/Users/robind/projects/wx/2.9/Phoenix/wx/lib/pdfviewer/viewer.py”, line
212, in LoadFile
self.CalculateDimensions(True) # to get initial visible page range
File
“/Users/robind/projects/wx/2.9/Phoenix/wx/lib/pdfviewer/viewer.py”, line
339, in CalculateDimensions
self.frompage = min(self.y0/self.Ypagepixels, self.numpages-1)
ZeroDivisionError: integer division or modulo by zero

David came up with a fix for this.

I attach two patches to correct above, one for classic and one for Phoenix.

Best regards
Werner

pdfviewer 27mar classic.patch (1.16 KB)

pdfviewer 27-mar.patch (1.31 KB)

···

On Monday, 25 March 2013 17:22:47 UTC+1, Robin Dunn wrote:


Robin Dunn
Software Craftsman
http://wxPython.org

Hi Robin,

...

I attach two patches to correct above, one for classic and one for Phoenix.

Thanks David for having caught my error.

I had missed two lines in the classic patch, updated patch attached.

Werner

pdfviewer 27mar classic 2.patch (1.3 KB)

···

On 27/03/2013 09:02, werner wrote:

Hi Robin,

...

I attach two patches to correct above, one for classic and one for
Phoenix.

Thanks David for having caught my error.

I had missed two lines in the classic patch, updated patch attached.

Werner

pdfviewer 27mar classic 2.patch (1.3 KB)

···

On 27/03/2013 09:02, werner wrote:

Werner wrote:

Hi Robin,

...

I attach two patches to correct above, one for classic and one for
Phoenix.

Thanks David for having caught my error.

I had missed two lines in the classic patch, updated patch attached.

Patches applied. Thanks.

···

On 27/03/2013 09:02, werner wrote:

--
Robin Dunn
Software Craftsman