Re: Please Help to build an addon for Anki

2015-04-20 Thread Ben Finney
Mahesh Chiramure  writes:

> I liked the addon "Picture-flasher" written for anki very much
> and I was wondering if the same thing could be done with mp3 and/or
> flac files.

Quite probably.

That sounds like a good small project to tackle: you've found a
free-software program, it has an existing feature you like, and you
want to add a similar feature. Good choice!

> I am not a programmer yet, please guide.

You'll want to collaborate with programmers. Maybe even the programmers
responsible for maintaining Anki.

> Hoping for a quick response.

Hopefully this is quick enough.

-- 
 \  “If you don't fail at least 90 percent of the time, you're not |
  `\aiming high enough.” —Alan Kay |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Please Help to build an addon for Anki

2015-04-20 Thread Mahesh Chiramure
Hi

I liked the addon "Picture-flasher" written for anki very much
and I was wondering if the same thing could be done with mp3 and/or
flac files. Means I am looking for an addon that chooses a random mp3
and/or flac file from a directory provided by me (to the addon as we
have to provide in "Picture-flasher") and plays it on successful
reviewing of a certain number of cards (as does the addon
"Picture-flasher"). As a music lover, I feel that this addon can
motivate a whole lot of music lovers out there to pay a visit to Anki
on their PC and review to listen to their favorite mp3 and/or flac
files as a reward.

I am not a programmer yet, please guide.

Hoping for a quick response.

Mahesh Chirmure
# -*- coding: utf-8 -*-
# Picture-Flasher (a plugin for Anki)
# Authors:
#   Emanuel Rylke, ema-...@web.de
#   D_Malik, malik6...@gmail.com
# Version 2
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html

"""
A simple plugin that flashes pictures on-screen to reinforce reviews.

Before using:
- Get pictures from someplace. I downloaded pictures off reddit using the 
script at https://github.com/dpbrown/RedditImageGrab
- Change all lines (in the plugin source) marked with "CHANGEME" according to 
your preferences.

For more details, see the post at For more details, see the post at 
http://lesswrong.com/r/discussion/lw/frc/two_anki_plugins_to_reinforce_reviewing/
"""

from anki.hooks import addHook
from aqt import mw
from random import random, choice
from aqt.qt import QSplashScreen, QPixmap, QTimer
from os import listdir

#-- begin configuration --#
pictureDirectory = "E://Family stuff//22 Feb//Personal//College//A J//" 
#CHANGEME to the directory where you're storing your pictures. NB: This MUST 
end with a trailing slash e.g. D://Family stuff//19 Jan//Imgs//Wallys//, 
D://Family stuff//22 Feb//Imgs//Windows 7//.

flashTime = 3000 #CHANGEME to change how long pictures stay on the screen. The 
number is time in milliseconds.

#flashPosition = [20, 1050] #CHANGEME if you want the picture to be shown at a 
specific location. The numbers are x- and y-coordinates.

#CHANGEME: The next lines are a python dictionary associating deck names 
with probabilities of pictures being shown.
#Eg, when using the deck "brainscience", you will get a picture after 30% 
of cards. When using a deck without a listed name, "other" is used.
#Change this according to your decks. Decks with shorter, easier cards need 
lower probabilities.
deckPicsProbabilities = {
"rocketsurgery":   0.3,
"brainscience" :   0.5,
"other":   0.1,
}
#--- end configuration ---#

pics = listdir(pictureDirectory)

def showPics():
if mw.col.decks.current()['name'] in deckPicsProbabilities:
picsProbability = deckPicsProbabilities[mw.col.decks.current()['name']]
else:
picsProbability = deckPicsProbabilities["other"]

if random() < picsProbability:
mw.splash = QSplashScreen(QPixmap(pictureDirectory + choice(pics)))
try:
mw.splash.move(flashPosition[0], flashPosition[1])
except NameError:
pass
mw.splash.show()
QTimer.singleShot(flashTime, mw.splash.close)

addHook("showQuestion", showPics)
-- 
https://mail.python.org/mailman/listinfo/python-list