コード例 #1
0
ファイル: settings.py プロジェクト: codeofdusk/ProjectMagenta
 def create_config(self):
  self.kmmap=self.make_kmmap()
  self.langs = languageHandler.getAvailableLanguages()
  langs = []
  [langs.append(i[1]) for i in self.langs]
  self.codes = []
  [self.codes.append(i[0]) for i in self.langs]
  id = self.codes.index(config.app["app-settings"]["language"])
  self.kmfriendlies=[]
  self.kmnames=[]
  for k,v in self.kmmap.items():
   self.kmfriendlies.append(k)
   self.kmnames.append(v)
  self.kmid=self.kmnames.index(config.app['app-settings']['load_keymap'])
  self.dialog.create_general(langs,self.kmfriendlies)
  self.dialog.general.language.SetSelection(id)
  self.dialog.general.km.SetSelection(self.kmid)
  self.dialog.set_value("general", "ask_at_exit", config.app["app-settings"]["ask_at_exit"])
  
  self.dialog.set_value("general", "play_ready_sound", config.app["app-settings"]["play_ready_sound"])
  self.dialog.set_value("general", "speak_ready_msg", config.app["app-settings"]["speak_ready_msg"])
  self.dialog.set_value("general", "handle_longtweets", config.app["app-settings"]["handle_longtweets"])
  self.dialog.set_value("general", "use_invisible_shorcuts", config.app["app-settings"]["use_invisible_keyboard_shorcuts"])
  self.dialog.set_value("general", "disable_sapi5", config.app["app-settings"]["voice_enabled"])
  self.dialog.set_value("general", "hide_gui", config.app["app-settings"]["hide_gui"])  
  self.dialog.create_proxy()
  self.dialog.set_value("proxy", "server", config.app["proxy"]["server"])
  self.dialog.set_value("proxy", "port", config.app["proxy"]["port"])
  self.dialog.set_value("proxy", "user", config.app["proxy"]["user"])
  self.dialog.set_value("proxy", "password", config.app["proxy"]["password"])
  self.dialog.realize()
  self.response = self.dialog.get_response()
コード例 #2
0
	def test_knownLanguageCodesInList(self):
		"""Ensure that expected languages are in the list."""
		langCodes = [lang[0] for lang in languageHandler.getAvailableLanguages()]
		self.assertIn("pl", langCodes)
		self.assertIn("ru", langCodes)
		self.assertIn("zh_TW", langCodes)
		self.assertIn("kmr", langCodes)
コード例 #3
0
	def test_langsListExpectedFormat(self):
		"""Ensures that for all languages except user default each element of the returned list consists of
		language code, and language  description containing language code
		(necessary since lang descriptions are localized to the default Windows language)."""
		for langCode, langDesc in languageHandler.getAvailableLanguages()[1:]:
			self.assertIn(langCode, langDesc)
			self.assertIn(languageHandler.getLanguageDescription(langCode), langDesc)
コード例 #4
0
 def onSave(self):
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "method"] = self.undefinedCharReprList.GetSelection()
     repr_ = self.undefinedCharReprEdit.Value
     if self.undefinedCharReprList.GetSelection() == CHOICE_otherDots:
         repr_ = re.sub(r"[^0-8\-]", "", repr_).strip("-")
         repr_ = re.sub(r"\-+", "-", repr_)
         config.conf["brailleExtender"]["undefinedCharsRepr"][
             "hardDotPatternValue"] = repr_
     else:
         config.conf["brailleExtender"]["undefinedCharsRepr"][
             "hardSignPatternValue"] = repr_
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "desc"] = self.undefinedCharDesc.IsChecked()
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "extendedDesc"] = self.extendedDesc.IsChecked()
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "fullExtendedDesc"] = self.fullExtendedDesc.IsChecked()
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "showSize"] = self.showSize.IsChecked()
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "start"] = self.startTag.Value
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "end"] = self.endTag.Value
     config.conf["brailleExtender"]["undefinedCharsRepr"][
         "lang"] = languageHandler.getAvailableLanguages()[
             self.undefinedCharLang.GetSelection()][0]
     undefinedCharTable = self.undefinedCharTable.GetSelection()
     keys = ["current"] + [
         table.fileName for table in addoncfg.tables if table.output
     ]
     config.conf["brailleExtender"]["undefinedCharsRepr"]["table"] = keys[
         undefinedCharTable]
