本文整理汇总了Python中solfege.cfg.get_string函数的典型用法代码示例。如果您正苦于以下问题:Python get_string函数的具体用法?Python get_string怎么用?Python get_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: play_mediafile
def play_mediafile(typeid, filename):
global _mediaplayer
if sys.platform == 'win32' and typeid == 'wav':
winsound.PlaySound(filename, winsound.SND_FILENAME | winsound.SND_ASYNC)
else:
args = [cfg.get_string("sound/%s_player" % typeid)]
# We only add %s_player_options if is is a non empty string,
# since args should not contain any empty strings.
if cfg.get_string("sound/%s_player_options"% typeid):
args.extend(
cfg.get_string("sound/%s_player_options"% typeid).split(" "))
found = False
for i, s in enumerate(args):
if '%s' in s:
args[i] = args[i] % os.path.abspath(filename)
found = True
if not found:
args.append(os.path.abspath(filename))
if _mediaplayer and _mediaplayer.poll() == None:
_mediaplayer.kill()
_mediaplaer = None
try:
if sys.platform == 'win32':
info = subprocess.STARTUPINFO()
info.dwFlags = 1
info.wShowWindow = 0
_mediaplayer = osutils.Popen(args=args, startupinfo=info)
else:
_mediaplayer = osutils.Popen(args=args)
except OSError, e:
raise osutils.BinaryForMediaPlayerException(typeid,
cfg.get_string("sound/%s_player" % typeid), e)
开发者ID:gabrielelanaro,项目名称:solfege,代码行数:32,代码来源:__init__.py
示例2: start_gui
def start_gui(datadir):
if not options.profile:
if cfg.get_bool("app/noprofilemanager"):
options.profile = cfg.get_string("app/last_profile")
elif do_profiles():
if solfege.splash_win:
solfege.splash_win.hide()
p = ProfileManager(cfg.get_string("app/last_profile"))
ret = p.run()
if ret == Gtk.ResponseType.ACCEPT:
options.profile = p.get_profile()
cfg.set_string("app/last_profile", "" if not options.profile else options.profile)
elif ret in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT):
Gtk.main_quit()
return
p.destroy()
if solfege.splash_win:
solfege.splash_win.show()
cfg.set_bool('config/no_random', bool(options.no_random))
lessonfile.infocache = lessonfile.InfoCache()
def f(s):
if solfege.splash_win:
solfege.splash_win.show_progress(s)
if solfege.splash_win:
solfege.splash_win.show_progress(_("Opening statistics database"))
try:
solfege.db = statistics.DB(f, profile=options.profile)
except sqlite3.OperationalError, e:
solfege.splash_win.hide()
gu.dialog_ok(_(u"Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once."))
sys.exit()
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:34,代码来源:startup.py
示例3: setup_sound
def setup_sound(self):
if sys.platform == 'win32' and \
cfg.get_string("sound/type") == "sequencer-device":
# just in case c:\home\.solfegerc is wrong
cfg.set_string("sound/type", "winsynth")
if self.m_options.no_sound \
or cfg.get_string("sound/type") == "fake-synth":
soundcard.initialise_using_fake_synth(self.m_options.verbose_sound_init)
elif cfg.get_string("sound/type") == "alsa-sequencer":
if alsaseq:
try:
clientid, portid = self.get_list("sound/alsa-client-port")
except ValueError:
clientid, portid = (None, None)
try:
soundcard.initialise_alsa_sequencer((clientid, portid),
self.m_options.verbose_sound_init)
except alsaseq.SequencerError, e:
logging.debug("initialise_alsa_sequencer failed. Using fake synth.")
self.display_sound_init_error_message(e)
soundcard.initialise_using_fake_synth(True)
return
else:
if solfege.splash_win:
solfege.splash_win.hide()
gu.dialog_ok(_("The pyalsa Python module is missing"),
solfege.win,
_("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."))
soundcard.initialise_using_fake_synth(True)
if solfege.splash_win:
solfege.splash_win.show()
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:31,代码来源:application.py
示例4: on_edit_file
def on_edit_file(self, menuitem, linked):
try:
try:
subprocess.call((cfg.get_string("programs/text-editor"),
lessonfile.uri_expand(self.m_model[linked])))
except OSError, e:
raise osutils.BinaryForProgramException("Text editor", cfg.get_string("programs/text-editor"), e)
except osutils.BinaryForProgramException, e:
solfege.win.display_error_message2(e.msg1, e.msg2)
开发者ID:gabrielelanaro,项目名称:solfege,代码行数:9,代码来源:fpeditor.py
示例5: create_interval_accels_config
def create_interval_accels_config(self, parent):
it, page_vbox = self.new_page_box(parent, _("Interval keyboard accelerators"))
self.g_interval_accels = Gtk.ListStore(GObject.TYPE_STRING,
GObject.TYPE_STRING)
intervals = ['minor2', 'major2', 'minor3', 'major3',
'perfect4', 'diminished5', 'perfect5', 'minor6',
'major6', 'minor7', 'major7', 'perfect8',
'minor9', 'major9', 'minor10', 'major10']
for interval in intervals:
self.g_interval_accels.append((
mpd.Interval.new_from_int(intervals.index(interval)).get_name(),
cfg.get_string('interval_input/%s' % interval)))
self.g_intervals_treeview = Gtk.TreeView(self.g_interval_accels)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Interval"), renderer, text=0)
self.g_intervals_treeview.append_column(column)
renderer = Gtk.CellRendererAccel()
renderer.set_property('editable', True)
def acc_ff(renderer, path, accel_key, accel_mods, hw_key):
is_unique = True
for interval in intervals:
if (interval != intervals[int(path)]
and cfg.get_string('interval_input/%s' % interval) == unichr(accel_key)):
is_unique = False
break
if not is_unique:
gu.dialog_ok(_(u"The accelerator in use for “%s”. You have to choose another key.") % mpd.Interval.new_from_int(intervals.index(interval)).get_name(), parent=self, msgtype=Gtk.MessageType.ERROR)
return
it = self.g_interval_accels.get_iter(path)
cfg.set_string('interval_input/%s' % intervals[int(path)], unichr(accel_key))
self.g_interval_accels.set(it, 1, unichr(accel_key))
return True
renderer.connect('accel-edited', acc_ff)
column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1)
self.g_intervals_treeview.append_column(column)
page_vbox.pack_start(self.g_intervals_treeview, True, True, 0)
hbox = Gtk.HBox()
page_vbox.pack_start(hbox, False, False, 0)
layouts = {'ascii': (_('ASCII'), u'1qaz2wsx3edc4rfv'),
'dvorak': (_('Dvorak'), u"1'a;2,oq3.ej4puk"),
}
def set_buttons(widget, layout):
v = layouts[layout][1]
idx = 0
it = self.g_interval_accels.get_iter_first()
while True:
self.g_interval_accels.set_value(it, 1, v[idx])
cfg.set_string('interval_input/%s' % intervals[idx], v[idx])
it = self.g_interval_accels.iter_next(it)
idx += 1
if not it:
break
for key in layouts:
btn = Gtk.Button(layouts[key][0])
btn.connect('clicked', set_buttons, key)
hbox.pack_start(btn, True, True, 0)
开发者ID:RannyeriDev,项目名称:Solfege,代码行数:60,代码来源:configwindow.py
示例6: __init__
def __init__(self, parent, error_text):
Gtk.Dialog.__init__(self, _("Make bug report"), parent,
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT))
self.m_error_text = error_text
self.add_button(_("_Send"), RESPONSE_SEND)
self.set_default_size(400, 400)
sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
l = Gtk.Label(_("Information about the version of GNU Solfege, your operating system and Python version, and the Python traceback (error message) will be sent to the crash database. Your email will not be published or shared, but we might contact you by email if we have further questions about your crash report."))
l.set_line_wrap(True)
l.show()
self.vbox.pack_start(l, False, False, 0)
self.g_email = Gtk.Entry()
self.vbox.pack_start(
gu.hig_label_widget(_("_Email:"), self.g_email, sizegroup),
False, False, 0)
self.g_email.set_text(cfg.get_string('user/email'))
# 140 is max in the solfege.org database
self.g_description = Gtk.Entry()
self.g_description.set_max_length(140)
self.vbox.pack_start(
gu.hig_label_widget(_("S_hort description:"), self.g_description,
sizegroup), False, False, 0)
label = Gtk.Label(label=_("_Describe how to produce the error message:"))
label.set_use_underline(True)
label.set_alignment(0.0, 0.5)
self.vbox.pack_start(label, False, False, 0)
self.g_tw = Gtk.TextView()
self.g_tw.set_wrap_mode(Gtk.WrapMode.WORD)
self.g_tw.set_border_width(10)
label.set_mnemonic_widget(self.g_tw)
self.vbox.pack_start(self.g_tw, True, True, 0)
self.show_all()
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:32,代码来源:reportbug.py
示例7: nComboBox
def nComboBox(exname, name, default, popdown_strings):
c = Gtk.ComboBoxText()
for n in popdown_strings:
c.append_text(n)
c.m_exname = exname
c.m_name = name
val = cfg.get_string("%s/%s=X" % (c.m_exname, c.m_name))
if val == 'X':
cfg.set_int("%s/%s" % (exname, name),
popdown_strings.index(default))
c.set_active(popdown_strings.index(default))
else:
try:
i = cfg.get_int("%s/%s" % (c.m_exname, c.m_name))
except ValueError:
i = 0
cfg.set_int("%s/%s" % (c.m_exname, c.m_name), 0)
if i >= len(popdown_strings):
i = 0
cfg.set_int("%s/%s" % (c.m_exname, c.m_name), 0)
c.set_active(cfg.get_int("%s/%s" % (c.m_exname, c.m_name)))
def f(combobox):
cfg.set_int("%s/%s" % (exname, name), combobox.get_active())
c.connect('changed', f)
return c
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:25,代码来源:gu.py
示例8: __init__
def __init__(self, parent, error_text):
gtk.Dialog.__init__(self, _("Make bug report"), parent,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
self.m_error_text = error_text
self.add_button(_("See complete _report"), RESPONSE_SEE)
self.add_button(_("_Send"), RESPONSE_SEND)
self.set_default_size(400, 400)
sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
self.g_email = gtk.Entry()
self.vbox.pack_start(
gu.hig_label_widget(_("_Email:"), self.g_email, sizegroup),
False)
self.g_mangled_email = gtk.Label()
self.vbox.pack_start(
gu.hig_label_widget(_("Mangled email address:"), self.g_mangled_email,
sizegroup), False)
self.g_email.set_text(cfg.get_string('user/email'))
self.g_email.connect('changed', self.on_update_mangle)
self.g_description = gtk.Entry()
self.vbox.pack_start(
gu.hig_label_widget(_("S_hort description:"), self.g_description,
sizegroup), False)
label = gtk.Label(_("_Describe how to produce the error message:"))
label.set_use_underline(True)
label.set_alignment(0.0, 0.5)
self.vbox.pack_start(label, False)
self.g_tw = gtk.TextView()
self.g_tw.set_wrap_mode(gtk.WRAP_WORD)
self.g_tw.set_border_width(10)
# translators, please notice that the word NO_DESCRIPTION must not be
# translated in this string.
self.g_tw.get_buffer().insert_at_cursor(_("""Describe as exactly as you can what you did when this error occurred. If you give no description at all, you make it very difficult to track down this bug. You should replace this text with your description, and also remove the "bug-tag" in the bottom of this text so that this bug is not automatically sorted among the bug reports with no description.\n\n(bug-tag: NO_DESCRIPTION)"""))
label.set_mnemonic_widget(self.g_tw)
self.vbox.pack_start(self.g_tw)
self.show_all()
开发者ID:gabrielelanaro,项目名称:solfege,代码行数:35,代码来源:reportbug.py
示例9: create_idtone_accels_config
def create_idtone_accels_config(self, parent):
it, page_vbox = self.new_page_box(parent, _("Identify tone keyboard accelerators"))
self.g_idtone_accels = Gtk.ListStore(GObject.TYPE_STRING,
GObject.TYPE_STRING)
notenames = ('c', 'cis', 'd', 'dis', 'e', 'f', 'fis',
'g', 'gis', 'a', 'ais', 'b')
for notename in notenames:
self.g_idtone_accels.append((
solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(),
cfg.get_string('idtone/tone_%s_ak' % notename)))
self.g_treeview = Gtk.TreeView(self.g_idtone_accels)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_("Note name"), renderer, text=0)
self.g_treeview.append_column(column)
renderer = Gtk.CellRendererAccel()
renderer.set_property('editable', True)
def acc_ff(renderer, path, accel_key, accel_mods, hw_key):
is_unique = True
for notename in notenames:
if (notename != notenames[int(path)]
and cfg.get_string('idtone/tone_%s_ak' % notename) == unichr(accel_key)):
is_unique = False
break
if not is_unique:
gu.dialog_ok(_(u"The accelerator in use for the tone “%s”. You have to choose another key.") % solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(), parent=self, msgtype=Gtk.MessageType.ERROR)
return
it = self.g_idtone_accels.get_iter(path)
cfg.set_string('idtone/tone_%s_ak' % notenames[int(path)], unichr(accel_key))
self.g_idtone_accels.set(it, 1, unichr(accel_key))
return True
renderer.connect('accel-edited', acc_ff)
column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1)
self.g_treeview.append_column(column)
page_vbox.pack_start(self.g_treeview, True, True, 0)
layouts = {'ascii': (_('ASCII'), u'awsedfujikol'),
'dvorak': (_('Dvorak'), u'a,o.eughctrn'),
}
hbox = Gtk.HBox()
page_vbox.pack_start(hbox, False, False, 0)
def set_buttons(widget, layout):
v = layouts[layout][1]
idx = 0
it = self.g_idtone_accels.get_iter_first()
while True:
self.g_idtone_accels.set_value(it, 1, v[idx])
cfg.set_string('idtone/tone_%s_ak' % notenames[idx], v[idx])
it = self.g_idtone_accels.iter_next(it)
idx += 1
if not it:
break
for key in layouts:
btn = Gtk.Button(layouts[key][0])
btn.connect('clicked', set_buttons, key)
hbox.pack_start(btn, True, True, 0)
开发者ID:RannyeriDev,项目名称:Solfege,代码行数:57,代码来源:configwindow.py
示例10: do_convert
def do_convert(from_format, to_format):
"""
Return False if we think the convert failed.
"""
app_cfg_name = "app/%s_to_%s_cmd" % (from_format, to_format)
if from_format == 'midi':
from_ext = 'mid'
else:
from_ext = from_format
to_ext = to_format
if not cfg.get_string(app_cfg_name):
solfege.win.display_error_message2("Config variable not defined", "The missing or empty variable was '%s'" % app_cfg_name)
return False
try:
inout = {
'in': os.path.join(export_dir,
"%s.%s" % (trackname % track_idx, from_ext)),
'out': os.path.join(export_dir,
"%s.%s" % (trackname % track_idx, to_ext))}
opts = cfg.get_string(app_cfg_name + '_options').split(" ")
opts = [x % inout for x in opts]
# For some reasong setting the executable arg does
# not work for Python 2.5.2
try:
subprocess.call(
[cfg.get_string(app_cfg_name)] + opts)
except OSError as e:
raise osutils.BinaryForMediaConvertorException(app_cfg_name,
cfg.get_string(app_cfg_name), e)
if os.path.exists(os.path.join(export_dir, "%s.%s" % (trackname % track_idx, to_ext))):
os.remove(os.path.join(export_dir, "%s.%s" % (trackname % track_idx, from_ext)))
else:
# This means that the program failed to generate
# the WAV file. We set output_format to 'midi'
# because we don't want to display this error for
# every single file.
output_format = 'midi'
solfege.win.display_error_message2("External program must have failed", "The file in %(from)s format was not generated from the %(to)s file as expected. Please check your setup in the preferences window (CTRL-F12)." % {'to': to_format.upper(), 'from': from_format.upper()})
except (TypeError, KeyError):
solfege.win.display_error_message2("%(from)s to %(to)s config error", "There was a format string error. Will not generate WAV files. Please check the app/midi_to_wav_cmd config variable." % {'from': from_format, 'to': to_format})
output_format = 'midi'
return True
开发者ID:tcamundsen,项目名称:solfege,代码行数:43,代码来源:application.py
示例11: create_gui_config
def create_gui_config(self):
i_iter, page_vbox = self.new_page_box(None, _("Interface"))
self.g_mainwin_user_resizeable = gu.nCheckButton('gui',
'mainwin_user_resizeable', _("_Resizeable main window"))
page_vbox.pack_start(self.g_mainwin_user_resizeable, False, False, 0)
# Combobox to select language
hbox = Gtk.HBox()
hbox.set_spacing(6)
label = Gtk.Label()
label.set_text_with_mnemonic(_("Select _language:"))
hbox.pack_start(label, False, False, 0)
self.g_language = Gtk.ComboBoxText()
for n in languages.languages:
self.g_language.append_text(n)
label.set_mnemonic_widget(self.g_language)
if sys.platform == 'win32':
lang = winlang.win32_get_langenviron()
if lang in languages.languages:
idx = languages.languages.index(lang)
elif lang == 'C':
idx = languages.C_locale_idx
else:
idx = 0
else:
lang = cfg.get_string('app/lc_messages')
if lang in languages.languages:
idx = languages.languages.index(lang)
elif lang == 'C':
idx = languages.C_locale_idx
else:
idx = 0
self.g_language.set_active(idx)
def f(combobox):
if combobox.get_active() == languages.C_locale_idx:
lang = "C"
else:
lang = languages.languages[combobox.get_active()]
cfg.set_string('app/lc_messages', lang)
if sys.platform == 'win32':
if combobox.get_active():
winlang.win32_put_langenviron(lang)
else:
winlang.win32_put_langenviron(None)
self.g_language.connect_after('changed', f)
hbox.pack_start(self.g_language, False, False, 0)
page_vbox.pack_start(hbox, False, False, 0)
l = Gtk.Label(label=_("You have to restart the program for the language change to take effect."))
l.set_alignment(0.0, 0.5)
page_vbox.pack_start(l, False, False, 0)
self.create_idtone_accels_config(i_iter)
self.create_interval_accels_config(i_iter)
开发者ID:tcamundsen,项目名称:solfege,代码行数:55,代码来源:configwindow.py
示例12: sComboBox
def sComboBox(exname, name, strings):
liststore = Gtk.ListStore(str)
for s in strings:
liststore.append([s])
g = Gtk.ComboBox.new_with_model_and_entry(liststore)
g.set_entry_text_column(0)
g.get_child().set_text(cfg.get_string("%s/%s" % (exname, name)))
g.connect('changed', lambda w:
cfg.set_string("%s/%s" % (exname, name),
w.get_child().get_text().decode("utf-8")))
return g
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:11,代码来源:gu.py
示例13: run_startup_profile_manager
def run_startup_profile_manager(self):
"""
Select a user profile to use. Return its name.
Quit program if user selects that.
"""
p = ProfileManager(self, cfg.get_string("app/last_profile"))
ret = p.run()
if ret == Gtk.ResponseType.ACCEPT:
profile = p.get_profile()
cfg.set_string("app/last_profile", "" if not profile else profile)
p.destroy()
return profile
else:
self.quit_program()
开发者ID:tcamundsen,项目名称:solfege,代码行数:14,代码来源:mainwin.py
示例14: acc_ff
def acc_ff(renderer, path, accel_key, accel_mods, hw_key):
is_unique = True
for interval in intervals:
if (interval != intervals[int(path)]
and cfg.get_string('interval_input/%s' % interval) == unichr(accel_key)):
is_unique = False
break
if not is_unique:
gu.dialog_ok(_(u"The accelerator in use for “%s”. You have to choose another key.") % mpd.Interval.new_from_int(intervals.index(interval)).get_name(), parent=self, msgtype=Gtk.MessageType.ERROR)
return
it = self.g_interval_accels.get_iter(path)
cfg.set_string('interval_input/%s' % intervals[int(path)], unichr(accel_key))
self.g_interval_accels.set(it, 1, unichr(accel_key))
return True
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:14,代码来源:configwindow.py
示例15: presetup
def presetup(app_defaults_filename, system_filename, user_filename):
if not os.path.exists(filesystem.app_data()):
os.makedirs(filesystem.app_data())
if not os.path.exists(filesystem.user_data()):
os.makedirs(filesystem.user_data())
try:
cfg.initialise(app_defaults_filename, system_filename, user_filename)
except UnicodeDecodeError:
traceback.print_exc()
print(file=sys.stderr)
print("\n".join(textwrap.wrap(
"Your %s file is not properly utf8 encoded. Most likely"
" it is the path to some external program that contain non-ascii"
" characters. Please edit or delete the file. Or email it to"
" [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))), file=sys.stderr)
print(file=sys.stderr)
sys.exit("I give up (solfege.py)")
except cfg.CfgParseException as e:
i18n.setup(".")
a, b = os.path.split(user_filename)
renamed_fn = os.path.join(a, "BAD-" + b)
m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
Gtk.ButtonsType.NONE,
_("Parsing %s failed") % filesystem.rcfile())
m.format_secondary_text(str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn))
m.add_buttons("Rename", 10)
m.add_buttons(Gtk.STOCK_QUIT, 11)
m.set_default_response(11)
ret = m.run()
if ret == 10:
os.rename(user_filename, renamed_fn)
m.destroy()
cfg.initialise(app_defaults_filename, system_filename, user_filename)
else:
sys.exit(1)
# MIGRATION from 2.9.2 to 2.9.3
if cfg.get_string("app/lc_messages") == 'C (english)':
cfg.set_string("app/lc_messages", "C")
开发者ID:tcamundsen,项目名称:solfege,代码行数:38,代码来源:presetup.py
示例16: setup_sound
def setup_sound(self):
if sys.platform == 'win32' and \
cfg.get_string("sound/type") == "sequencer-device":
# just in case c:\home\.solfegerc is wrong
cfg.set_string("sound/type", "winsynth")
if self.m_options.no_sound \
or cfg.get_string("sound/type") == "fake-synth":
soundcard.initialise_using_fake_synth(self.m_options.verbose_sound_init)
elif cfg.get_string("sound/type") == "alsa-sequencer":
if alsaseq:
try:
clientid, portid = self.get_list("sound/alsa-client-port")
except ValueError:
clientid, portid = (None, None)
try:
soundcard.initialise_alsa_sequencer((clientid, portid),
self.m_options.verbose_sound_init)
except alsaseq.SequencerError as e:
logging.debug("initialise_alsa_sequencer failed. Using fake synth.")
self.display_sound_init_error_message(e)
soundcard.initialise_using_fake_synth(True)
return
else:
if solfege.splash_win:
solfege.splash_win.hide()
gu.dialog_ok(_("The pyalsa Python module is missing"),
solfege.win,
_("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."))
soundcard.initialise_using_fake_synth(True)
if solfege.splash_win:
solfege.splash_win.show()
elif cfg.get_string("sound/type") == "winsynth":
try:
soundcard.initialise_winsynth(cfg.get_int("sound/synth_number"),
verbose_init=self.m_options.verbose_sound_init)
except ImportError as e:
self.display_sound_init_error_message(e)
cfg.set_string("sound/type", "fake-synth")
soundcard.initialise_using_fake_synth(True)
return
except RuntimeError as e:
# We can get here if winmidi.output_devices() in winsynth
# __init__ returns no devices. Don't know when, but it could
# happen.
gu.display_exception_message(e)
cfg.set_string("sound/type", "fake-synth")
soundcard.initialise_using_fake_synth(True)
return
if cfg.get_int("sound/synth_number") != soundcard.synth.m_devnum:
solfege.win.display_error_message2(_("MIDI setup"), _("MIDI Device %(olddev)i not available. Will use device %(newdev)i.") % {'olddev': cfg.get_int("sound/synth_number"), 'newdev': soundcard.synth.m_devnum})
cfg.set_int("sound/synth_number", soundcard.synth.m_devnum)
elif cfg.get_string("sound/type") == "external-midiplayer":
soundcard.initialise_external_midiplayer(
verbose_init=self.m_options.verbose_sound_init)
soundcard.synth.error_report_cb = solfege.win.display_error_message
elif cfg.get_string("sound/type") == '':
solfege.win.display_error_message(
_("You should configure sound from the 'Sound' page "
"of the preferences window."))
elif cfg.get_string("sound/type") == "sequencer-device":
try:
soundcard.initialise_devicefile(
cfg.get_string("sound/device_file"),
cfg.get_int("sound/synth_number"),
verbose_init=self.m_options.verbose_sound_init)
except (soundcard.SoundInitException, OSError, ImportError) as e:
self.m_sound_init_exception = e
soundcard.initialise_using_fake_synth(True)
if cfg.get_string("programs/csound") == "AUTODETECT":
for p in osutils.find_csound_executables():
cfg.set_string("programs/csound", p)
break
else:
# If not csound binary was found, then we set the string empty.
# This means that autodetection will only happen the first time
# you run the program. But later will newly installed binaries
# be shown in the combo box of the preferences window.
cfg.set_string("programs/csound", "")
if cfg.get_string("programs/mma") == "AUTODETECT":
for p in osutils.find_mma_executables(cfg.get_list("app/win32_ignore_drives")):
cfg.set_string("programs/mma", p)
break
else:
cfg.set_string("programs/mma", "")
开发者ID:tcamundsen,项目名称:solfege,代码行数:84,代码来源:application.py
示例17: start_gui
def start_gui(datadir):
cfg.set_bool('config/no_random', bool(options.no_random))
lessonfile.infocache = lessonfile.InfoCache()
def f(s):
if solfege.splash_win:
solfege.splash_win.show_progress(s)
if solfege.splash_win:
solfege.splash_win.show_progress(_("Creating application window"))
solfege.app = application.SolfegeApp(options)
solfege.win = w = MainWin(options, datadir)
solfege.app.setup_sound()
w.post_constructor()
solfege.win.load_frontpage()
w.show()
if solfege.splash_win:
solfege.splash_win.destroy()
solfege.splash_win = None
if not options.profile:
if cfg.get_bool("app/noprofilemanager"):
options.profile = cfg.get_string("app/last_profile")
elif do_profiles():
if solfege.splash_win:
solfege.splash_win.hide()
options.profile = solfege.win.run_startup_profile_manager()
if solfege.splash_win:
solfege.splash_win.show()
if solfege.splash_win:
solfege.splash_win.show_progress(_("Opening statistics database"))
try:
solfege.db = statistics.DB(f, profile=options.profile)
except sqlite3.OperationalError as e:
if solfege.splash_win:
solfege.splash_win.hide()
gu.dialog_ok(
_("Failed to open the statistics database:\n«%s»")
% str(e).decode(sys.getfilesystemencoding(), 'replace'),
solfege.win,
secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once."))
sys.exit()
def ef(t, value, traceback):
if options.debug:
msg = "ehooked:" + str(value)
else:
msg = str(value)
if issubclass(t, lessonfile.LessonfileException):
w.display_error_message(msg, str(t))
elif issubclass(t, osutils.ExecutableDoesNotExist):
if len(value.args) > 1:
w.display_error_message2(value.args[0], "\n".join(value.args[1:]))
else:
w.display_error_message(msg, str(t))
else:
sys.__excepthook__(t, value, traceback)
if not options.disable_exception_handler:
sys.excepthook = ef
print(time.time() - start_time)
# We parse all lesson files when we are idle to save a half a
# second the first time the user searches all lesson files using
# Ctrl-F.
lessonfile.infocache.parse_all_files(True)
if options.screenshots:
make_screenshots.make_screenshots()
if options.lessonfile:
solfege.app.practise_lessonfile(options.lessonfile)
开发者ID:tcamundsen,项目名称:solfege,代码行数:69,代码来源:startup.py
示例18: test_set_str
def test_set_str(self):
cfg.set_string("abc/def", "str string")
cfg.set_string("abc/ghi", "unicode string ØÆÅ")
self.assertTrue(isinstance(cfg.get_string("abc/def"), str))
self.assertTrue(isinstance(cfg.get_string("abc/ghi"), str))
开发者ID:tcamundsen,项目名称:solfege,代码行数:5,代码来源:test_cfg.py
示例19: up
" it is the path to some external program that contain non-ascii"
" characters. Please edit or delete the file. Or email it to"
" [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace")))
print >> sys.stderr
sys.exit("I give up (solfege.py)")
except cfg.CfgParseException, e:
i18n.setup(".")
a, b = os.path.split(user_filename)
renamed_fn = os.path.join(a, "BAD-"+b)
m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
Gtk.ButtonsType.NONE,
_("Parsing %s failed") % filesystem.rcfile())
m.format_secondary_text(str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn))
m.add_buttons("Rename", 10)
m.add_buttons(Gtk.STOCK_QUIT, 11)
m.set_default_response(11)
ret = m.run()
if ret == 10:
os.rename(user_filename, renamed_fn)
m.destroy()
cfg.initialise(app_defaults_filename, system_filename, user_filename)
else:
sys.exit(1)
# MIGRATION from 2.9.2 to 2.9.3
if cfg.get_string("app/lc_messages") == 'C (english)':
cfg.set_string("app/lc_messages", "C")
开发者ID:RannyeriDev,项目名称:Solfege,代码行数:29,代码来源:presetup.py
示例20: _
self.display_sound_init_error_message(e)
cfg.set_string("sound/type", "fake-synth")
soundcard.initialise_using_fake_synth(True)
return
except RuntimeError, e:
# We can get here if winmidi.output_devices() in winsynth
# __init__ returns no devices. Don't know when, but it could
# happen.
gu.display_exception_message(e)
cfg.set_string("sound/type", "fake-synth")
soundcard.initialise_using_fake_synth(True)
return
if cfg.get_int("sound/synth_number") != soundcard.synth.m_devnum:
solfege.win.display_error_message2(_("MIDI setup"), _("MIDI Device %(olddev)i not available. Will use device %(newdev)i.") % {'olddev': cfg.get_int("sound/synth_number"), 'newdev': soundcard.synth.m_devnum})
cfg.set_int("sound/synth_number", soundcard.synth.m_devnum)
elif cfg.get_string("sound/type") == "external-midiplayer":
soundcard.initialise_external_midiplayer(
verbose_init=self.m_options.verbose_sound_init)
soundcard.synth.error_report_cb = solfege.win.display_error_message
elif cfg.get_string("sound/type") == '':
solfege.win.display_error_message(
_("You should configure sound from the 'Sound' page "
"of the preferences window."))
elif cfg.get_string("sound/type") == "sequencer-device":
try:
soundcard.initialise_devicefile(
cfg.get_string("sound/device_file"),
cfg.get_int("sound/synth_number"),
verbose_init=self.m_options.verbose_sound_init)
except (soundcard.SoundInitException, OSError, ImportError), e:
self.m_sound_init_exception = e
开发者ID:PauloJava2016,项目名称:Solfege,代码行数:31,代码来源:application.py |
请发表评论