![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
API for plugins to create custom columns
Working with @davidfor, I added an API that plugin writers can use to create custom columns for the plugin's use. See the class CreateNewCustomColumn in calibre.gui2.preferences.create_custom_column. It is documented there.
The class is in calibre source now. Notes:
EDIT: I have improved the documentation for the class and methods to make it clearer that more than one column can be created, and to better explain the parameters. I will submit it to Kovid if/when I have more feedback. The documentation as of 2/Jan/21 is: Spoiler:
Last edited by chaley; 01-02-2022 at 07:25 AM. Reason: New documentation |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,187
Karma: 1318209
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Hi, Chaley.
I have two questions: 1) What is the is_multiple argument used for? I could not understand this parameter. 2) When using calibre preferences, I can create multiple columns before restarting. Can't that be replicated with the API? I plan to use this on my Skoob Sync plugin, but the user must configure seven columns, hence seven restarts. P.S.: Just noticed you said "create columns". Maybe I misunderstood your point on my second question. Can I create multiple columns at once? Maybe this is the reason for the is_multiple argument? Last edited by thiago.eec; 01-01-2022 at 11:12 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Code:
creator = CreateNewCustomColumn(gui) result1 = creator.create('#col1', ...) --- check result1 for correctness --- result2 = creator.create('#col2', ...) --- check result2 for correctness --- This system is similar to what you see with calibre preferences. You can create etc as many columns as you wish using one dialog, but you can't do it again until you restart. |
||
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I have 'improved' the documentation for the class and methods to make it clearer that more than one column can be created, and to better explain the parameters. I will submit it to Kovid if/when I have more feedback.
EDIT: The documentation is now in the first post. Last edited by chaley; 01-01-2022 at 01:06 PM. Reason: Moved documentation to the first post |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
As @chaley said, I was testing his code and making changes. It is working well and I nearly have all the changes ready in the Kobo Utilities plugin.
@chaley: One thing we missed was duplicate column headings. When using "generate_unused_lookup_name=True", the supplied column heading is probably not unique. Appending the same number to the column heading is probably good enough for this. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
And done. I also added a method to return the column headings as a dict {heading:lookup_name} Last edited by chaley; 01-02-2022 at 08:25 AM. Reason: Job done. |
|
![]() |
![]() |
![]() |
#7 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 863
Karma: 409968
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
|
Geniuses !! excellent work of both as always, I take off my hat
|
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
|
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,187
Karma: 1318209
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Hi, @chaley and @davidfor.
Thank both of you, @chaley and @davidfor, for your efforts. This is really great. Got it working here for Skoob Sync after looking at implemented version by @davidfor. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Forgot how to create size columns | Rellwood | Library Management | 2 | 08-06-2021 08:21 PM |
Ratings Custom Columns Created From other Columns | Tanjamuse | Library Management | 4 | 09-28-2020 12:57 AM |
Is there any direct api to using built-in input and output plugins in new plugin? | The_book | Plugins | 2 | 03-21-2020 09:31 AM |
Custom sort order for custom columns? | matjojo | Library Management | 5 | 11-24-2019 11:30 AM |
Help Needed for Custom Columns Created From other Columns | Tanjamuse | Library Management | 5 | 09-02-2018 06:19 PM |