コード例 #5
0
	def test_noDuplicates(self):
		seenLangCodes = set()
		seenLangDescs = set()
		for langCode, langDesc in languageHandler.getAvailableLanguages():
			self.assertNotIn(langCode, seenLangCodes)
			seenLangCodes.add(langCode)
			self.assertNotIn(langDesc, seenLangDescs)
			seenLangDescs.add(langDesc)
コード例 #6
0
	def test_langsWithOutTranslationsNotInList(self):
		"""Ensure that languages which do  not have a translations
		(i.e. only symbol  files are present) are excluded ."""
		langCodes = [lang[0] for lang in languageHandler.getAvailableLanguages()]
		self.assertNotIn("be", langCodes)
		self.assertNotIn("te", langCodes)
		self.assertNotIn("zh", langCodes)
		self.assertNotIn("kok", langCodes)
コード例 #7
0
ファイル: configuration.py プロジェクト: Oire/TWBlue
 def __init__(self, parent):
  wx.Panel.__init__(self, parent)
  sizer = wx.BoxSizer(wx.VERTICAL)
  language = wx.StaticText(self, -1, _(u"Language"))
  self.langs = languageHandler.getAvailableLanguages()
  langs = []
  [langs.append(i[1]) for i in self.langs]
  self.codes = []
  [self.codes.append(i[0]) for i in self.langs]
  self.language = wx.ListBox(self, -1, choices=langs)
  id = self.codes.index(config.main["general"]["language"])
  self.language.SetSelection(id)
  self.language.SetSize(self.language.GetBestSize())
  langBox = wx.BoxSizer(wx.HORIZONTAL)
  langBox.Add(language, 0, wx.ALL, 5)
  langBox.Add(self.language, 0, wx.ALL, 5)
  sizer.Add(langBox, 0, wx.ALL, 5)
  self.au = wx.Button(self, -1, _(u"Set the autocomplete function"))
  self.ask_at_exit = wx.CheckBox(self, -1, _(U"ask before exiting TwBlue?"))
  self.ask_at_exit.SetValue(config.main["general"]["ask_at_exit"])
  sizer.Add(self.ask_at_exit, 0, wx.ALL, 5)
  self.use_invisible_shorcuts = wx.CheckBox(self, -1, _(u"Use invisible interface's keyboard shorcuts on the GUI"))
  self.use_invisible_shorcuts.SetValue(config.main["general"]["use_invisible_keyboard_shorcuts"])
  sizer.Add(self.use_invisible_shorcuts, 0, wx.ALL, 5)
  self.relative_time = wx.CheckBox(self, -1, _(U"Relative times"))
  self.relative_time.SetValue(config.main["general"]["relative_times"])
  sizer.Add(self.relative_time, 0, wx.ALL, 5)
  if platform.system() == "Windows":
   self.disable_sapi5 = wx.CheckBox(self, -1, _(u"Activate Sapi5 when any other screen reader is not being run"))
   self.disable_sapi5.SetValue(config.main["general"]["voice_enabled"])
   sizer.Add(self.disable_sapi5, 0, wx.ALL, 5)
   self.show_gui = wx.CheckBox(self, -1, _(u"Activate the auto-start of the invisible interface"))
   self.show_gui.SetValue(config.main["general"]["hide_gui"])
   sizer.Add(self.show_gui, 0, wx.ALL, 5)
  apiCallsBox = wx.BoxSizer(wx.HORIZONTAL)
  apiCallsBox.Add(wx.StaticText(self, -1, _(u"API calls when the stream is started (One API call equals to 200 tweetts, two API calls equals 400 tweets, etc):")), 0, wx.ALL, 5)
  self.apiCalls = wx.SpinCtrl(self, -1)
  self.apiCalls.SetRange(1, 10)
  self.apiCalls.SetValue(config.main["general"]["max_api_calls"])
  self.apiCalls.SetSize(self.apiCalls.GetBestSize())
  apiCallsBox.Add(self.apiCalls, 0, wx.ALL, 5)
  sizer.Add(apiCallsBox, 0, wx.ALL, 5)
  tweetsPerCallBox = wx.BoxSizer(wx.HORIZONTAL)
  tweetsPerCallBox.Add(wx.StaticText(self, -1, _(u"Items on each API call")), 0, wx.ALL, 5)
  self.itemsPerApiCall = wx.SpinCtrl(self, -1)
  self.itemsPerApiCall.SetRange(0, 200)
  self.itemsPerApiCall.SetValue(config.main["general"]["max_tweets_per_call"])
  self.itemsPerApiCall.SetSize(self.itemsPerApiCall.GetBestSize())
  tweetsPerCallBox.Add(self.itemsPerApiCall, 0, wx.ALL, 5)
  sizer.Add(tweetsPerCallBox, 0, wx.ALL, 5)
  self.reverse_timelines = wx.CheckBox(self, -1, _(u"Inverted buffers: The newest tweets will be shown at the beginning of the lists while the oldest at the end"))
  self.reverse_timelines.SetValue(config.main["general"]["reverse_timelines"])
  sizer.Add(self.reverse_timelines, 0, wx.ALL, 5)
  self.SetSizer(sizer)
コード例 #8
0
ファイル: dialogs.py プロジェクト: Futyn-Maker/Access8Math
	def __init__(self, parent):
		super(NewLanguageAddingDialog,self).__init__(parent, title=_("New language adding"))
		import languageHandler
		self.mainSizer=wx.BoxSizer(wx.VERTICAL)
		self.sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.HORIZONTAL)

		exist_languages = os.listdir(os.path.join(base_path, 'locale'))
		self.languageNames = languageHandler.getAvailableLanguages()[:-1]
		self.languageNames = [x for x in self.languageNames if not x[0] in exist_languages]
		languageChoices = [x[1] for x in self.languageNames]
		print(languageChoices)
		# Translators: The label for a setting in general settings to select NVDA's interface language (once selected, NVDA must be restarted; the option user default means the user's Windows language will be used).
		languageLabelText = _("&Language:")
		self.languageList=self.sHelper.addLabeledControl(languageLabelText, wx.Choice, choices=languageChoices)
		self.languageIndex = self.languageList.Selection = 0

		languageListSize = self.languageList.GetSize()
		self.certainLanguageList = self.sHelper.addItem(wx.Choice(self, size=languageListSize))
		#self.certainLanguageList=self.sHelper.addLabeledControl(languageLabelText, wx.Choice, choices=[], size=languageListSize)
		self.certainLanguageList.Hide()

		self.certainButton = self.sHelper.addItem(wx.Button(self, label=_("&Select")))
		self.certainButton.Bind(wx.EVT_BUTTON, self.OnCertainClick)
		self.certainLanguage = None

		self.uncertainButton = self.sHelper.addItem(wx.Button(self, label=_("&Unselect")))
		self.uncertainButton.Bind(wx.EVT_BUTTON, self.OnUncertainClick)
		self.uncertainButton.Hide()

		#bHelper = sHelper.addItem(guiHelper.ButtonHelper(orientation=wx.HORIZONTAL))
		self.bHelper = guiHelper.ButtonHelper(orientation=wx.HORIZONTAL)

		# Add button
		self.unicodeDicButton = self.bHelper.addButton(self, label=_("unicode dictionary"))
		self.mathRuleButton = self.bHelper.addButton(self, label=_("math rule"))
		self.OkButton = self.bHelper.addButton(self, label=_("OK"), id=wx.ID_OK)

		# Bind button
		self.unicodeDicButton.Bind(wx.EVT_BUTTON, self.OnUnicodeDicClick)
		self.mathRuleButton.Bind(wx.EVT_BUTTON, self.OnMathRuleClick)
		self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)

		# Hide button
		self.unicodeDicButton.Disable()
		self.mathRuleButton.Disable()
		self.OkButton.Disable()

		self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

		self.mainSizer.Add(self.sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
		self.mainSizer.Add(self.bHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)

		self.mainSizer.Fit(self)
		self.SetSizer(self.mainSizer)
コード例 #9
0
	def __init__(self, parent, addonsList):
		if ToolsForAddonDialog._instance is not None:
			return
		ToolsForAddonDialog._instance = self
		# Translators: This is the title of the dialog
		dialogTitle = _("Tools for add-on development")
		title = ToolsForAddonDialog.title = makeAddonWindowTitle(dialogTitle)
		super(ToolsForAddonDialog, self).__init__(
			parent, -1, title, style=wx.CAPTION | wx.CLOSE_BOX | wx.TAB_TRAVERSAL)
		self.addonsList = addonsList
		languageNames = languageHandler.getAvailableLanguages()
		self.languages = {x[0]: x[1] for x in languageNames}
		self.doGui()
コード例 #10
0
    def create_config(self):
        self.kmmap = self.make_kmmap()
        self.langs = languageHandler.getAvailableLanguages()
        langs = []
        [langs.append(i[1]) for i in self.langs]
        self.codes = []
        [self.codes.append(i[0]) for i in self.langs]
        id = self.codes.index(config.app["app-settings"]["language"])
        self.kmfriendlies = []
        self.kmnames = []
        for k, v in self.kmmap.items():
            self.kmfriendlies.append(k)
            self.kmnames.append(v)
        self.kmid = self.kmnames.index(
            config.app['app-settings']['load_keymap'])
        self.dialog.create_general(langs, self.kmfriendlies)
        self.dialog.general.language.SetSelection(id)
        self.dialog.general.km.SetSelection(self.kmid)
        self.dialog.set_value("general", "ask_at_exit",
                              config.app["app-settings"]["ask_at_exit"])

        self.dialog.set_value("general", "play_ready_sound",
                              config.app["app-settings"]["play_ready_sound"])
        self.dialog.set_value("general", "speak_ready_msg",
                              config.app["app-settings"]["speak_ready_msg"])
        self.dialog.set_value("general", "handle_longtweets",
                              config.app["app-settings"]["handle_longtweets"])
        self.dialog.set_value(
            "general", "use_invisible_shorcuts",
            config.app["app-settings"]["use_invisible_keyboard_shorcuts"])
        self.dialog.set_value("general", "disable_sapi5",
                              config.app["app-settings"]["voice_enabled"])
        self.dialog.set_value("general", "hide_gui",
                              config.app["app-settings"]["hide_gui"])
        self.dialog.create_proxy()
        self.dialog.set_value("proxy", "server", config.app["proxy"]["server"])
        self.dialog.set_value("proxy", "port", config.app["proxy"]["port"])
        self.dialog.set_value("proxy", "user", config.app["proxy"]["user"])
        self.dialog.set_value("proxy", "password",
                              config.app["proxy"]["password"])
        self.dialog.realize()
        self.response = self.dialog.get_response()
コード例 #11
0
 def makeSettings(self, settingsSizer):
     sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
     # Translators: label of a dialog.
     label = _("Representation &method:")
     self.undefinedCharReprList = sHelper.addLabeledControl(
         label, wx.Choice, choices=list(CHOICES_LABELS.values()))
     self.undefinedCharReprList.SetSelection(
         config.conf["brailleExtender"]["undefinedCharsRepr"]["method"])
     self.undefinedCharReprList.Bind(wx.EVT_CHOICE,
                                     self.onUndefinedCharReprList)
     # Translators: label of a dialog.
     self.undefinedCharReprEdit = sHelper.addLabeledControl(
         _("Specify another &pattern"),
         wx.TextCtrl,
         value=self.getHardValue())
     self.undefinedCharDesc = sHelper.addItem(
         wx.CheckBox(
             self,
             label=(_(
                 "Show punctuation/symbol &name for undefined characters if available (can cause a lag)"
             ))))
     self.undefinedCharDesc.SetValue(
         config.conf["brailleExtender"]["undefinedCharsRepr"]["desc"])
     self.undefinedCharDesc.Bind(wx.EVT_CHECKBOX, self.onUndefinedCharDesc)
     self.extendedDesc = sHelper.addItem(
         wx.CheckBox(
             self,
             label=_(
                 "Also describe e&xtended characters (e.g.: country flags)")
         ))
     self.extendedDesc.SetValue(config.conf["brailleExtender"]
                                ["undefinedCharsRepr"]["extendedDesc"])
     self.extendedDesc.Bind(wx.EVT_CHECKBOX, self.onExtendedDesc)
     self.fullExtendedDesc = sHelper.addItem(
         wx.CheckBox(self, label=_("&Full extended description")))
     self.fullExtendedDesc.SetValue(
         config.conf["brailleExtender"]["undefinedCharsRepr"]
         ["fullExtendedDesc"])
     self.showSize = sHelper.addItem(
         wx.CheckBox(self, label=_("Show the si&ze taken")))
     self.showSize.SetValue(
         config.conf["brailleExtender"]["undefinedCharsRepr"]["showSize"])
     self.startTag = sHelper.addLabeledControl(
         _("&Start tag:"),
         wx.TextCtrl,
         value=config.conf["brailleExtender"]["undefinedCharsRepr"]
         ["start"],
     )
     self.endTag = sHelper.addLabeledControl(
         _("&End tag:"),
         wx.TextCtrl,
         value=config.conf["brailleExtender"]["undefinedCharsRepr"]["end"],
     )
     values = [lang[1] for lang in languageHandler.getAvailableLanguages()]
     keys = [lang[0] for lang in languageHandler.getAvailableLanguages()]
     undefinedCharLang = config.conf["brailleExtender"][
         "undefinedCharsRepr"]["lang"]
     if not undefinedCharLang in keys:
         undefinedCharLang = keys[-1]
     undefinedCharLangID = keys.index(undefinedCharLang)
     self.undefinedCharLang = sHelper.addLabeledControl(_("&Language:"),
                                                        wx.Choice,
                                                        choices=values)
     self.undefinedCharLang.SetSelection(undefinedCharLangID)
     values = [_("Use the current output table")] + [
         table.displayName for table in addoncfg.tables if table.output
     ]
     keys = ["current"] + [
         table.fileName for table in addoncfg.tables if table.output
     ]
     undefinedCharTable = config.conf["brailleExtender"][
         "undefinedCharsRepr"]["table"]
     if undefinedCharTable not in addoncfg.tablesFN + ["current"]:
         undefinedCharTable = "current"
     undefinedCharTableID = keys.index(undefinedCharTable)
     self.undefinedCharTable = sHelper.addLabeledControl(
         _("Braille &table:"), wx.Choice, choices=values)
     self.undefinedCharTable.SetSelection(undefinedCharTableID)
     self.onExtendedDesc()
     self.onUndefinedCharDesc()
     self.onUndefinedCharReprList()
コード例 #12
0
	def test_userDefaultDescriptionIsCorrect(self):
		"""Description for the 'user default' should not contain a language code."""
		userDefaultLangCode, userDefaultLangDesc = languageHandler.getAvailableLanguages()[0]
		self.assertEqual(userDefaultLangCode, "Windows")
		self.assertNotIn(userDefaultLangCode, userDefaultLangDesc)
コード例 #13
0
ファイル: models.py プロジェクト: tsengwoody/WorldVoice
import codecs
import collections
import os

import addonHandler
import globalVars
import languageHandler
from logHandler import log

addonHandler.initTranslation()

base_path = globalVars.appArgs.configPath

SPEECH_SYMBOL_LANGUAGE_LABELS = dict(languageHandler.getAvailableLanguages())

SYMMOD_CONTEXT = 0
SYMMOD_FORCE = 1

SPEECH_SYMBOL_MODE_LABELS = {
    SYMMOD_CONTEXT: _("context"),
    SYMMOD_FORCE: _("force"),
}


class SpeechSymbol(object):
    __slots__ = ("identifier", "replacement", "language", "mode",
                 "displayName")

    def __init__(self,
                 identifier,
                 replacement=None,
コード例 #14
0
ファイル: models.py プロジェクト: tsengwoody/WorldVoice
    def __init__(self):
        """Constructor.
		"""
        self.symbols = collections.OrderedDict()
        self.fileName = None
        self.localesToNames = dict(languageHandler.getAvailableLanguages())
コード例 #15
0
def generateUnsupportedWindowsLocales():
	"""Generates list of languages which are not supported under the current version of Windows.
	Uses `localesData.LANG_NAMES_TO_LOCALIZED_DESCS` as a base but filters further
	since unsupported languages are different under different systems."""
	unsupportedLangs = set()
	for localeName in LANG_NAMES_TO_LOCALIZED_DESCS.keys():
		# `languageHandler.englishCountryNameFromNVDALocale` returns `None` for locale unknown to Windows.
		if not languageHandler.englishCountryNameFromNVDALocale(localeName):
			unsupportedLangs.add(localeName)
	return unsupportedLangs


LCID_ENGLISH_US = 0x0409
UNSUPPORTED_WIN_LANGUAGES = generateUnsupportedWindowsLocales()
TRANSLATABLE_LANGS = set(l[0] for l in languageHandler.getAvailableLanguages()) - {"Windows"}
WINDOWS_LANGS = set(locale.windows_locale.values()).union(LCIDS_TO_TRANSLATED_LOCALES.values())


class TestLocaleNameToWindowsLCID(unittest.TestCase):
	def test_knownLocale(self):
		lcid = languageHandler.localeNameToWindowsLCID("en")
		self.assertEqual(lcid, LCID_ENGLISH_US)

	def test_windowsUnknownLocale(self):
		# "an" is the locale name for Aragonese, but Windows doesn't know about it.
		lcid = languageHandler.localeNameToWindowsLCID("an")
		self.assertEqual(lcid, LCID_NONE)

	def test_nonStandardLocale(self):
		lcid = languageHandler.localeNameToWindowsLCID("us")
コード例 #16
0
	def test_manuallyAddedLocalesPresentInList(self):
		"""Some locales do not have translations, yet they should be  present in the list."""
		langCodes = [lang[0] for lang in languageHandler.getAvailableLanguages()]
		self.assertEqual("Windows", langCodes[0])
		self.assertIn("en", langCodes)
コード例 #17
0
	def makeSettings(self, settingsSizer):
		sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
		self.options = []
		for (label, flagList, defaultValue, allowInSecureMode) in self.OPTION_LIST:
			flagList = " ".join(flagList)
			flagList = flagList.replace('{', '').replace('}', '')
			additionalObject = None  # Additional object to disable in secure mode.
			if isinstance(defaultValue, bool):
				checkBox = wx.CheckBox(self, label="{label}:\n{flags}".format(label=label, flags=flagList))
				checkBox.SetValue(defaultValue)
				sHelper.addItem(checkBox)
				self.options.append(checkBox)
			elif isinstance(defaultValue, LogLevelStr):
				logLevelChoices = ['{level} ({name})'.format(name=name, level=level) for level, name in gui.settingsDialogs.GeneralSettingsPanel.LOG_LEVELS]
				logLevelChoices.insert(0, '')
				logLevelList = sHelper.addLabeledControl("{label}:\n{flags}".format(label=label, flags=flagList), wx.Choice, choices=logLevelChoices)
				logLevelList.SetSelection(0)
				self.options.append(logLevelList)
			elif isinstance(defaultValue, LangStr):
				self.languages = languageHandler.getAvailableLanguages(presentational=True)
				langChoices = ['{code} - {lng}'.format(code=c, lng=l) for (c, l) in self.languages]
				langChoices.insert(0, '')
				langList = sHelper.addLabeledControl("{label}:\n{flags}".format(label=label, flags=flagList), wx.Choice, choices=langChoices)
				langList.SetSelection(0)
				self.options.append(langList)
			elif isinstance(defaultValue, str):
				groupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label="{label}:   {flags}".format(label=label, flags=flagList))
				groupBox = groupSizer.GetStaticBox()
				groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=groupSizer))
				# Translators: The label of a button to browse for a directory or a file.
				browseText = _("Browse...")
				if isinstance(defaultValue, FolderStr):
					# Translators: The title of the dialog presented when browsing for the directory.
					dirDialogTitle = _("Select a directory")
					directoryPathHelper = gui.guiHelper.PathSelectionHelper(groupBox, browseText, dirDialogTitle)
					directoryEntryControl = groupHelper.addItem(directoryPathHelper)
					directoryEdit = directoryEntryControl.pathControl
					directoryEdit.Value = defaultValue
					self.options.append(directoryEdit)		
					additionalObject = directoryEntryControl._browseButton
				elif isinstance(defaultValue, FileStr):
					# Translators: the label for the NVDA log extension (log) file type
					wildcard = (_("NVDA log file (*.{ext})")+"|*.{ext}").format(ext="log")
					# Translators: The title of the dialog presented when browsing for the file.
					fileDialogTitle = _("Select a file")
					filePathHelper = FileSelectionHelper(groupBox, browseText, wildcard, fileDialogTitle)
					shouldAddSpacer = groupHelper.hasFirstItemBeenAdded
					if shouldAddSpacer:
						groupHelper.sizer.AddSpacer(SPACE_BETWEEN_VERTICAL_DIALOG_ITEMS)
					groupHelper.sizer.Add(filePathHelper.sizer, flag=wx.EXPAND)
					groupHelper.hasFirstItemBeenAdded = True
					fileEntryControl = filePathHelper
					
					fileEdit = fileEntryControl.pathControl
					fileEdit.Value = defaultValue
					self.options.append(fileEdit)		
					additionalObject = fileEntryControl._browseButton
				else:
					raise			
			else:
				raise Exception('Unknown option type')
			if globalVars.appArgs.secure and not allowInSecureMode:
				self.options[-1].Disable()
				if additionalObject:
					additionalObject.Disable()
