Exemple #1
0
def showHelp(helpId: str):
    """Display the corresponding section of the user guide when either the Help
	button in an NVDA dialog is pressed or the F1 key is pressed on a
	recognized control.
	"""

    import ui
    import queueHandler
    if not helpId:
        # Translators: Message indicating no context sensitive help is available for the control or dialog.
        noHelpMessage = _("No help available here.")
        queueHandler.queueFunction(queueHandler.eventQueue, ui.message,
                                   noHelpMessage)
        return

    import gui
    helpFile = gui.getDocFilePath("userGuide.html")
    if helpFile is None:
        # Translators: Message shown when trying to display context sensitive help,
        # indicating that	the user guide could not be found.
        noHelpMessage = _("No user guide found.")
        log.debugWarning(
            "No user guide found: possible cause - running from source without building user docs"
        )
        queueHandler.queueFunction(queueHandler.eventQueue, ui.message,
                                   noHelpMessage)
        return
    log.debug(f"Opening help: helpId = {helpId}, userGuidePath: {helpFile}")

    nvdaTempDir = os.path.join(tempfile.gettempdir(), "nvda")
    if not os.path.exists(nvdaTempDir):
        os.mkdir(nvdaTempDir)

    contextHelpRedirect = os.path.join(nvdaTempDir, "contextHelp.html")
    try:
        # a redirect is necessary because not all browsers support opening a fragment URL from the command line.
        writeRedirect(helpId, helpFile, contextHelpRedirect)
    except Exception:
        log.error("Unable to write context help redirect file.", exc_info=True)
        return

    try:
        os.startfile(f"file://{contextHelpRedirect}")
    except Exception:
        log.error("Unable to launch context help.", exc_info=True)
Exemple #2
0
#importing bs4 is borrowed from textInformation addon by Carter Temm.
sys.path.append(CURRENT_DIR)
import imp
a, b, c = imp.find_module("bs4")
BeautifulSoup = imp.load_module("bs4", a, b, c).BeautifulSoup
del sys.path[-1]

import random
import gui
from .game import Game

import addonHandler
addonHandler.initTranslation()

#path of keyCommands.html in documentation files, taking into consideration nvda language
keyCommandsFile = gui.getDocFilePath("keyCommands.html")


def readFile(filepath):
    ''' reading the file that contains the required data and returning its html source as a string.'''
    with open(filepath, 'r', encoding='utf-8') as f:
        html = f.read()
    return html


def populateOptionsAndReturnList(lst, lst_all):
    '''Adding to obtions or answers list three random incorrect commands, beside the correct command already there.
	lst is a list of questions data, each element of it is a tuple, first item of it is the question and the second item is a list containing one item which is the correct answer.
	lst_all is a lis containing all scraped commands.
	'''
    result = []
Exemple #3
0
	def onWhatsNew(self, evt):
		os.startfile(gui.getDocFilePath("changes.html"))
		self.Close()
Exemple #4
0
	def onWhatsNew(self, evt):
		os.startfile(gui.getDocFilePath("changes.html"))
		self.Close()