@@ -2017,13 +2017,13 @@ def OnCancel(self, evt):
2017
2017
#2014-10-14
2018
2018
class MyNoteBook (wx .Frame ):
2019
2019
''' Settings Notebook '''
2020
- def __init__ (self , settings , statusbar ):
2021
- wx .Frame .__init__ (self , wx . GetApp (). TopWindow , wx .ID_ANY , _ ("Abc settings" ), style = wx .DEFAULT_FRAME_STYLE , name = 'settingsbook' )
2020
+ def __init__ (self , parent , settings , statusbar ):
2021
+ wx .Frame .__init__ (self , parent , wx .ID_ANY , _ ("Abc settings" ), style = wx .DEFAULT_FRAME_STYLE , name = 'settingsbook' )
2022
2022
# Add a panel so it looks the correct on all platforms
2023
2023
p = wx .Panel (self )
2024
2024
nb = wx .Notebook (p )
2025
2025
# 1.3.6.4 [SS] 2015-05-26 added statusbar
2026
- abcsettings = AbcFileSettingsFrame (nb , settings , statusbar )
2026
+ abcsettings = AbcFileSettingsFrame (nb , settings , statusbar , parent . mc )
2027
2027
chordpage = MyChordPlayPage (nb , settings )
2028
2028
self .voicepage = MyVoicePage (nb , settings )
2029
2029
# 1.3.6.1 [SS] 2015-02-02
@@ -2052,26 +2052,27 @@ def OnPageChanged(self, event):
2052
2052
2053
2053
class AbcFileSettingsFrame (wx .Panel ):
2054
2054
# 1.3.6.4 [SS] 2015-05-26 added statusbar
2055
- def __init__ (self , parent , settings , statusbar ):
2055
+ def __init__ (self , parent , settings , statusbar , mc ):
2056
2056
wx .Panel .__init__ (self , parent )
2057
2057
self .settings = settings
2058
2058
self .statusbar = statusbar
2059
+ self .mc = mc
2059
2060
self .SetBackgroundColour (dialog_background_colour )
2060
2061
border = control_margin
2061
2062
2062
- PathEntry = namedtuple ('PathEntry' , 'name display_name tooltip add_default wildcard' )
2063
+ PathEntry = namedtuple ('PathEntry' , 'name display_name tooltip add_default wildcard on_change ' )
2063
2064
2064
2065
# 1.3.6.3 [JWDJ] 2015-04-27 replaced TextCtrl with ComboBox for easier switching of versions
2065
2066
self .needed_path_entries = [
2066
- PathEntry ('abcm2ps' , _ ('abcm2ps executable:' ), _ ('This executable is used to display the music' ), True , None ),
2067
- PathEntry ('abc2midi' , _ ('abc2midi executable:' ), _ ('This executable is used to make the midi file' ), True , None ),
2068
- PathEntry ('abc2abc' , _ ('abc2abc executable:' ), _ ('This executable is used to transpose the music' ), True , None ),
2067
+ PathEntry ('abcm2ps' , _ ('abcm2ps executable:' ), _ ('This executable is used to display the music' ), True , None , None ),
2068
+ PathEntry ('abc2midi' , _ ('abc2midi executable:' ), _ ('This executable is used to make the midi file' ), True , None , None ),
2069
+ PathEntry ('abc2abc' , _ ('abc2abc executable:' ), _ ('This executable is used to transpose the music' ), True , None , None ),
2069
2070
# 1.3.6.4 [SS] 2015-06-22
2070
- PathEntry ('midi2abc' , _ ('midi2abc executable:' ), _ ('This executable is used to disassemble the output midi file' ), True , None ),
2071
- PathEntry ('gs' , _ ('ghostscript executable:' ), _ ('This executable is used to create PDF files' ), False , None ),
2072
- PathEntry ('nwc2xml' , _ ('nwc2xml executable:' ), _ ('For NoteWorthy Composer - Windows only' ), False , None ),
2073
- PathEntry ('midiplayer' , _ ('midiplayer:' ), _ ('Your preferred MIDI player' ), False , None ),
2074
- PathEntry ('soundfont' , _ ('SoundFont:' ), _ ('Your preferred SoundFont (.sf2)' ), False , 'SoundFont (*.sf2;*.sf3)|*.sf2;*.sf3' )
2071
+ PathEntry ('midi2abc' , _ ('midi2abc executable:' ), _ ('This executable is used to disassemble the output midi file' ), True , None , None ),
2072
+ PathEntry ('gs' , _ ('ghostscript executable:' ), _ ('This executable is used to create PDF files' ), False , None , None ),
2073
+ PathEntry ('nwc2xml' , _ ('nwc2xml executable:' ), _ ('For NoteWorthy Composer - Windows only' ), False , None , None ),
2074
+ PathEntry ('midiplayer' , _ ('midiplayer:' ), _ ('Your preferred MIDI player' ), False , None , self . midiplayer_changed ),
2075
+ PathEntry ('soundfont' , _ ('SoundFont:' ), _ ('Your preferred SoundFont (.sf2)' ), False , 'SoundFont (*.sf2;*.sf3)|*.sf2;*.sf3' , self . soundfont_changed )
2075
2076
]
2076
2077
2077
2078
@@ -2098,9 +2099,11 @@ def __init__(self, parent, settings, statusbar):
2098
2099
self .browsebutton_to_control = {}
2099
2100
self .browsebutton_to_wildcard = {}
2100
2101
self .control_to_name = {}
2102
+ self .afterchanged = {}
2101
2103
for entry in self .needed_path_entries :
2102
2104
setting_name = '%s_path' % entry .name
2103
2105
current_path = self .settings .get (setting_name , '' )
2106
+ self .afterchanged [setting_name ] = entry .on_change
2104
2107
setting_name_choices = '%s_path_choices' % entry .name
2105
2108
path_choices = self .settings .get (setting_name_choices , '' ).split ('|' )
2106
2109
path_choices = self .keep_existing_paths (path_choices )
@@ -2201,9 +2204,21 @@ def change_path_for_control(self, control, path):
2201
2204
self .settings [setting_name_choices ] = '|' .join (paths )
2202
2205
# 1.3.6.4 [SS] 2015-05-26
2203
2206
self .statusbar .SetStatusText (setting_name + ' was updated to ' + path )
2204
- if setting_name == 'midiplayer_path' :
2205
- app = wx .GetApp ()
2206
- app .frame .update_play_button () # 1.3.6.3 [JWDJ] 2015-04-21 playbutton enabling centralized
2207
+ on_changed = self .afterchanged .get (setting_name )
2208
+ if on_changed is not None :
2209
+ on_changed (path )
2210
+
2211
+ def midiplayer_changed (self , path ):
2212
+ app = wx .GetApp ()
2213
+ app .frame .update_play_button () # 1.3.6.3 [JWDJ] 2015-04-21 playbutton enabling centralized
2214
+
2215
+ def soundfont_changed (self , sf2_path ):
2216
+ try :
2217
+ wait = wx .BusyCursor ()
2218
+ self .mc .set_soundfont (sf2_path ) # load another sound font
2219
+ del wait
2220
+ except :
2221
+ pass
2207
2222
2208
2223
def On_Chk_IncludeHeader (self , event ):
2209
2224
self .settings ['abc_include_file_header' ] = self .chkIncludeHeader .GetValue ()
@@ -2229,7 +2244,7 @@ def OnRestoreSettings(self, event):
2229
2244
frame .restore_settings ()
2230
2245
frame .settingsbook .Show (False )
2231
2246
frame .settingsbook .Destroy ()
2232
- frame .settingsbook = MyNoteBook (self .settings , self .statusbar )
2247
+ frame .settingsbook = MyNoteBook (self , self .settings , self .statusbar )
2233
2248
frame .settingsbook .Show ()
2234
2249
2235
2250
def append_exe (self , path , paths ):
@@ -6329,7 +6344,7 @@ def OnAbcSettings(self, evt):
6329
6344
# 1.3.6.4 [SS] 2015-07-07
6330
6345
win = wx .FindWindowByName ('settingsbook' )
6331
6346
if win is None :
6332
- self .settingsbook = MyNoteBook (self .settings , self .statusbar )
6347
+ self .settingsbook = MyNoteBook (self , self .settings , self .statusbar )
6333
6348
self .settingsbook .Show ()
6334
6349
else :
6335
6350
self .settingsbook .Iconize (False )
0 commit comments