コード例 #18
0
ファイル: configuration.py プロジェクト: zywek123/TWBlue
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     sizer = wx.BoxSizer(wx.VERTICAL)
     language = wx.StaticText(self, -1, _(u"Language"))
     self.langs = languageHandler.getAvailableLanguages()
     langs = []
     [langs.append(i[1]) for i in self.langs]
     self.codes = []
     [self.codes.append(i[0]) for i in self.langs]
     self.language = wx.ListBox(self, -1, choices=langs)
     id = self.codes.index(config.main["general"]["language"])
     self.language.SetSelection(id)
     self.language.SetSize(self.language.GetBestSize())
     langBox = wx.BoxSizer(wx.HORIZONTAL)
     langBox.Add(language, 0, wx.ALL, 5)
     langBox.Add(self.language, 0, wx.ALL, 5)
     sizer.Add(langBox, 0, wx.ALL, 5)
     self.au = wx.Button(self, -1, _(u"Set the autocomplete function"))
     self.ask_at_exit = wx.CheckBox(self, -1,
                                    _(U"ask before exiting TwBlue?"))
     self.ask_at_exit.SetValue(config.main["general"]["ask_at_exit"])
     sizer.Add(self.ask_at_exit, 0, wx.ALL, 5)
     self.use_invisible_shorcuts = wx.CheckBox(
         self, -1,
         _(u"Use invisible interface's keyboard shorcuts on the GUI"))
     self.use_invisible_shorcuts.SetValue(
         config.main["general"]["use_invisible_keyboard_shorcuts"])
     sizer.Add(self.use_invisible_shorcuts, 0, wx.ALL, 5)
     self.relative_time = wx.CheckBox(self, -1, _(U"Relative times"))
     self.relative_time.SetValue(config.main["general"]["relative_times"])
     sizer.Add(self.relative_time, 0, wx.ALL, 5)
     if platform.system() == "Windows":
         self.disable_sapi5 = wx.CheckBox(
             self, -1,
             _(u"Activate Sapi5 when any other screen reader is not being run"
               ))
         self.disable_sapi5.SetValue(
             config.main["general"]["voice_enabled"])
         sizer.Add(self.disable_sapi5, 0, wx.ALL, 5)
         self.show_gui = wx.CheckBox(
             self, -1,
             _(u"Activate the auto-start of the invisible interface"))
         self.show_gui.SetValue(config.main["general"]["hide_gui"])
         sizer.Add(self.show_gui, 0, wx.ALL, 5)
     apiCallsBox = wx.BoxSizer(wx.HORIZONTAL)
     apiCallsBox.Add(
         wx.StaticText(
             self, -1,
             _(u"API calls when the stream is started (One API call equals to 200 tweetts, two API calls equals 400 tweets, etc):"
               )), 0, wx.ALL, 5)
     self.apiCalls = wx.SpinCtrl(self, -1)
     self.apiCalls.SetRange(1, 10)
     self.apiCalls.SetValue(config.main["general"]["max_api_calls"])
     self.apiCalls.SetSize(self.apiCalls.GetBestSize())
     apiCallsBox.Add(self.apiCalls, 0, wx.ALL, 5)
     sizer.Add(apiCallsBox, 0, wx.ALL, 5)
     tweetsPerCallBox = wx.BoxSizer(wx.HORIZONTAL)
     tweetsPerCallBox.Add(
         wx.StaticText(self, -1, _(u"Items on each API call")), 0, wx.ALL,
         5)
     self.itemsPerApiCall = wx.SpinCtrl(self, -1)
     self.itemsPerApiCall.SetRange(0, 200)
     self.itemsPerApiCall.SetValue(
         config.main["general"]["max_tweets_per_call"])
     self.itemsPerApiCall.SetSize(self.itemsPerApiCall.GetBestSize())
     tweetsPerCallBox.Add(self.itemsPerApiCall, 0, wx.ALL, 5)
     sizer.Add(tweetsPerCallBox, 0, wx.ALL, 5)
     self.reverse_timelines = wx.CheckBox(
         self, -1,
         _(u"Inverted buffers: The newest tweets will be shown at the beginning of the lists while the oldest at the end"
           ))
     self.reverse_timelines.SetValue(
         config.main["general"]["reverse_timelines"])
     sizer.Add(self.reverse_timelines, 0, wx.ALL, 5)
     self.SetSizer(sizer)
