View Single Post
Old 02-23-2023, 10:51 AM   #1025
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,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
I defined a template function called selected_column (see the code at the end of this post) that gets the selected column name, if @chaley has no interest in adding something similar to calibre, I will add it to the next version of Action Chains.
Given that it will be rarely used and is easy to implement as a fast python stored template, I don't think adding it to base calibre is required. Action Chains users can use what you add. People who want the function can create a stored template.

You might consider whether using a stored template is a good solution for you. A stored template will work just as well, and you aren't required to maintain it.

The stored template code is (like yours):
Code:
python:
def evaluate(book, context):
	from calibre.gui2.ui import get_gui
	gui = get_gui()
	cv = get_gui().current_view()
	return cv.column_map[cv.currentIndex().column()]
Assuming the name is (like yours) "current_column" the "adding" dialog Preferences / Template functions is
Click image for larger version

Name:	Clipboard03.jpg
Views:	667
Size:	95.0 KB
ID:	199877

I slightly prefer the name "current_column", but I think it is more important that we use the same name.

Last edited by chaley; 02-23-2023 at 11:06 AM.
chaley is offline   Reply With Quote