driscollis / applications_with_wxpython

Code examples for the book, Creating GUI Application with wxPython
https://www.blog.pythonlibrary.org
116 stars 26 forks source link

Chapter 10 - Code in book is different than code in repo #19

Closed cmcknight closed 5 years ago

cmcknight commented 5 years ago

In the split_panel.py code in the book:

if ',' in split_options:
    pages = split_options.split(',')

    for page in pages:
        pdf_writer.addPage(pdf.getPage(int(page)))

In the repo code:

if ',' in split_options:
    pages = [page for page in split_options.split(',')
                     if page]

    for page in pages:
        pdf_writer.addPage(pdf.getPage(int(page)))

I'm also getting an index out of range error that I'm trying to track down.

Update: I'm trying to split a 2-page PDF to keep the first test simple. I'm either getting the above error or I'm told that the method is getting 1 value when it expects 2 if I just specify a single page to split out.

driscollis commented 5 years ago

You caught a fun corner case. I just uploaded a fix that I think will resolve the issue. I am also going to be pushing an update to the book here shortly

cmcknight commented 5 years ago

Confirming that this fixed it. 👍

driscollis commented 5 years ago

I should make some challenge coins for people like you. Beeware has some really neat ones