@@ -56,17 +56,17 @@ def load_user_preferences():
5656 global user_preferences
5757 #merge user file values into the user preferences data structure
5858 if os .path .exists (path_to_user_preferences ()):
59- with open (path_to_user_preferences ()) as f :
59+ with open (path_to_user_preferences (), encoding = 'utf-8' ) as f :
6060 # merge with the default preferences, overwriting with the user's values
6161 user_preferences |= yaml .load (f , Loader = yaml .FullLoader )
6262
6363def write_user_preferences ():
6464 if not os .path .exists (path_to_user_preferences_folder ()):
6565 #create a folder for the user preferences
6666 os .mkdir (path_to_user_preferences_folder ())
67- with open (path_to_user_preferences (), 'w' ) as f :
67+ with open (path_to_user_preferences (), 'w' , encoding = "utf-8" ) as f :
6868 #write values to the user preferences file, NOT the default
69- yaml .dump (user_preferences , f )
69+ yaml .dump (user_preferences , stream = f , allow_unicode = True )
7070
7171class UserInterface (MathCATgui .MathCATPreferencesDialog ):
7272 def GetLanguages (self ):
@@ -106,6 +106,7 @@ def set_ui_values(self):
106106 #now get the available SpeechStyles from the folder structure and set to the preference setting is possible
107107 UserInterface .GetSpeechStyles (self , user_preferences ["Speech" ]["SpeechStyle" ])
108108 self .m_choiceSpeechAmount .SetSelection (Speech_Verbosity .index (user_preferences ["Speech" ]["Verbosity" ]))
109+ self .m_sliderRelativeSpeed .SetValue (user_preferences ["Speech" ]["MathRate" ])
109110 self .m_choiceSpeechForChemical .SetSelection (Speech_Chemistry .index (user_preferences ["Speech" ]["Chemistry" ]))
110111 self .m_choiceNavigationMode .SetSelection (Navigation_NavMode .index (user_preferences ["Navigation" ]["NavMode" ]))
111112 self .m_checkBoxResetNavigationMode .SetValue (user_preferences ["Navigation" ]["ResetNavMode" ])
@@ -128,6 +129,7 @@ def get_ui_values(self):
128129 user_preferences ["Speech" ]["Language" ] = self .m_choiceLanguage .GetStringSelection ()
129130 user_preferences ["Speech" ]["SpeechStyle" ] = self .m_choiceSpeechStyle .GetStringSelection ()
130131 user_preferences ["Speech" ]["Verbosity" ] = Speech_Verbosity [self .m_choiceSpeechAmount .GetSelection ()]
132+ user_preferences ["Speech" ]["MathRate" ] = self .m_sliderRelativeSpeed .GetValue ()
131133 user_preferences ["Speech" ]["Chemistry" ] = Speech_Chemistry [self .m_choiceSpeechForChemical .GetSelection ()]
132134 user_preferences ["Navigation" ]["NavMode" ] = Navigation_NavMode [self .m_choiceNavigationMode .GetSelection ()]
133135 user_preferences ["Navigation" ]["ResetNavMode" ] = self .m_checkBoxResetNavigationMode .GetValue ()
@@ -193,8 +195,30 @@ def MathCATPreferencesDialogOnCharHook(self,event):
193195 UserInterface .OnClickCancel (self ,event )
194196 if keyCode == wx .WXK_RETURN :
195197 UserInterface .OnClickOK (self ,event )
196- #if keyCode == wx.WXK_TAB and wx.KeyboardState.GetModifiers():
197- # print("Tab")
198+ if keyCode == wx .WXK_TAB and (event .GetModifiers () == wx .MOD_CONTROL ):
199+ #cycle the category forward
200+ new_category = self .m_listBoxPreferencesTopic .GetSelection () + 1
201+ if new_category == 3 :
202+ new_category = 0
203+ self .m_listBoxPreferencesTopic .SetSelection (new_category )
204+ #update the ui to show the new page
205+ UserInterface .OnListBoxCategories (self ,event )
206+ #set the focus into the category list box
207+ self .m_listBoxPreferencesTopic .SetFocus ()
208+ #jump out so the tab key is not processed
209+ return
210+ if keyCode == wx .WXK_TAB and (event .GetModifiers () == wx .MOD_CONTROL | wx .MOD_SHIFT ):
211+ #cycle the category back
212+ new_category = self .m_listBoxPreferencesTopic .GetSelection () - 1
213+ if new_category == - 1 :
214+ new_category = 2
215+ self .m_listBoxPreferencesTopic .SetSelection (new_category )
216+ #update the ui to show the new page
217+ UserInterface .OnListBoxCategories (self ,event )
218+ #update the ui to show the new page
219+ self .m_listBoxPreferencesTopic .SetFocus ()
220+ #jump out so the tab key is not processed
221+ return
198222 event .Skip ()
199223
200224app = wx .App (False )
0 commit comments