Anki Forums

Editor: apply font color, background color, custom class, custom style [Official thread]

If you have a problem with the add-on editor: apply font color, background color, custom class, custom style post in this thread. This way I get notified. If you make a new thread I will likely miss it.

Hi, I don’t know if it is possible but I wanted to change the background color of my cards.
In the same deck, I want some cards in blue, another ones in orange and last ones in green, in order to distinguish them at first sight.
My problem is that every time I change the color, it changes in all the cards that are the same type (I just want to change the specific card I´m edditing)

This has nothing to do with my add-on which is meant for highlighting small sections of one card.

There are multiple solutions.

You could use different note types. E.g. clone your existing note type twice and then adjust the .card property in the styling section of the card template dialog.

There are also more sophisticated approaches. Like adding an additional field to your note and then applying css based on the content of this field. This is often used when learning languages with different genders so that e.g. for German people use three colors for their vocabulary cards. Search the old forum and the anki subreddit about this. There are good solutions.

Check out the this article Changing the background. I think this would solve your problem.

If you don’t understand this: To get started with card styling etc watch the third video “styling cards” that is linked from the top of the manual, https://apps.ankiweb.net/docs/manual.html Then maybe have a look at Anki: Customizing Card Style (font, color, hints, etc)

4 Likes

I´m sorry my question had nothing to do with your add-on :grimacing: :grimacing:

Thank you so much

This is a really cool add-on, but is it possible to make the name in the Tools menu shorter? The length makes it way wider than it needs to be… Thanks!

27.08, 11.26.02_anki

@celsient: At the moment you need to change the source code of the add-on (and do this after each update of the add-on). In the folder for this add-on there’s a file __init__.py that has a line action.setText(f"Adjust config for {addonname}"). Change it to action.setText("Adjust config for styling add-on") or something like this.

to go to the add-on folder: in the add-on window select my add-on and the click the button “View Files”.

@ijgnd Oh cool! Thank you so much!! :]

@celsient: I’ll rename the add-on soon and then this entry will be shorter, too.

Error in (Add entry -> style (inline)

image

Informações de Depuração:
Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-09-15 09:08:42

Caught exception:
Traceback (most recent call last):
File “C:\Users\diogenes.nunes\AppData\Roaming\Anki2\addons21\1899278645\confdialog_init_.py”, line 116, in accept
a = gui_dialog(self, sel=sel, config=None)
File “C:\Users\diogenes.nunes\AppData\Roaming\Anki2\addons21\1899278645\confdialog_init_.py”, line 60, in gui_dialog
return SettingsForStyle(inst, config)
File “C:\Users\diogenes.nunes\AppData\Roaming\Anki2\addons21\1899278645\confdialog\style.py”, line 16, in init
self.dialog.pb_hotkeyset.clicked.connect(self.onHotkey)
AttributeError: ‘Ui_Dialog’ object has no attribute ‘pb_hotkeyset’

@diogenes_nunes: thanks for reporting this bug. I just uploaded a new version to ankiweb that should fix it. Please update your add-ons and restart Anki. If you still have this problem or find another bug with my add-on please let me know.

Its complement is the best of anki! Congratulations!

The update resolved the previous error.

I found another bug now.

When applying STYLE INLINE it does not work.

The hotkey also does not work.

@diogenes_nunes: Thanks for reporting the new bug. I usually don’t use inline styling so I missed it. That’s why I need good bug reports (like yours).

I just uploaded a new version to ankiweb that should fix it. Please update your add-ons and restart Anki. If you still have this problem or find another bug with my add-on please let me know.

I don’t if that only happen to me,
Text Wrapper Not showing any fields

@ijgnd: The new update resolved the bug. Thank you!

@arpitdhiman777
In fact it happened to everybody. I just pushed a new version to AnkiWeb which should fix this bug. You can update right away.

1 Like

Awesome Work!!

Hi, After I update my add-ons today, I find this didn’t work! look like this. 2020-09-19_20-36
My Anki version : 2.1.26(arch-linux-2.1.26-1)
Debug Info:

Anki 2.1.26 (arch-linux-2.1.26-1) Python 3.8.5 Qt 5.15.1 PyQt 5.15.1
Platform: Linux
Flags: frz=False ao=True sv=1
Add-ons, last update check: 2020-09-19 13:16:38


===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Custom Styles font color background colour classes ['1899278645', 2020-09-19T00:56, 'None', '']

===IDs of active AnkiWeb add-ons===
1899278645

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AwesomeTTS Google Cloud Text-to-Speech unofficial ['814349176', 2020-09-17T16:41, 'None', '']
Batch Editing ['291119185', 2019-06-03T02:47, 'None', '']
Browser TableEditor side-by-side horizontal split ['831846358', 2020-07-08T07:44, 'None', '']
Edit Field During Review ['1020366288', 2020-01-30T00:33, 'None', '']
Fast Word Query Multi-threaded queries for words from local or web dictionaries ['1807206748', 2019-06-23T11:10, 'None', '']
Image Occlusion Enhanced for Anki 21 alpha ['1374772155', 2020-04-28T10:21, 'None', '']
ReviewHeatmap ['723520343', 2019-08-03T23:14, 'None', '']

I have a error when I added it. Can anyone help? Thanks


Error

An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.

If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeat until you discover the add-on that is causing the problem.

When you’ve discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.

Debug info:

Anki 2.1.32 (dee7d45d) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2

Platform: Mac 10.13.4

Flags: frz=True ao=True sv=1

Add-ons, last update check: 2020-09-20 08:36:20

Add-ons possibly involved: ⁨Custom Styles font color background colour classes⁩

Caught exception:

Traceback (most recent call last):

File “aqt/progress.py”, line 43, in handler

File “aqt/main.py”, line 142, in on_window_init

File “aqt/main.py”, line 231, in setupProfile

File “aqt/main.py”, line 427, in loadProfile

File “aqt/gui_hooks.py”, line 1978, in call

File “/Users/wangwei/Library/Application Support/Anki2/addons21/1899278645/conf_dict.py”, line 89, in load_conf_dict

if askUser(warning_message_about_templates(missing)):

File “/Users/wangwei/Library/Application Support/Anki2/addons21/1899278645/utils.py”, line 91, in warning_message_about_templates

You have the add-on “{addonname}” installed. This add-on will NOT work with these note types:

NameError: name ‘addonname’ is not defined

A quick fix would be to update to the latest Anki version, however I will push a fix later today, just be a little more patient :slight_smile:

Edit: I just pushed the fix.

1 Like

I will inspect this today, and push the fix.

Edit: I just pushed the fix.