Skip to content

Instantly share code, notes, and snippets.

@feerrenrut
Last active May 26, 2020 07:57
Show Gist options
  • Save feerrenrut/73ec3ae46dda87effcb20d6e51a28551 to your computer and use it in GitHub Desktop.
Save feerrenrut/73ec3ae46dda87effcb20d6e51a28551 to your computer and use it in GitHub Desktop.
A braille display driver for NVDA. Braille is displayed on screen. Save this file to the 'brailleDisplayDrivers' folder in your user config (`%appdata%/nvda/brailleDisplayDrivers`) directory or in `source\brailleDisplayDrivers\` directory in your repository.
#brailleViewer.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2017 NV Access Limited
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
import wx
import gui
import braille
NUM_CELLS = 40
class BrailleViewerFrame(wx.MiniFrame):
def __init__(self):
super(BrailleViewerFrame, self).__init__(gui.mainFrame, wx.ID_ANY, _("NVDA Braille Viewer"), style=wx.CAPTION | wx.RESIZE_BORDER | wx.STAY_ON_TOP)
self.Bind(wx.EVT_CLOSE, self.onClose)
mainSizer = wx.BoxSizer(wx.VERTICAL)
item = self.output = wx.StaticText(self, label=u"\u2800" * NUM_CELLS)
font = item.Font
font.PointSize = 24
item.Font = font
mainSizer.Add(item, proportion=1, flag=wx.EXPAND)
mainSizer.Fit(self)
self.Sizer = mainSizer
self.Show()
def onClose(self, evt):
if not evt.CanVeto():
self.Destroy()
return
evt.Veto()
class BrailleDisplayDriver(braille.BrailleDisplayDriver):
name = "brailleViewer"
description = _("Braille viewer")
numCells = NUM_CELLS
@classmethod
def check(cls):
return True
def __init__(self):
super(BrailleDisplayDriver, self).__init__()
if gui.mainFrame:
self._frame = BrailleViewerFrame()
else:
# GUI not initialised yet, so we'll initialise later.
self._frame = None
def display(self, cells):
if not self._frame and gui.mainFrame:
self._frame = BrailleViewerFrame()
if not self._frame:
return
self._frame.output.Label = u"".join(unichr(0x2800 + cell) for cell in cells)
def terminate(self):
super(BrailleDisplayDriver, self).terminate()
try:
self._frame.Destroy()
except wx.PyDeadObjectError:
# NVDA's GUI has already terminated.
pass
@feerrenrut
Copy link
Author

Yes, it looks like I didn't write very good instructions. Sorry about that. It should work with an installation of NVDA if you place the file in %appdata%/nvda/brailleDisplayDrivers.

@smackbrl
Copy link

smackbrl commented Feb 3, 2019

I am not actually a programmer, but I unzipped the file and put it in NVDA/brailleDisplayDrivers. I can see the file in there in Windows Explorers, but Braille Viewer is not listed when I go into NVDA braille displays. What does the %appdata% part of your directions mean? Thanks!

@feerrenrut
Copy link
Author

Note: The braille viewer has been integrated with NVDA, find it via the tools menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment