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-18-2022, 04:44 AM   #16
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Would it break existing things to change it to <= instead of <?
It could break every template that uses it.
chaley is offline   Reply With Quote
Old 01-18-2022, 05:16 PM   #17
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 893
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by Penny_Dreadful View Post
I edited the code a bit so I could use the default rating column and change the colour for each number of stars.



Code:
program: 

     r = $rating;
 

     if r >=#5 then '#2EAB64'
     elif r >=#4 then '#94E4C9'
     elif r >=#3 then '#FE657D'    
     elif r >=#2 then '#FCB2A9'
     elif r >=#1 then '#FEDC78'
 

     fi

Go to Settings> Look and Feel> Column Colouring> Add Advanced Rule (it's a button at the bottom left of the dialogue box)


Change "Set the colour of the column" to the ratings column and paste the code into the template box and you should be good to go.

Ans so much thanks to ownedbycats your idea is genius! I love ideas to make calibre prettier.


Now yes, thanks for sharing!
dunhill is offline   Reply With Quote
Advert
Old 01-19-2022, 06:32 PM   #18
Penny_Dreadful
She/Her
Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.
 
Penny_Dreadful's Avatar
 
Posts: 87
Karma: 142774
Join Date: Aug 2009
Location: Perth, Australia
Device: Kindle PW5 (G001PX) PW3 PW1
Quote:
Originally Posted by chaley View Post
FWIW: this template will have better performance because the sequence of comparisons is done in python instead of the template interpreter.
Code:
program:
    first_matching_cmp(
        $rating,
        1.1, '#FEDC78',
        2.1, '#94E4C9',
        3.1, '#FE657D',
        4.1, '#94E4C9',
             '#2EAB64')
I used 1.1 instead of 1 etc. because the comparisons are 'less than'. I should have made it <= when I added first_matching_cmp() to the template language. Oh well, too late now.

Thanks Chaley, this is fantastic 💚
Penny_Dreadful is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with ratings column Tanjamuse Library Management 13 09-19-2016 10:04 AM
Custom Column for Half-Star Ratings Loosheesh Calibre 2 09-14-2016 01:45 PM
My Ratings column MerlinMama Calibre 5 09-08-2016 07:20 AM
grouping does not work for custom column type ratings comox Calibre Companion 2 09-24-2014 01:54 PM
Rename the Ratings column? mlevin77 Library Management 5 04-13-2012 09:36 PM


All times are GMT -4. The time now is 01:25 AM.


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