Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2022, 06:25 AM   #301
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,121
Karma: 3858943
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
That works. I didn't realize it was possible to re-use a variable name and have it return different things. That will be useful to know.
Ahhh, that explains some of your previous questions.

A variable is a container, not an alias. You set or change the contents of a variable by assigning to it. A copy is made of the result of computing the expression on the right-hand side of the '=' then then stored in the variable named on the left-hand side of the '='. The right-hand expression is evaluated before assignment so assigning to a variable doesn't affect the result of the expression. And vice versa, you can change anything that was used in a previous expression without changing what was stored in the variable.

Examples:
Code:
    x = 5;
# x contains the value 5.
    y = x + 1;
# y contains 6 (5 + 1). x still contains 5.
    x = x + 10
# x contains 15 (5 + 10). y still contains 6.
    y = x + 1;
# y contains 16 (15 + 1). x still contains 15.
    y = (x + y) * 2;
# y contains 62 ((15 + 16) * 2). x still contains 15.
    y = x;
# y contains 15. x still contains 15.
    y = y + 1
# y contains 16. x still contains 15.
chaley is offline   Reply With Quote
Old 01-25-2022, 05:11 PM   #302
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Thanks.

Some stuff in the PyQt6 migration thread made me wonder: can template detect whether light or dark mode is in use?
ownedbycats is online now   Reply With Quote
Old 01-25-2022, 05:26 PM   #303
capink
Guru
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 711
Karma: 211790
Join Date: Aug 2015
Device: Kindle
You can do it with a custom template function.

Code:
def evaluate(self, formatter, kwargs, mi, locals):
    from qt.core import QApplication
    if QApplication.instance().is_dark_theme:
        return 1
    else:
        return ''
function name: is_dark_theme
arg count: -1

Code:
program:
    is_dark_theme()

Last edited by capink; 01-25-2022 at 05:34 PM.
capink is offline   Reply With Quote
Old 01-25-2022, 10:11 PM   #304
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Thanks. I don't have any use for it personally myself but I can see it being useful with people who switch between the themes.
ownedbycats is online now   Reply With Quote
Old 01-26-2022, 11:23 PM   #305
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Is there any type of "goto" option in a template? e.g. if a book matches a certain check, then skip the rest of the if-tree and then go to the next one?

Last edited by ownedbycats; 01-26-2022 at 11:34 PM.
ownedbycats is online now   Reply With Quote
Old 01-27-2022, 05:03 AM   #306
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,121
Karma: 3858943
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
Is there any type of "goto" option in a template? e.g. if a book matches a certain check, then skip the rest of the if-tree and then go to the next one?
What is an "if-tree"? If it is nested ifs then why doesn't a nested if do the job?

The language doesn't support goto. It does support continue, break, and return.
chaley is offline   Reply With Quote
Old 01-27-2022, 05:28 AM   #307
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Yeah, I meant nested ifs. Probably a nested if would work just as well.
ownedbycats is online now   Reply With Quote
Old 01-27-2022, 04:15 PM   #308
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,121
Karma: 3858943
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
Is there any type of "goto" option in a template? e.g. if a book matches a certain check, then skip the rest of the if-tree and then go to the next one?
As you run from source, could you confirm that today's changes fix your problems?
chaley is offline   Reply With Quote
Old 01-27-2022, 05:22 PM   #309
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
If you mean the nested stored template thing, it's working on source.
ownedbycats is online now   Reply With Quote
Old 01-27-2022, 05:25 PM   #310
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,121
Karma: 3858943
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
If you mean the nested stored template thing, it's working on source.
Thanks.

Is there something that isn't working yet? I confess that I didn't completely follow your addition to the bug report so I assumed it was the same problem.
chaley is offline   Reply With Quote
Old 01-27-2022, 05:34 PM   #311
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
My addition was mostly just about how it only affected new stored templates. For example, I'd already had a nested template, fanfic_unreadchaps(). Duplicating it into fanfic_unreadchaps2() and swapping it in broke the nesting. Putting it back unbroke it. Just found that very strange.
ownedbycats is online now   Reply With Quote
Old 01-27-2022, 07:44 PM   #312
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,430
Karma: 14101180
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Is the second equal sign turning yellow here a glitch?

Click image for larger version

Name:	2022-01-27 19_43_07-Window.png
Views:	27
Size:	2.1 KB
ID:	191936

Last edited by ownedbycats; Yesterday at 02:52 AM.
ownedbycats is online now   Reply With Quote
Old Yesterday, 06:48 AM   #313
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,121
Karma: 3858943
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
Is the second equal sign turning yellow here a glitch?
Yes, caused by the requirement to highlight TPM syntax. Put a space before the quote to get rid of it.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A few questions... (template language, mainly) Clem2605 Library Management 2 12-30-2020 04:25 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 12:37 PM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 10:19 PM
[Old Thread] Save Template not working TGinAZ Calibre 7 01-18-2012 02:03 AM
Thread management questions meme Feedback 6 01-31-2011 06:07 PM


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


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