11
11
import addonHandler
12
12
from logHandler import log # logging
13
13
from typing import List , Dict , Union , Callable
14
- from .MathCAT import ConvertSSMLTextForNVDA
14
+ from .MathCAT import convertSSMLTextForNVDA
15
15
from speech import speak
16
16
from zipfile import ZipFile
17
17
@@ -72,8 +72,8 @@ def __init__(self, parent):
72
72
self ._listBoxPreferencesTopic .SetSelection (0 )
73
73
userPreferences ["NVDAAddOn" ] = {"LastCategory" : "0" }
74
74
# populate the languages and braille codes
75
- UserInterface .GetLanguages (self )
76
- UserInterface .GetBrailleCodes (self )
75
+ UserInterface .getLanguages (self )
76
+ UserInterface .getBrailleCodes (self )
77
77
# set the ui items to match the preferences
78
78
UserInterface .setUIValues (self )
79
79
@@ -88,7 +88,7 @@ def pathToBrailleFolder():
88
88
return os .path .join (os .path .dirname (os .path .abspath (__file__ )), "Rules" , "Braille" )
89
89
90
90
@staticmethod
91
- def LanguagesDict () -> Dict [str , str ]:
91
+ def languagesDict () -> Dict [str , str ]:
92
92
languages = {
93
93
"aa" : "Afar" ,
94
94
"ab" : "Аҧсуа" ,
@@ -291,13 +291,13 @@ def getRulesFiles(
291
291
292
292
return ruleFiles
293
293
294
- def GetLanguages (self ):
294
+ def getLanguages (self ):
295
295
def addRegionalLanguages (subDir : str , language : str ) -> List [str ]:
296
296
# the language variants are in folders named using ISO 3166-1 alpha-2
297
297
# codes https://en.wikipedia.org/wiki/ISO_3166-2
298
298
# check if there are language variants in the language folder
299
299
if subDir != "SharedRules" :
300
- languagesDict = UserInterface .LanguagesDict ()
300
+ languagesDict = UserInterface .languagesDict ()
301
301
# add to the listbox the text for this language variant together with the code
302
302
regionalCode = language + "-" + subDir .upper ()
303
303
if languagesDict .get (regionalCode , "missing" ) != "missing" :
@@ -310,7 +310,7 @@ def addRegionalLanguages(subDir: str, language: str) -> List[str]:
310
310
return []
311
311
312
312
# initialise the language list
313
- languagesDict = UserInterface .LanguagesDict ()
313
+ languagesDict = UserInterface .languagesDict ()
314
314
# clear the language names in the dialog
315
315
self ._choiceLanguage .Clear ()
316
316
# Translators: menu item -- use the language of the voice chosen in the NVDA speech settings dialog
@@ -331,12 +331,12 @@ def addRegionalLanguages(subDir: str, language: str) -> List[str]:
331
331
else :
332
332
self ._choiceLanguage .Append (language + " (" + language + ")" )
333
333
334
- def GetLanguageCode (self ):
334
+ def getLanguageCode (self ):
335
335
lang_selection = self ._choiceLanguage .GetStringSelection ()
336
336
lang_code = lang_selection [lang_selection .find ("(" ) + 1 : lang_selection .find (")" )]
337
337
return lang_code
338
338
339
- def GetSpeechStyles (self , thisSpeechStyle : str ):
339
+ def getSpeechStyles (self , thisSpeechStyle : str ):
340
340
"""Get all the speech styles for the current language.
341
341
This sets the SpeechStyles dialog entry"""
342
342
from speech import getCurrentLanguage
@@ -370,7 +370,7 @@ def getSpeechStyleFromDirectory(dir: str, lang: str) -> list[str]:
370
370
# clear the SpeechStyle choices
371
371
self ._choiceSpeechStyle .Clear ()
372
372
# get the currently selected language code
373
- languageCode = UserInterface .GetLanguageCode (self )
373
+ languageCode = UserInterface .getLanguageCode (self )
374
374
375
375
if languageCode == "Auto" :
376
376
# list the speech styles for the current voice rather than have none listed
@@ -402,7 +402,7 @@ def getSpeechStyleFromDirectory(dir: str, lang: str) -> list[str]:
402
402
# that didn't work, choose the first in the list
403
403
self ._choiceSpeechStyle .SetSelection (0 )
404
404
405
- def GetBrailleCodes (self ):
405
+ def getBrailleCodes (self ):
406
406
# initialise the braille code list
407
407
self ._choiceBrailleMathCode .Clear ()
408
408
# populate the available braille codes in the dialog
@@ -438,7 +438,7 @@ def setUIValues(self):
438
438
self ._choiceLanguage .SetSelection (0 )
439
439
try :
440
440
# now get the available SpeechStyles from the folder structure and set to the preference setting is possible
441
- self .GetSpeechStyles (str (userPreferences ["Speech" ]["SpeechStyle" ]))
441
+ self .getSpeechStyles (str (userPreferences ["Speech" ]["SpeechStyle" ]))
442
442
except Exception as e :
443
443
log .exception (f"MathCAT: An exception occurred in set_ui_values (getting SpeechStyle): { e } " )
444
444
self ._choiceSpeechStyle .Append (
@@ -511,7 +511,7 @@ def getUIValues(self):
511
511
global userPreferences
512
512
# read the values from the UI and update the user preferences dictionary
513
513
userPreferences ["Speech" ]["Impairment" ] = Speech_Impairment [self ._choiceImpairment .GetSelection ()]
514
- userPreferences ["Speech" ]["Language" ] = self .GetLanguageCode ()
514
+ userPreferences ["Speech" ]["Language" ] = self .getLanguageCode ()
515
515
userPreferences ["Other" ]["DecimalSeparator" ] = Speech_DecimalSeparator [
516
516
self ._choiceDecimalSeparator .GetSelection ()
517
517
]
@@ -695,17 +695,17 @@ def writeUserPreferences():
695
695
# write values to the user preferences file, NOT the default
696
696
yaml .dump (userPreferences , stream = f , allow_unicode = True )
697
697
698
- def OnRelativeSpeedChanged (self , event ):
698
+ def onRelativeSpeedChanged (self , event ):
699
699
rate = self ._sliderRelativeSpeed .GetValue ()
700
700
# Translators: this is a test string that is spoken. Only translate "the square root of x squared plus y squared"
701
701
text = _ ("<prosody rate='XXX%'>the square root of x squared plus y squared</prosody>" ).replace (
702
702
"XXX" ,
703
703
str (rate ),
704
704
1 ,
705
705
)
706
- speak (ConvertSSMLTextForNVDA (text ))
706
+ speak (convertSSMLTextForNVDA (text ))
707
707
708
- def OnPauseFactorChanged (self , event ):
708
+ def onPauseFactorChanged (self , event ):
709
709
rate = self ._sliderRelativeSpeed .GetValue ()
710
710
pfSlider = self ._sliderPauseFactor .GetValue ()
711
711
pauseFactor = (
@@ -730,44 +730,44 @@ def OnPauseFactorChanged(self, event):
730
730
pause_factor_300 = 300 * pauseFactor // 100 ,
731
731
pause_factor_600 = 600 * pauseFactor // 100 ,
732
732
)
733
- speak (ConvertSSMLTextForNVDA (text ))
733
+ speak (convertSSMLTextForNVDA (text ))
734
734
735
- def OnClickOK (self , event ):
735
+ def onClickOK (self , event ):
736
736
UserInterface .getUIValues (self )
737
737
UserInterface .writeUserPreferences ()
738
738
self .Destroy ()
739
739
740
- def OnClickCancel (self , event ):
740
+ def onClickCancel (self , event ):
741
741
self .Destroy ()
742
742
743
- def OnClickApply (self , event ):
743
+ def onClickApply (self , event ):
744
744
UserInterface .getUIValues (self )
745
745
UserInterface .writeUserPreferences ()
746
746
747
- def OnClickReset (self , event ):
747
+ def onClickReset (self , event ):
748
748
UserInterface .loadDefaultPreferences ()
749
749
UserInterface .validateUserPreferences ()
750
750
UserInterface .setUIValues (self )
751
751
752
- def OnClickHelp (self , event ):
752
+ def onClickHelp (self , event ):
753
753
webbrowser .open ("https://nsoiffer.github.io/MathCAT/users.html" )
754
754
755
- def OnListBoxCategories (self , event ):
755
+ def onListBoxCategories (self , event ):
756
756
# the category changed, now show the appropriate dialogue page
757
757
self ._simplebookPanelsCategories .SetSelection (self ._listBoxPreferencesTopic .GetSelection ())
758
758
759
- def OnLanguage (self , event ):
759
+ def onLanguage (self , event ):
760
760
# the language changed, get the SpeechStyles for the new language
761
- UserInterface .GetSpeechStyles (self , self ._choiceSpeechStyle .GetStringSelection ())
761
+ UserInterface .getSpeechStyles (self , self ._choiceSpeechStyle .GetStringSelection ())
762
762
763
- def MathCATPreferencesDialogOnCharHook (self , event : wx .KeyEvent ):
763
+ def mathCATPreferencesDialogOnCharHook (self , event : wx .KeyEvent ):
764
764
# designed choice is that Enter is the same as clicking OK, and Escape is the same as clicking Cancel
765
765
keyCode = event .GetKeyCode ()
766
766
if keyCode == wx .WXK_ESCAPE :
767
- UserInterface .OnClickCancel (self , event )
767
+ UserInterface .onClickCancel (self , event )
768
768
return
769
769
if keyCode == wx .WXK_RETURN :
770
- UserInterface .OnClickOK (self , event )
770
+ UserInterface .onClickOK (self , event )
771
771
if keyCode == wx .WXK_TAB :
772
772
if event .GetModifiers () == wx .MOD_CONTROL :
773
773
# cycle the category forward
@@ -776,7 +776,7 @@ def MathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
776
776
newCategory = 0
777
777
self ._listBoxPreferencesTopic .SetSelection (newCategory )
778
778
# update the ui to show the new page
779
- UserInterface .OnListBoxCategories (self , event )
779
+ UserInterface .onListBoxCategories (self , event )
780
780
# set the focus into the category list box
781
781
self ._listBoxPreferencesTopic .SetFocus ()
782
782
# jump out so the tab key is not processed
@@ -788,7 +788,7 @@ def MathCATPreferencesDialogOnCharHook(self, event: wx.KeyEvent):
788
788
newCategory = 2
789
789
self ._listBoxPreferencesTopic .SetSelection (newCategory )
790
790
# update the ui to show the new page
791
- UserInterface .OnListBoxCategories (self , event )
791
+ UserInterface .onListBoxCategories (self , event )
792
792
# update the ui to show the new page
793
793
self ._listBoxPreferencesTopic .SetFocus ()
794
794
# jump out so the tab key is not processed
0 commit comments