[orca-list] Orca Time Script



Hi,
I have attempted to addapt slightly the time and date script from the Orca FAQ.  I broke it.  I am not sure how.  I added some comments, changed the keybinding to Orca-t instead of Orca-d and made it only speak the time in 12 hour format instead of 24 hour format with AM or PM afterwards.  I placed the file in my ~/.orca/orca-scripts directory with the name timekey.py
The problem is, when I proess Orca-t and/or Orca-d, nothing happens.  Here's the code, can someone please tell me what is wrong with it?  Thanks for the help.
Storm
PS  Please take a look at my comments in the code and make sure that I know what I am talking about. :)

"""This script adds time functionality to Orca
Adapted by Storm Dragon from the script posted at:
http://live.gnome.org/Orca/FrequentlyAskedQuestions#head-6a8c1c2511ba01d7397f68f754eec0d923d166f1
feel free to modify and/or redistribute this script as you see fit."""
#import gets code that has already been written.
#think of it as using wheels instead of trying to reinvent them.
import orca.input_event # watches for input that Orca recognizes
import orca.keybindings # Handles binding keystrokes for Orca to use.
import orca.orca # Imports the main screen reader
import orca.speech # Handles Orca's speaking abilities
import orca.braille # Displays information in Braille format
import re # Not sure

myKeyBindings = orca.keybindings.KeyBindings()

#Define the sayTime function
def sayTime(script, inputEvent=None):
    import time # imports the Python time library
    message = time.strftime("%I:%M%p", time.localtime())
    orca.speech.speak(message)
    orca.braille.displayMessage(message)
    return True
#end sayTime function

sayTimeHandler = orca.input_event.InputEventHandler(
    sayTime,
    "Presents the time.") # Shows the function of the key press in learn mode

myKeyBindings.add(orca.keybindings.KeyBinding(
    "t",
    1 << orca.settings.MODIFIER_ORCA,
    1 << orca.settings.MODIFIER_ORCA,
    sayTimeHandler)) # Sets Orca-t as the say time key

orca.settings.keyBindingsMap["default"] = myKeyBindings





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]