Countdown to Events / Exams addon [Official Thread]

If you have a problem with the add-on ‘Countdown to events / exams’ (https://ankiweb.net/shared/info/1143540799)

Then post in this thread. This way i get a notification. Alternatively you can email me: anki.sam@outlook.com

3 Likes

I am getting this on multiple of my computers with this add on (but I don’t get it on one computer). It only happens when I go to close Anki or switch profiles.

Debug info:
Anki 2.1.29 (bbff62bf) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=True sv=?
Add-ons, last update check: 2020-08-01 04:02:49

[2020-08-01 06:55:02,947] ERROR in app: Exception on /_addons/1143540799/styles.css [GET]
Traceback (most recent call last):
  File "lib\site-packages\flask\app.py", line 2447, in wsgi_app
  File "lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
  File "lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
  File "lib\site-packages\flask\app.py", line 1821, in handle_user_exception
  File "lib\site-packages\flask\_compat.py", line 39, in reraise
  File "lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
  File "lib\site-packages\flask\app.py", line 1936, in dispatch_request
  File "aqt\mediasrv.py", line 93, in allroutes
  File "aqt\mediasrv.py", line 199, in _redirectWebExports
AttributeError: 'NoneType' object has no attribute 'media'
[2020-08-01 06:55:03,018] ERROR in app: Exception on /_addons/1143540799/styles.css [GET]
Traceback (most recent call last):
  File "lib\site-packages\flask\app.py", line 2447, in wsgi_app
  File "lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
  File "lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
  File "lib\site-packages\flask\app.py", line 1821, in handle_user_exception
  File "lib\site-packages\flask\_compat.py", line 39, in reraise
  File "lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
  File "lib\site-packages\flask\app.py", line 1936, in dispatch_request
  File "aqt\mediasrv.py", line 93, in allroutes
  File "aqt\mediasrv.py", line 199, in _redirectWebExports
AttributeError: 'NoneType' object has no attribute 'media'

Likely because of the anki version you’re using, I’ll test it myself on 2.1.29 and see if i can get it to work

After looking at the code:

File: anki/qt/aqt/mediasrv.py
167: def _redirectWebExports(path):
...
199:     return aqt.mw.col.media.dir(), path

This happened because the col object was closed (None). @dae do we need to handle this?

I’ll push a fix later today

2 Likes

Not necessarily a problem, but is there any way to change the text color of the events listed on the deck page?

@cheesypancakes
If you want to do this, go into the add-on’s files and open __init__.py.
Replace:
content.stats += "<br>" + bold(str(daysLeft)) + " days until " + exam
With:
content.stats += "<br>" + """<span style="color: put_your_colour_here">""" + bold(str(daysLeft)) + " days until " + exam + """</span>"""

Enjoy :slight_smile:

@sam

exactly what I wanted! Thank you so much!

@sam
Is there any way to hide the “Events + settings button” that’s displayed above the countdown? Great idea, and thank you.

Hi, yes this is possible. Access __init__.py as described above. Then, this line of code needs to be removed.
content.stats += """<br><link rel="stylesheet" type="text/css" href="{}/styles.css"/><h3 style="display: inline-block;margin: 0 20px" >Events</h3> <div class="settings-btn" onclick='pycmd(\"add-new-event\");'><img src="{}/images/settings.png"></div>""".format( base_url, base_url)

Without this code, you will not be able to access the settings and add new events, so I would reccomend commenting the code out (by putting a # in front of each line) rather than deleting it. Then when you want the settings back, remove the comment(s).

Let me know if you have any problems

1 Like

@sam

That’s beautiful, thank you! I went ahead and just put a # in front of the lines and it worked like a charm! If it’s not too much hassle, could you tell me how I could keep a space between the “studied X cards in Y seconds today” and the countdown timer?

Right now it looks like this:

Studied 0 cards in 0 seconds today (Os/cards)
1 day until event

I’d like it to be

Studied 0 cards in 0 seconds today (Os/cards)

1 day until event

Just a space between the two. :slight_smile: Thank you, Sam.

Yep. On the next line (after the commented code), copy and paste this:

content.stats += "<br>"

No problem :slight_smile:

1 Like

@sam
I got it to work, thank you!

@sam

I keep getting this error when I open my Anki program. Can’t seem to figure out what it might be. Do you think you would be able to help out?

Thank you!

Debug info:
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-01-20 10:39:16
Add-ons possibly involved: ⁨Countdown To Events Exams⁩

Traceback (most recent call last):
File “aqt/main.py”, line 521, in loadCollection
File “aqt/main.py”, line 661, in moveToState
File “aqt/main.py”, line 668, in _deckBrowserState
File “</Applications/Anki.app/Contents/MacOS/decorator.pyc:decorator-gen-124>”, line 2, in show
File “anki/hooks.py”, line 638, in decorator_wrapper
File “anki/hooks.py”, line 629, in repl
File “aqt/deckbrowser.py”, line 58, in show
File “aqt/deckbrowser.py”, line 115, in _renderPage
File “aqt/deckbrowser.py”, line 124, in __renderPage
File “aqt/gui_hooks.py”, line 1000, in call
File “/Users/williamjones/Library/Application Support/Anki2/addons21/1143540799/init.py”, line 37, in display
deleteEvent(eventID)
File “/Users/williamjones/Library/Application Support/Anki2/addons21/1143540799/init.py”, line 44, in deleteEvent
cursor.execute(’’‘DELETE FROM events WHERE id=?’’’, str(eventID))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 2 supplied.

I’ll check it out, but I’ll need you to send me the add-on folder with its contents.

If you can attach it here then do that, otherwise email me: anki.sam [at] outlook.com

1 Like

Good job, I love this add-on! :heart:

Unfortunately I found out that the data of this add-on does not synchronize between devices. Is there any chance you could enable syncing event data via the AnkiWeb account?

I have no experience in add-on development and I don’t know if this is possible or easy to implement. Also the documentation on addon-docs.ankiweb.net seems a bit lackluster. But I can see references to a synchronized storage in this other project in class ConfigManager(object).

It would be a great option to be able to simply edit the event text and or date :slight_smile:

1 Like

Hello, thank you a lot for this really useful addon.

Just a little question/suggestion: is there a way to edit existing events?

1 Like

Thank you! No, not at the moment. Although I will add that feature soon.

1 Like

I am on Anki 2.1.35 on PC (Windows 10) - option to sort by date ascending/descending not showing.

image

Addon always asks for update in Addon settings and then nothing happens.

Gifs

  1. before Update- 1st addon
  2. after update - 2nd addon