Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 01-23-2026, 05:33 PM   #1
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 22,208
Karma: 30317706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Template function for current book

I'd like to put an Up arrow emblem under the current book in the upcoming shelf view - i.e. the one that's highlighted - which can be hard to see - but I can't fathom how to finagle the equivalent of an is_current template function.

Any ideas?

BR
BetterRed is online now   Reply With Quote
Old Yesterday, 01:16 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,911
Karma: 29228280
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Here is the code for a python template:
Code:
python:
def evaluate(book, context):
        from calibre.gui2.ui import get_gui
        v = get_gui().library_view
        row = v.currentIndex().row()
        if row < 0:
            return 'no'
        try:
            return 'yes' if v.model().db.data.index_to_id(row) == book.id else 'no'
        except Exception:
            return 'no'
Then in the emblem rule simply check if the column base don this template is yes. Note I havent actually tested this, but I see no reason why it wont work.

Last edited by kovidgoyal; Yesterday at 04:19 AM.
kovidgoyal is offline   Reply With Quote
Old Yesterday, 04:07 AM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 22,208
Karma: 30317706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Thanks, but it returns 'no' for selected book

Click image for larger version

Name:	Screenshot 2026-01-24 185715.jpg
Views:	12
Size:	590.8 KB
ID:	220475

I just copied and pasted (I'm good at that) but I've attached the saved python function.

BR
Attached Files
File Type: txt is_current.txt (354 Bytes, 1 views)
BetterRed is online now   Reply With Quote
Old Yesterday, 04:17 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,911
Karma: 29228280
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah actually thinking about it some more, I doubt this whole approach will work, template results are cached and the cache isnt invalidated when the current book changes. So it will give stale results anyway.
kovidgoyal is offline   Reply With Quote
Old Yesterday, 05:30 AM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 22,208
Karma: 30317706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Oh well, back to the drawing board

Thanks anyway
BetterRed is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with template function JohnAndJane Library Management 1 03-16-2025 02:35 PM
Template function to strip HTML? halloleo Library Management 6 11-16-2023 04:20 AM
BuiltinAdd template language function DyckBook Editor 4 10-19-2021 05:21 PM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 01:20 PM
how to use re() function in Template Program Mode? msciwoj Library Management 3 07-07-2016 04:55 PM


All times are GMT -4. The time now is 08:23 PM.


MobileRead.com is a privately owned, operated and funded community.