Re: [orca-list] orca customizations



aerospace1028 hotmail com wrote:
I'm having a little trouble modifying my orca-customizations.py file.

I want to create a function so when I press orcaKey+c I turn the punctuation up to all and turn on speak 
indentation support.  I prefer these features when working with computer code or modifying settings files, 
but like them turned off for most other situations.  I thought, it'd be more convenient to have a 
key-combination defined in orca-customizations.py instead of going through the preffrences dialog every time.

I read through settings.py in the orca directory and found the definitions I need, I think.  I had previous 
successfully implimented a time and date capacity based off the instruction on live.gnome.org/orca/.  I tried 
modifying the templet from my time function to include the below, but it doesn't seam to work.

There were a couple of problems.

1/ The "def setCoding(script, inputEvent=None)" line didn't have
   a colon at the end of it.

2/ The next line wasn't indented properly. Python is really
   fussy about indentation.

I also suggest that you surround everything you put inside
your orca-customizations.py file with a try:/except: clause.
That means that if you do have an error, it'll be caught, and
Orca will recover from it and start up normally (rather than
bring up the Orca Preferences dialog).

I've attached a working version of the orca-customizations.py
file. I've left a couple lines of print debug in there to help
show that it was working.

try:
    # setup custom key bindings.
    #
    import orca.input_event
    import orca.keybindings
    import orca.orca
    import orca.speech
    import orca.braille
    import re

    # define keybindings object
    myKeyBindings = orca.keybindings.KeyBindings()

    ## the time function from live.gnome.org/orca/

    # define a function to change verbosity and punctuation
    # more compatible for coding.
    def setCoding(script, inputEvent=None):
        import orca.settings
        print "XXX: setCoding called."
        # increase punctuation level to all
        orca.settings.verbalizePunctuationStyle = orca.settings.PUNCTUATION_STYLE_ALL 
        # speak indentations
        orca.settings.enableSpeechIndentation = True
        return True

    setCodingHandler = orca.input_event.InputEventHandler(setCoding, "resets orca for typing computer code.") 

    # assign orca key + c to our setCode script
    myKeyBindings.add(orca.keybindings.KeyBinding("c", 1 << orca.settings.MODIFIER_ORCA, 1 << 
orca.settings.MODIFIER_ORCA, setCodingHandler))

    # add our new keybindings to orca
    orca.settings.keyBindingsMap["default"] = myKeyBindings
except:
    print "XXX: got an exception in orca-customization.py."


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