Quote:
Originally Posted by capink
Thanks for the help. I think I figured out the problem. I made the wrong assumption that if no row is selected the result of gui.library_view.currentIndex() will evaluate to None and proceeded with:
Code:
if gui.library_view.currentIndex():
....
[...]
|
Use
Code:
dex = gui.library_view.currentIndex()
if dex.isValid():
row = dex.row()
....
This is easy to test using this python template:
Code:
python:
def evaluate(book, context):
from calibre.gui2.ui import get_gui
gui = get_gui()
dex = gui.library_view.currentIndex()
print(dex, dex.isValid())
return f'row = {dex.row()}' if dex.isValid() else 'Not valid'
To test it, select a book, open the template tester, then paste the template. It will give you a row number. Then search for authors:false (there aren't any books with no authr), which will give an empty list view. Type something in the template tester to make the template run and you will get "Not valid">