Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mltony committed Oct 26, 2018
1 parent 742a7ff commit 6e08792
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions addon/globalPlugins/audioChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import operator
import re
import scriptHandler
from scriptHandler import script
import speech
import struct
import tones
Expand Down Expand Up @@ -143,7 +144,7 @@ def playAsync(values):
wx.CallAfter(play, values)

def play(values):
pitches = map(value_to_pitch, values)
pitches = list(map(value_to_pitch, values))
n = len(pitches)
beepBufSizes = [NVDAHelper.generateBeep(None, pitches[i], beep_duration, beep_volume, beep_volume) for i in range(n)]
bufSize = sum(beepBufSizes)
Expand All @@ -160,8 +161,9 @@ def play(values):

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
scriptCategory = _("AudioChart")

@script(description='Plot audio chart.', gestures=['kb:nvda+a', 'kb(laptop):nvda+ctrl+shift+a'])
def script_audioChart(self, gesture):
"""Plot audio chart."""
count=scriptHandler.getLastScriptRepeatCount()
if count >= 2:
return
Expand All @@ -179,17 +181,18 @@ def collectValues(self):
values = []
if isinstance(focus, excel.ExcelSelection):
colspan = focus._get_colSpan()
if colspan != 1:
# Translators: Message when more than one column is selected
ui.message(_("Please select only a single column."))
rowspan = focus._get_rowSpan()
if (colspan != 1) and (rowspan != 1):
# Translators: Message when more than one column and more than 1 row is selected
ui.message(_("Please select only a single column or a single row."))
return None
excelValues = focus.excelRangeObject.Value()
for evTuple in excelValues:
try:
ev = evTuple[0]
values.append(float(ev))
except:
continue
for ev in evTuple:
try:
values.append(float(ev))
except:
continue
if len(values) == 0:
# Translators: message when no numeric cells found within selected range
ui.message(_("No numeric values found within the selection."))
Expand Down Expand Up @@ -224,9 +227,3 @@ def popupCalibrationDialog(self, values):

def showCalibrationDialog(self, values):
wx.CallAfter(self.popupCalibrationDialog, values)


__gestures = {
"kb(desktop):NVDA+A": "audioChart",
"kb(laptop):NVDA+Control+Shift+A": "audioChart",
}

0 comments on commit 6e08792

Please sign in to comment.