Quantcast
Channel: MobileRead Forums - Reading and Management
Viewing all articles
Browse latest Browse all 24044

Build Custom Stars Rating Column.

$
0
0
I build custem stars column (text) from number float column using this function.

Code:

def evaluate(self, formatter, kwargs, mi, locals, r):
        try:
                m = float (r)
                n = int(m)
                if 0.00 <= m - n <= 0.25:
                        x = n * '★'
                if 0.25 < m - n <= 0.75:
                        x = n * '★' +'½'
                if 0.75 < m - n <= 1.00:
                        x = (n+1) * '★'
        except:
                x = ''
        return x

It works well but I have a few question:

- Is there a way to use an half star in text?

- The funny thing is that in the catrgory is show half stars rating, but it doesn't show any books.

- From 2.67 there is half star option in the custem star column, can I build star column from float column?

Attached Thumbnails
Click image for larger version

Name:	rt1.PNG
Views:	N/A
Size:	12.4 KB
ID:	151712   Click image for larger version

Name:	rt2.PNG
Views:	N/A
Size:	19.9 KB
ID:	151713  

Viewing all articles
Browse latest Browse all 24044

Trending Articles