コード例 #19
0
def generateUnsupportedWindowsLocales():
    """Generates list of languages which are not supported under the current version of Windows.
	Uses `localesData.LANG_NAMES_TO_LOCALIZED_DESCS` as a base but filters further
	since unsupported languages are different under different systems."""
    unsupportedLangs = set()
    for localeName in LANG_NAMES_TO_LOCALIZED_DESCS.keys():
        # `languageHandler.englishCountryNameFromNVDALocale` returns `None` for locale unknown to Windows.
        if not languageHandler.englishCountryNameFromNVDALocale(localeName):
            unsupportedLangs.add(localeName)
    return unsupportedLangs


LCID_ENGLISH_US = 0x0409
UNSUPPORTED_WIN_LANGUAGES = generateUnsupportedWindowsLocales()
TRANSLATABLE_LANGS = set(
    l[0] for l in languageHandler.getAvailableLanguages()) - {"Windows"}
WINDOWS_LANGS = set(locale.windows_locale.values()).union(
    windowsPrimaryLCIDsToLocaleNames.values())


class TestLocaleNameToWindowsLCID(unittest.TestCase):
    def test_knownLocale(self):
        lcid = languageHandler.localeNameToWindowsLCID("en")
        self.assertEqual(lcid, LCID_ENGLISH_US)

    def test_windowsUnknownLocale(self):
        # "an" is the locale name for Aragonese, but Windows doesn't know about it.
        lcid = languageHandler.localeNameToWindowsLCID("an")
        self.assertEqual(lcid, LCID_NONE)

    def test_nonStandardLocale(self):