Permalink
Browse files

Added backward flipping and one more key for forward flipping. Docume…

…nted in README.
  • Loading branch information...
1 parent ab6c0e4 commit a335555a32e05c3dfb5cd02657b560acfaddb071 @Vultaire committed Feb 9, 2012
Showing with 19 additions and 3 deletions.
  1. +9 −0 README.rst
  2. +10 −3 flashcards.py
View
@@ -45,6 +45,9 @@ GUI-based dialogs for telling the program what to do.
Help
====
+Usage
+-----
+
::
usage: flashcards.py [-h] [-f FONT_FACE] [-s FONT_SIZE] [-i INTERVAL] [-t]
@@ -70,6 +73,12 @@ Help
-t, --on-top Make the window stay always on top.
-v, --version Show version and exit.
+In-program keybindings
+----------------------
+
+| Enter, space bar or left click: **flip forward**
+| Backspace or right click: **flip backward**
+
Footnotes
=========
View
@@ -49,8 +49,12 @@ def __init__(self, root, data, interval, font_face, font_size, on_top):
self.root.wm_attributes("-topmost", 1)
# Bind events
- self.root.bind("<Button-1>", self.flip_card)
- self.root.bind("<Key-Return>", self.flip_card)
+ self.root.bind("<Button-1>", self.flip_forward)
+ self.root.bind("<Key-Return>", self.flip_forward)
+ self.root.bind("<Key-space>", self.flip_forward)
+
+ self.root.bind("<Button-3>", self.flip_backward)
+ self.root.bind("<Key-BackSpace>", self.flip_backward)
def reset_card(self):
"""
@@ -107,10 +111,13 @@ def update_card(self):
refresh_ms = int(self.refresh_interval * 1000)
self.root.after(refresh_ms, self.update_card)
- def flip_card(self, event):
+ def flip_forward(self, event):
self.current_index = (self.current_index + 1) % len(self.current)
self.card.configure(text=self.current[self.current_index])
+ def flip_backward(self, event):
+ self.current_index = (self.current_index - 1) % len(self.current)
+ self.card.configure(text=self.current[self.current_index])
def parse_args():
ap = argparse.ArgumentParser(

0 comments on commit a335555

Please sign in to comment.