Hi,
Sorry about the previous lack of instructions for getting everything set
up.  I am going to try and attach the file this time.  I wasn't sure
that the list's mail handler would allow attachments.  The file goes in
your ~/.orca directory.  Here are the key presses in the newest script.
orca-d speak and/or Braille the date
orca-t speak and/or Braille the time
orca-w speak and/or Braille the current temperature and conditions.
The time and date are also placed into the clipboard so they can be
pasted with a simple press of ctrl-v
A note about the weather.  I wanted to get the weather from the top
panel.  In Ubuntu, it is shown with the clock.  I couldn't find the
information I needed to access this though, so I wrote a script to get
the info from Yahoo's weather services.  I got to thinking that this may
be the best way to do things after all, because I am not sure that all
distros have the weather posted with the clock, and even if they do,
they may not all use the same program to do it.  The only drawback is,
if you press the orca-w keys to get the weather and are not connected to
the internet there is a bit of significant lag while the script attempts
to get the info.  IF you do have internet connectivity though, it's
nearly instantly displayed.  Ok, here's the script, let me know if you
need any help with it, if there's something that can be done to improve
it, etc.
Storm
   




    

<<attachment: 1.gif>>

"""This script adds time and date functionality to Orca
New in this script, time or date can be pasted from the clipboard
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 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

#change the next line to your zip code:
zipCode = 28624

#places text in the clipboard
def setClipboardText(text):
  import gtk # import the gtk library
  cb = gtk.Clipboard()
  cb.set_text(text)
  cb.store()

#getWeather function gets weather from Yahoo
def getWeather(zip_code):
  if zip_code != 0:
    import urllib
    from xml.dom import minidom
    WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
    WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'
    url = WEATHER_URL % zip_code
    dom = minidom.parse(urllib.urlopen(url))
    ycondition = dom.getElementsByTagNameNS(WEATHER_NS, 'condition')[0]
    weatherReport = ycondition.getAttribute('temp') + ' | ' + ycondition.getAttribute('text')
  else:
    weatherReport = "No zip code set: Please edit .orca/orca-customizations.py"
  return weatherReport

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)
  setClipboardText(message)
  return True
#end sayTime function


#Define the sayDate function
def sayDate(script, inputEvent=None):
  import time # imports the Python time library
  message = time.strftime("%A, %B %d, %Y", time.localtime())
  orca.speech.speak(message)
  orca.braille.displayMessage(message)
  setClipboardText(message)
  return True
#end sayDate function

#Define the sayWeather function
def sayWeather(script, inputEvent=None):
  message = getWeather(zipCode)
  orca.speech.speak(message)
  orca.braille.displayMessage(message)
  return True
#end sayWeather function

#Set up sayTime keys
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

#add sayDate info
sayDateHandler = orca.input_event.InputEventHandler(
    sayDate,
    "Presents the date.") # Shows the function of the key press in learn mode

myKeyBindings.add(orca.keybindings.KeyBinding(
    "d",
    1 << orca.settings.MODIFIER_ORCA,
    1 << orca.settings.MODIFIER_ORCA,
    sayDateHandler)) # Sets Orca-d as the say date key

#add sayWeather info
sayWeatherHandler = orca.input_event.InputEventHandler(
    sayWeather,
    "Get current temperature and conditions.") # Shows the function of the key press in learn mode

myKeyBindings.add(orca.keybindings.KeyBinding(
    "w",
    1 << orca.settings.MODIFIER_ORCA,
    1 << orca.settings.MODIFIER_ORCA,
    sayWeatherHandler)) # Sets Orca-d as the say date key

orca.settings.keyBindingsMap["default"] = myKeyBindings
#end time, date, and weather code
-- 
Ubuntu-accessibility mailing list
Ubuntu-accessibility@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-accessibility

Reply via email to