Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@aleventhal

This comment has been minimized.

Copy link

commented Apr 30, 2018

Hello, it would be wonderful if this worked.

I'm using NVDA 2018.1 and it looks like it expects .pyc but not .py files in NVDA\brailleDisplayDrivers.
What do I need to do to make this work with NVDA 2018.1? When I relaunch NVDA, it doesn't see the new driver.

Thanks!!!

@feerrenrut

This comment has been minimized.

Copy link
Owner Author

commented Apr 30, 2018

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

This comment has been minimized.

Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.