Пример #1
0
class DisplaytestWindow(gtk.Window):
    def on_quit(self, w):
        t = self.m_buf.get_text(self.m_buf.get_start_iter(),
                                self.m_buf.get_end_iter(), True)
        self.save(t)

    def __init__(self):
        gtk.Window.__init__(self)
        self.connect('destroy', self.on_quit)
        self.vbox = vbox = gtk.VBox()
        vbox.show()
        self.add(vbox)
        self.g_text = gtk.TextView()
        self.g_text.set_size_request(-1, 100)
        self.g_text.show()
        self.g_text.set_editable(True)
        try:
            s = open(musicfile, "r").read()
        except IOError, e:
            s = r"\staff{c' d' e'}"
        self.m_buf = self.g_text.get_buffer()
        self.m_buf.insert(self.m_buf.get_end_iter(), s)
        vbox.pack_start(self.g_text)
        self.g_displayer = MusicDisplayer()
        self.g_displayer.set_size_request(200, 200)
        self.g_displayer.show()
        self.vbox.pack_start(self.g_displayer)
        gu.bButton(vbox, "Parse", self.on_parse)
        gu.bButton(vbox, "Display", self.on_display)
        gu.bButton(vbox, "Display first notes", self.on_display_first_notes)
        gu.bButton(vbox, "Play", self.on_play)
        gu.bButton(vbox, "Play first", self.on_play_first)
Пример #2
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher, no_notebook=False)
        ################
        # practise_box #
        ################
        self.g_question_title = gu.bLabel(self.practise_box, "", False, False)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.set_size_request(500, -1)
        self.g_music_displayer.show()
        self.practise_box.pack_start(self.g_music_displayer, True, True, 0)
        ###############
        # action_area #
        ###############
        self.g_partbox = gu.bHBox(self.practise_box, False)
        self.g_go_back = Gtk.Button(stock='gtk-go-back')
        self.g_go_back.connect('clicked', self.select_previous)
        self.g_go_back.show()
        self.action_area.pack_start(self.g_go_back, False, False, 0)
        self.g_go_forward = Gtk.Button(stock='gtk-go-forward')
        self.g_go_forward.show()
        self.g_go_forward.connect('clicked', self.select_next)
        self.action_area.pack_start(self.g_go_forward, False, False, 0)
        self.g_play = gu.bButton(self.action_area, _("_Play the whole music"),
                                 self.play)
        self.g_show = gu.bButton(self.action_area, _("_Show"),
                                 self.show_answer)
Пример #3
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher, no_notebook=False)
        ################
        # practise_box #
        ################
        self.g_question_title = gu.bLabel(self.practise_box, "", False, False)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.set_size_request(500, -1)
        self.g_music_displayer.show()
        self.practise_box.pack_start(self.g_music_displayer, True, True, 0)
        ###############
        # action_area #
        ###############
        self.g_partbox = gu.bHBox(self.practise_box, False)
        self.g_go_back = Gtk.Button(stock='gtk-go-back')
        self.g_go_back.connect('clicked', self.select_previous)
        self.g_go_back.show()
        self.action_area.pack_start(self.g_go_back, False, False, 0)
        self.g_go_forward = Gtk.Button(stock='gtk-go-forward')
        self.g_go_forward.show()
        self.g_go_forward.connect('clicked', self.select_next)
        self.action_area.pack_start(self.g_go_forward, False, False, 0)
        self.g_play = gu.bButton(self.action_area, _("_Play the whole music"),
                                 self.play)
        self.g_show = gu.bButton(self.action_area, _("_Show"), self.show_answer)
Пример #4
0
 def __init__(self, fields=('link',)):
     SelectWinBase.__init__(self)
     self.m_fields = fields
     self.g_box = Gtk.VBox(False, 0)
     self.g_box.set_border_width(gu.hig.SPACE_MEDIUM)
     self.add_with_viewport(self.g_box)
     self.g_searchbox = Gtk.HBox(False, gu.hig.SPACE_SMALL)
     self.g_box.pack_start(self.g_searchbox, False, False, padding=gu.hig.SPACE_MEDIUM)
     self.g_searchentry = Gtk.Entry()
     self.g_searchbox.pack_start(self.g_searchentry, True, True, 0)
     self.g_searchentry.connect('activate', self.on_search)
     gu.bButton(self.g_searchbox, _("Search"), callback=self.on_search, expand=False)
     self.show_all()
Пример #5
0
 def __init__(self, teacher):
     abstract.LessonbasedGui.__init__(self, teacher, True)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.g_music_displayer.show()
     self.practise_box.pack_start(self.g_music_displayer, False, False, 0)
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.g_quality_box = gu.bHBox(self.practise_box)
     self.g_quality_box.show()
     self.g_number_box = gu.bHBox(self.practise_box)
     self.g_number_box.show()
     gu.bButton(self.action_area, _("_New"), self.new_question)
Пример #6
0
 def __init__(self, teacher):
     abstract.LessonbasedGui.__init__(self, teacher, True)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.g_music_displayer.show()
     self.practise_box.pack_start(self.g_music_displayer, False, False, 0)
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.g_quality_box = gu.bHBox(self.practise_box)
     self.g_quality_box.show()
     self.g_number_box = gu.bHBox(self.practise_box)
     self.g_number_box.show()
     gu.bButton(self.action_area, _("_New"), self.new_question)
Пример #7
0
 def __init__(self,  fields=('link',)):
     SelectWinBase.__init__(self)
     self.m_fields = fields
     app = solfege.app
     self.g_box = gtk.VBox()
     self.g_box.set_border_width(gu.hig.SPACE_MEDIUM)
     self.add_with_viewport(self.g_box)
     self.g_searchbox = gtk.HBox()
     self.g_box.pack_start(self.g_searchbox, False, padding=gu.hig.SPACE_MEDIUM)
     self.g_searchentry = gtk.Entry()
     self.g_searchbox.pack_start(self.g_searchentry, True)
     self.g_searchentry.connect('activate', self.on_search)
     gu.bButton(self.g_searchbox, _("Search"), callback=self.on_search, expand=False)
     self.show_all()
Пример #8
0
    def create_win32_sound_page(self):
        it, page_vbox = self.new_page_box(None, _("Sound Setup"))
        
        #############
        # midi setup
        #############
        
        txt = Gtk.Label(_("""Solfege has two ways to play MIDI files. It is recommended to use Windows multimedia output. An external MIDI player can be useful if your soundcard lacks a hardware synth, in which case you have to use a program like timidity to play the music."""))
        txt.set_line_wrap(1)
        txt.set_justify(Gtk.Justification.FILL)
        txt.set_alignment(0.0, 0.0)
        page_vbox.pack_start(txt, False, False, 0)

        self.g_fakesynth_radio = gu.RadioButton(None, _("_No sound"), None)
        page_vbox.pack_start(self.g_fakesynth_radio, False, False, 0)

        hbox = gu.bHBox(page_vbox, False)
        self.g_device_radio = gu.RadioButton(self.g_fakesynth_radio,
              _("_Windows multimedia output:"), None)
        self.g_synth = Gtk.ComboBoxText()
        if winmidi:
            for devname in winmidi.output_devices():
                #FIXME workaround of the bug
                # http://code.google.com/p/solfege/issues/detail?id=12
                
                if devname is None:
                    self.g_synth.append_text("FIXME bug #12")
                
                else:
                    self.g_synth.append_text(devname)
        self.g_synth.set_active(self.get_int('sound/synth_number') + 1)
        hbox.pack_start(self.g_device_radio, False, False, 0)
        hbox.pack_start(self.g_synth, False, False, 0)

        hbox = gu.bHBox(page_vbox, False)
        self.g_midiplayer_radio = gu.RadioButton(self.g_fakesynth_radio,
             _("Use _external MIDI player"), None)
        hbox.pack_start(self.g_midiplayer_radio, False, False, 0)

        if self.get_string("sound/type") == "external-midiplayer":
            self.g_midiplayer_radio.set_active(True)
        
        elif self.get_string("sound/type") == "winsynth":
            self.g_device_radio.set_active(True)
        
        else:
            self.g_fakesynth_radio.set_active(True)

        gu.bButton(page_vbox, _("_Test"), self.on_apply_and_play_test_sound, False)
Пример #9
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher, no_notebook=True)
        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.clear()
        self.g_music_displayer.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
        self.practise_box.pack_start(self.g_music_displayer, True, True, 0)

        self.g_new = gu.bButton(self.action_area, _("_New"), self.new_question)
        self.g_play_first_note = gu.bButton(self.action_area, _("_Play first note"), lambda f, s=self: s.m_t.play_question())
        self.g_play_first_note.set_sensitive(False)
        self.g_play_last_note = gu.bButton(self.action_area, _("Play _last note"), lambda f, s=self: s.m_t.play_last_note())
        self.g_play_last_note.set_sensitive(False)
        self.g_play_all = gu.bButton(self.action_area, _("Play _all"), lambda f, s=self: s.m_t.play_all_notes())
        self.g_play_all.set_sensitive(False)
        self.practise_box.show_all()
Пример #10
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     #
     self.g_music_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_music_displayer, False, False, 0)
     #
     self.g_tap = gu.bButton(self.practise_box, _("Tap here"), self.on_tap)
     self.std_buttons_add(
         ('new', self.on_new_question),
         ('play_music',
          lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
         ('display_music', self.show_answer), ('repeat', self.on_repeat),
         ('give_up', self.on_give_up))
     # Flashbar
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     ###############
     # Config grid #
     ###############
     label = Gtk.Label(label=_("Accuracy required:"))
     label.props.halign = Gtk.Align.END
     label.show()
     self.g_config_grid.attach(label, 0, 0, 1, 1)
     spin = gu.nSpinButton(self.m_exname, 'accuracy',
                           Gtk.Adjustment(0, 0, 2, 0.01, 0.05))
     spin.set_digits(2)
     self.g_config_grid.attach(spin, 1, 0, 1, 1)
Пример #11
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     #
     self.g_music_displayer = mpd.musicdisplayer.MusicDisplayer()
     self.practise_box.pack_start(self.g_music_displayer, False)
     #
     self.g_tap = gu.bButton(self.practise_box, _("Tap here"), self.on_tap)
     self.std_buttons_add(
         ('new', self.on_new_question),
         ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
         ('display_music', self.show_answer),
         ('repeat', self.on_repeat),
         ('give_up', self.on_give_up))
     # Flashbar
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False)
     # Config box
     label = gtk.Label(_("Accuracy required:"))
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     spin = gu.nSpinButton(self.m_exname, 'accuracy',
                           gtk.Adjustment(0, 0, 2, 0.01, 0.05))
     spin.set_tooltip_text("See bug report #93 (http://bugs.solfege.org/93) and add suggested values to the bug report.")
     spin.set_digits(2)
     hbox = gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     hbox.pack_start(label, False)
     hbox.pack_start(spin, False)
     self.config_box.pack_start(hbox, False)
     hbox.show_all()
Пример #12
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     #
     self.g_music_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_music_displayer, False, False, 0)
     #
     self.g_tap = gu.bButton(self.practise_box, _("Tap here"), self.on_tap)
     self.std_buttons_add(
         ('new', self.on_new_question),
         ('play_music',
          lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
         ('display_music', self.show_answer), ('repeat', self.on_repeat),
         ('give_up', self.on_give_up))
     # Flashbar
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     # Config box
     label = Gtk.Label(label=_("Accuracy required:"))
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     spin = gu.nSpinButton(self.m_exname, 'accuracy',
                           Gtk.Adjustment(0, 0, 2, 0.01, 0.05))
     spin.set_tooltip_text(
         "See bug report #93 (http://bugs.solfege.org/93) and add suggested values to the bug report."
     )
     spin.set_digits(2)
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     hbox.pack_start(label, False, False, 0)
     hbox.pack_start(spin, False, False, 0)
     self.config_box.pack_start(hbox, False, False, 0)
     hbox.show_all()
Пример #13
0
 def std_buttons_add(self, *buttons):
     """
     buttons is a sequence of tuples ('buttonname', callback)
     buttonnames with a hyphen '-' are splitted at the first hyphen,
     and only the first part of the name are used.
     """
     d = {'new': _("_New"),
          'new-interval': _("_New interval"),
          'new-chord': _("_New chord"),
          'new-tone': _("_New tone"),
          'repeat': _("_Repeat"),
          'repeat_arpeggio': _("Repeat _arpeggio"),
          'repeat_slowly': _("Repeat _slowly"),
          'repeat_melodic': _("Repeat _melodic"),
          'play_tonic': _("Play _tonic"),
          'play_music': _("P_lay music"),
          'play_answer': _("_Play answer"),
          'guess_answer': _("Guess _answer"),
          'display_music': _("_Display music"),
          # This button exist mostly for historical reasons, but I think
          # it can be useful, even though it is not much used today (as in
          # Solfege 3.6). It will present a Show button for exercises that
          # does not have a music displayer. And the button will be
          # insensitive until the question has been solved.
          'show': _("_Show"),
          'give_up': _("_Give up")
     }
     self._std_buttons.extend([x[0] for x in buttons])
     for b, cb in buttons:
         button = gu.bButton(self.action_area, d[b], cb)
         if '-' in b:
             b = b.split('-')[0]
         setattr(self, 'g_%s' % b, button)
Пример #14
0
    def create_win32_sound_page(self):
        it, page_vbox = self.new_page_box(None, _("Sound Setup"))
        #############
        # midi setup
        #############
        txt = Gtk.Label(
            _("""Solfege has two ways to play MIDI files. It is recommended to use Windows multimedia output. An external MIDI player can be useful if your soundcard lacks a hardware synth, in which case you have to use a program like timidity to play the music."""
              ))
        txt.set_line_wrap(1)
        txt.set_justify(Gtk.Justification.FILL)
        txt.set_alignment(0.0, 0.0)
        page_vbox.pack_start(txt, False, False, 0)

        self.g_fakesynth_radio = gu.RadioButton(None, _("_No sound"), None)
        page_vbox.pack_start(self.g_fakesynth_radio, False, False, 0)

        hbox = gu.bHBox(page_vbox, False)
        self.g_device_radio = gu.RadioButton(self.g_fakesynth_radio,
                                             _("_Windows multimedia output:"),
                                             None)
        self.g_synth = Gtk.ComboBoxText()
        if winmidi:
            for devname in winmidi.output_devices():
                #FIXME workaround of the bug
                # http://code.google.com/p/solfege/issues/detail?id=12
                if devname is None:
                    self.g_synth.append_text("FIXME bug #12")
                else:
                    self.g_synth.append_text(devname)
        self.g_synth.set_active(self.get_int('sound/synth_number') + 1)
        hbox.pack_start(self.g_device_radio, False, False, 0)
        hbox.pack_start(self.g_synth, False, False, 0)

        hbox = gu.bHBox(page_vbox, False)
        self.g_midiplayer_radio = gu.RadioButton(
            self.g_fakesynth_radio, _("Use _external MIDI player"), None)
        hbox.pack_start(self.g_midiplayer_radio, False, False, 0)

        if self.get_string("sound/type") == "external-midiplayer":
            self.g_midiplayer_radio.set_active(True)
        elif self.get_string("sound/type") == "winsynth":
            self.g_device_radio.set_active(True)
        else:
            self.g_fakesynth_radio.set_active(True)

        gu.bButton(page_vbox, _("_Test"), self.on_apply_and_play_test_sound,
                   False)
Пример #15
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_music_displayer = mpd.MusicDisplayer()
        self.practise_box.pack_start(self.g_music_displayer, True, True, 0)

        self.g_new = gu.bButton(self.action_area, _("_New"), self.new_question)
        gu.bButton(self.action_area, _("440h_z"), self.play_440hz)
        self.g_play_answer = gu.bButton(self.action_area, _("_Play answer"),
            lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_random_transpose_gui()
Пример #16
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.add_module_is_deprecated_label()
        self.g_hbox = hbox = gu.bHBox(self.practise_box)
        hbox.set_spacing(gu.PAD)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        hbox.pack_start(self.g_music_displayer, False, False, 0)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.g_new = gu.bButton(self.action_area, _("_New chord"),
                                self.new_question)
        self.g_repeat = gu.bButton(
            self.action_area, _("_Repeat"),
            lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
        self.g_repeat_arpeggio = gu.bButton(
            self.action_area, _("Repeat _arpeggio"), lambda w: self.
            run_exception_handled(self.m_t.m_P.play_question_arpeggio))
        self.g_give_up = gu.bButton(self.action_area, _("_Give up"),
                                    self.give_up)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box = gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True,
                                   True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
Пример #17
0
 def __init__(self, parent):
     Gtk.Dialog.__init__(self, parent)
     self.set_transient_for(parent)
     self.set_default_size(500, 300)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.vbox.pack_start(self.g_music_displayer, True, True, 0)
     b = gu.bButton(self.action_area, _("Close"), solfege.win.close_musicviewer)
     b.grab_focus()
     self.connect('destroy', solfege.win.close_musicviewer)
     self.show_all()
Пример #18
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.m_key_bindings = {'backspace_ak': self.on_backspace}
        self.g_answer_box = gu.NewLineBox()
        self.practise_box.pack_start(self.g_answer_box, False)
        #-------
        hbox = gu.bHBox(self.practise_box)
        b = gtk.Button(_("Play"))
        b.show()
        b.connect('clicked', self.play_users_answer)
        hbox.pack_start(b, False, True)
        self.practise_box.pack_start(gtk.HBox(), False,
                                     padding=gu.PAD_SMALL)
        self.g_rhythm_viewer = RhythmViewer(self)
        #FIXME the value 52 is dependant on the theme used
        self.g_rhythm_viewer.set_size_request(-1, 52)
        self.g_rhythm_viewer.create_holders()
        hbox.pack_start(self.g_rhythm_viewer)
        #self.practise_box.pack_start(self.g_rhythm_viewer, False)

        # action area
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', self.repeat_question),
            ('give_up', self.give_up))

        self.g_backspace = gu.bButton(self.action_area, _("_Backspace"),
                     self.on_backspace)
        self.g_backspace.set_sensitive(False)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_select_elements_gui()
        #--------
        self.config_box.pack_start(gtk.HBox(), False,
                                   padding=gu.PAD_SMALL)
        self.add_select_num_beats_gui()
        #-----
        self.config_box.pack_start(gtk.HBox(), False,
                                   padding=gu.PAD_SMALL)
        #------
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                 "not_start_with_rest",
                 _("Don't start the question with a rest")), False)
        sep = gtk.VSeparator()
        hbox.pack_start(sep, False)
        hbox.pack_start(gtk.Label(_("Beats per minute:")), False)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                 gtk.Adjustment(60, 20, 240, 1, 10))
        hbox.pack_start(spin, False)
        self._add_auto_new_question_gui(self.config_box)
        self.config_box.show_all()
Пример #19
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.add_module_is_deprecated_label()
        self.g_hbox = hbox = gu.bHBox(self.practise_box)
        hbox.set_spacing(gu.PAD)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        hbox.pack_start(self.g_music_displayer, False, False, 0)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.g_new = gu.bButton(self.action_area, _("_New chord"),
                                self.new_question)
        self.g_repeat = gu.bButton(self.action_area, _("_Repeat"),
              lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
        self.g_repeat_arpeggio = gu.bButton(self.action_area,
              _("Repeat _arpeggio"),
              lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio))
        self.g_give_up = gu.bButton(self.action_area, _("_Give up"),
                                    self.give_up)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True, True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
Пример #20
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_music_displayer, True, True, 0)
     self.g_flashbar = gu.FlashBar()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.g_music_displayer.clear()
     self.g_new = gu.bButton(self.action_area, _("_New"), self.new_question)
     self.g_repeat = gu.bButton(self.action_area, _("_Repeat"),
         lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
     self.g_repeat_arpeggio = gu.bButton(self.action_area,
         _("Repeat _arpeggio"),
         lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio))
     self.g_play_answer = gu.bButton(self.action_area,
                 _("_Play answer"), self.hear_answer)
     ##############
     # config_box #
     ##############
     self.add_random_transpose_gui()
     self.practise_box.show_all()
Пример #21
0
 def __init__(self, parent):
     Gtk.Dialog.__init__(self, parent)
     self.set_transient_for(parent)
     self.set_default_size(500, 300)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.vbox.pack_start(self.g_music_displayer, True, True, 0)
     b = gu.bButton(self.action_area, _("Close"),
                    solfege.win.close_musicviewer)
     b.grab_focus()
     self.connect('destroy', solfege.win.close_musicviewer)
     self.show_all()
Пример #22
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     self.g_music_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_music_displayer, True, True, 0)
     self.g_flashbar = gu.FlashBar()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.g_music_displayer.clear()
     self.g_new = gu.bButton(self.action_area, _("_New"), self.new_question)
     self.g_repeat = gu.bButton(
         self.action_area, _("_Repeat"),
         lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
     self.g_repeat_arpeggio = gu.bButton(
         self.action_area, _("Repeat _arpeggio"), lambda w: self.
         run_exception_handled(self.m_t.m_P.play_question_arpeggio))
     self.g_play_answer = gu.bButton(self.action_area, _("_Play answer"),
                                     self.hear_answer)
     ##############
     # config_box #
     ##############
     self.add_random_transpose_gui()
     self.practise_box.show_all()
Пример #23
0
 def std_buttons_add(self, *buttons):
     """
     buttons is a sequence of tuples ('buttonname', callback)
     buttonnames with a hyphen '-' are splitted at the first hyphen,
     and only the first part of the name are used.
     """
     d = {
         'new': _("_New"),
         'new-interval': _("_New interval"),
         'new-chord': _("_New chord"),
         'new-tone': _("_New tone"),
         'repeat': _("_Repeat"),
         'repeat_arpeggio': _("Repeat _arpeggio"),
         'repeat_slowly': _("Repeat _slowly"),
         'repeat_melodic': _("Repeat _melodic"),
         'repeat_first': _("Repeat first"),
         'repeat_last': _("Repeat last"),
         'play_tonic': _("Play _tonic"),
         'play_music': _("P_lay music"),
         'play_answer': _("_Play answer"),
         'guess_answer': _("Guess _answer"),
         'display_music': _("_Display music"),
         # This button exist mostly for historical reasons, but I think
         # it can be useful, even though it is not much used today (as in
         # Solfege 3.6). It will present a Show button for exercises that
         # does not have a music displayer. And the button will be
         # insensitive until the question has been solved.
         'show': _("_Show"),
         'give_up': _("_Give up"),
         'backspace': _("Backspace"),
     }
     self._std_buttons.extend([x[0] for x in buttons])
     for b, cb in buttons:
         button = gu.bButton(self.action_area, d[b], cb)
         if '-' in b:
             b = b.split('-')[0]
         setattr(self, 'g_%s' % b, button)
Пример #24
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        self.g_lesson_heading.hide()
        self.g_music_displayer = mpd.musicdisplayer.MusicDisplayer()
        self.practise_box.pack_start(self.g_music_displayer, False)

        self.g_answer_button_box = gu.NewLineBox()
        self.practise_box.pack_start(self.g_answer_button_box)
        # The user fill the answer in this box
        self.g_answer_frame = gtk.Frame()
        self.g_answer_frame.set_shadow_type(gtk.SHADOW_IN)
        self.practise_box.pack_start(self.g_answer_frame, False, False)
        self.g_answer = gtk.HBox()
        self.g_answer_frame.add(self.g_answer)
        self.g_answer_frame.show_all()
        # Flashbar
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False)
        # action area
        self.std_buttons_add(
            ('new', self.new_question),
            ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('display_music', self.show_answer),
            ('repeat', self.repeat_question),
            ('guess_answer', self.guess_answer),
            ('play_tonic', lambda w: self.run_exception_handled(self.m_t.play_tonic)),
            ('give_up', self.give_up),
        )
        self.g_backspace = gu.bButton(self.action_area, _("_Backspace"),
                     self.on_backspace)
        self.g_backspace.set_sensitive(False)
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.PercentagesStatisticsViewer,
                                   _("elembuilder"))
Пример #25
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     ################
     # practise_box #
     ################
     self.g_score_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_score_displayer, True, True, 0)
     self.g_score_displayer.clear()
     b1 = gu.bHBox(self.practise_box, False)
     self.g_new_interval_correct = gu.bButton(
         b1, _("_New interval,\nlast was correct"), self.new_question)
     self.g_new_interval_wrong = gu.bButton(
         b1, _("New interval,\nlast was _wrong"), self.new_last_was_wrong)
     self.g_new_interval = gu.bButton(b1, _("_New interval"),
                                      self.new_question)
     self.g_new_interval_wrong.set_sensitive(False)
     self.g_repeat_tonika = gu.bButton(
         self.action_area,
         _("_Repeat first tone"),
         lambda _o, self=self: self.m_t.play_first_tone())
     self.g_repeat_tonika.set_sensitive(False)
     self.g_play_answer = gu.bButton(
         self.action_area,
         _("_Play answer"),
         lambda _o, self=self: self.m_t.play_question())
     self.g_play_answer.set_sensitive(False)
     self.g_repeat_last_tone = gu.bButton(
         self.action_area,
         _("Play _last tone"),
         lambda _o, self=self: self.m_t.play_last_tone())
     self.g_repeat_last_tone.set_sensitive(False)
     self.practise_box.show_all()
     self.g_new_interval_correct.hide()
     self.g_new_interval_wrong.hide()
     ###############
     # config_grid #
     ###############
     self.g_mici = MultipleIntervalConfigWidget(self.m_exname,
                                                self.g_config_grid, 0, 0)
     ###############
     # statistics
     ###############
     self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                 _("Sing interval"))
Пример #26
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     ################
     # practise_box #
     ################
     self.g_score_displayer = mpd.MusicDisplayer()
     self.practise_box.pack_start(self.g_score_displayer, True, True, 0)
     self.g_score_displayer.clear()
     b1 = gu.bHBox(self.practise_box, False)
     self.g_new_interval_correct = gu.bButton(b1,
             _("_New interval,\nlast was correct"), self.new_question)
     self.g_new_interval_wrong = gu.bButton(b1,
             _("New interval,\nlast was _wrong"), self.new_last_was_wrong)
     self.g_new_interval = gu.bButton(b1,
            _("_New interval"), self.new_question)
     self.g_new_interval_wrong.set_sensitive(False)
     self.g_repeat_tonika = gu.bButton(self.action_area,
                  _("_Repeat first tone"),
                  lambda _o, self=self: self.m_t.play_first_tone())
     self.g_repeat_tonika.set_sensitive(False)
     self.g_play_answer = gu.bButton(self.action_area,
                  _("_Play answer"),
                  lambda _o, self=self: self.m_t.play_question())
     self.g_play_answer.set_sensitive(False)
     self.g_repeat_last_tone = gu.bButton(self.action_area,
        _("Play _last tone"), lambda _o, self=self: self.m_t.play_last_tone())
     self.g_repeat_last_tone.set_sensitive(False)
     self.practise_box.show_all()
     self.g_new_interval_correct.hide()
     self.g_new_interval_wrong.hide()
     ##############
     # config_box #
     ##############
     self.g_mici = MultipleIntervalConfigWidget(self.m_exname)
     self.config_box.pack_start(self.g_mici, False, False, 0)
     self.config_box.show_all()
     ###############
     # statistics
     ###############
     self.setup_statisticsviewer(
        statisticsviewer.StatisticsViewer, _("Sing interval"))
Пример #27
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self._ignore_events = 0
        ##############
        # practise_box
        ##############
        self.practise_box.set_spacing(gu.PAD)
        hbox = gu.bHBox(self.practise_box)
        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.clear()
        hbox.pack_start(self.g_music_displayer, True, True, 0)

        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        hbox = gu.bHBox(self.practise_box, False)
        hbox.set_homogeneous(True)
        self.g_first_is_largest = gu.bButton(hbox, _("F_irst interval\nis largest"), lambda f, self=self: self.guess_answer(-1))
        self.g_first_is_largest.get_child().set_justify(Gtk.Justification.CENTER)
        self.g_first_is_largest.set_sensitive(False)
        self.g_equal_size = gu.bButton(hbox, _("The intervals\nare _equal"), lambda f, self=self: self.guess_answer(0))
        self.g_equal_size.get_child().set_justify(Gtk.Justification.CENTER)
        self.g_equal_size.set_sensitive(False)
        self.g_last_is_largest = gu.bButton(hbox, _("_Last interval\nis largest"), lambda f, self=self: self.guess_answer(1))
        self.g_last_is_largest.set_sensitive(False)
        self.g_last_is_largest.get_child().set_justify(Gtk.Justification.CENTER)
        self.std_buttons_add(
                ('new', self.new_question),
                ('repeat', lambda w, self=self: self.m_t.play_question()),
                ('repeat_first', self.m_t.play_first_interval),
                ('repeat_last', self.m_t.play_last_interval),
                ('give_up', self.give_up),
        )
        self.action_area.set_homogeneous(True)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self._add_auto_new_question_gui(self.config_box)
        # ----------------------------------------------

        def pack_rdbs(box, callback):
            D = {}
            D['harmonic'] = b = gu.RadioButton(None, _("Harmonic"), callback)
            b.m_idir = 'harmonic'
            box.pack_start(b, False, False, 0)
            D['melodic'] = b = gu.RadioButton(b, _("Melodic"), callback)
            b.m_idir = 'melodic'
            box.pack_start(b, False, False, 0)
            return D
        #---------
        self.g_intervalconfig_box = gu.bVBox(self.config_box, False)
        hbox = gu.bHBox(self.g_intervalconfig_box, False)
        hbox.pack_start(Gtk.Label(_("First interval:")), False, False,
                        padding=gu.PAD_SMALL)
        self.g_rdbs = [pack_rdbs(hbox, self.update_first)]
        self.g_first_interval_up = nIntervalCheckBox(self.m_exname,
                                                     'first_interval_up')
        self.g_intervalconfig_box.pack_start(self.g_first_interval_up, False, False, 0)
        self.g_first_interval_down = nIntervalCheckBox(
            self.m_exname, 'first_interval_down')
        self.g_intervalconfig_box.pack_start(self.g_first_interval_down, False, False, 0)
        #----------
        hbox = gu.bHBox(self.g_intervalconfig_box, False)
        hbox.pack_start(Gtk.Label(_("Last interval:")), False, False,
                        padding=gu.PAD_SMALL)
        self.g_rdbs.append (pack_rdbs(hbox, self.update_last))
        self.g_last_interval_up = nIntervalCheckBox(self.m_exname,
                     'last_interval_up')
        self.g_intervalconfig_box.pack_start(self.g_last_interval_up, False, False, 0)
        self.g_last_interval_down = nIntervalCheckBox(self.m_exname,
                        'last_interval_down')
        self.g_intervalconfig_box.pack_start(self.g_last_interval_down, False, False, 0)
        #------------
        s = self.get_string('first_interval_type')
        if not s in ('harmonic', 'melodic'):
            self.set_string('first_interval_type', 'harmonic')
        self.g_rdbs[0][self.get_string('first_interval_type')].set_active(True)
        self.update_first(self.g_rdbs[0][self.get_string('first_interval_type')])
        s = self.get_string('last_interval_type')
        if not s in ('harmonic', 'melodic'):
            self.set_string('last_interval_type', 'harmonic')
        self.g_rdbs[1][self.get_string('last_interval_type')].set_active(True)
        self.update_last(self.g_rdbs[1][self.get_string('last_interval_type')])
        self.config_box.show_all()
        self.add_watch('first_interval_type', self._watch_1_cb)
        self.add_watch('last_interval_type', self._watch_2_cb)
Пример #28
0
    def create_linux_sound_page(self):
        it, page_vbox = self.new_page_box(None, _("Sound Setup"))
        #############
        # midi setup
        #############

        self.g_fakesynth_radio = gu.RadioButton(None, _("_No sound"), None)
        page_vbox.pack_start(self.g_fakesynth_radio, False, False, 0)

        ### ALSA
        self.m_gui_client_port = False
        hbox = gu.bHBox(page_vbox, False)
        self.g_alsa_radio = gu.RadioButton(self.g_fakesynth_radio,
                                           _("Use ALSA _device"), None)
        hbox.pack_start(self.g_alsa_radio, False, False, 0)

        self.g_alsa_device = Gtk.Button()
        self.g_alsa_device.connect('clicked', self.popup_alsa_connection_list)
        hbox.pack_start(self.g_alsa_device, False, False, 0)
        if solfege.soundcard.alsa_sequencer:
            connections = solfege.soundcard.alsa_sequencer.get_connection_list(
            )
            for v in connections:
                if v[0:2] == self.get_list("sound/alsa-client-port"):
                    self.g_alsa_device.set_label(v[-1])
                    self.m_gui_client_port = v[0:2]
                    break
            else:
                if connections:
                    self.m_gui_client_port = connections[-1][0:2]
                    self.g_alsa_device.set_label(connections[-1][-1])
                else:
                    self.g_alsa_device.set_label("")
        else:
            self.g_alsa_device.set_sensitive(False)
            self.g_alsa_radio.set_sensitive(False)
            label = Gtk.Label(
                label="Disabled because the pyalsa Python module was not found."
            )
            label.show()
            hbox.pack_start(label, False, False, 0)
        ### OSS
        hbox = gu.bHBox(page_vbox, False)
        self.g_device_radio = gu.RadioButton(self.g_fakesynth_radio,
                                             _("Use OSS _device"), None)
        hbox.pack_start(self.g_device_radio, False, False, 0)

        self.g_device_file = gu.sComboBox(
            'sound', 'device_file',
            ['/dev/sequencer', '/dev/sequencer2', '/dev/music'])
        self.g_synth_num = Gtk.SpinButton()
        self.g_synth_num.set_adjustment(Gtk.Adjustment(0, 0, 100, 1, 1))
        self.g_synth_num.set_value(self.get_int('sound/synth_number'))
        hbox.pack_start(self.g_device_file, False, False, 0)
        hbox.pack_start(self.g_synth_num, False, False, 0)

        ###
        hbox = gu.bHBox(page_vbox, False)
        self.g_midiplayer_radio = gu.RadioButton(
            self.g_fakesynth_radio, _("Use _external MIDI player"), None)
        hbox.pack_start(self.g_midiplayer_radio, False, False, 0)

        if self.get_string("sound/type") == "external-midiplayer":
            self.g_midiplayer_radio.set_active(True)
        elif self.get_string("sound/type") == "sequencer-device":
            self.g_device_radio.set_active(True)
        elif self.get_string("sound/type") == "alsa-sequencer":
            self.g_alsa_radio.set_active(True)
        else:
            self.g_fakesynth_radio.set_active(True)

        gu.bButton(page_vbox, _("_Test"), self.on_apply_and_play_test_sound,
                   False)
Пример #29
0
    def create_linux_sound_page(self):
        it, page_vbox = self.new_page_box(None, _("Sound Setup"))
        #############
        # midi setup
        #############

        self.g_fakesynth_radio = gu.RadioButton(None, _("_No sound"), None)
        page_vbox.pack_start(self.g_fakesynth_radio, False, False, 0)

        ### ALSA
        self.m_gui_client_port = False
        hbox = gu.bHBox(page_vbox, False)
        self.g_alsa_radio = gu.RadioButton(self.g_fakesynth_radio,
              _("Use ALSA _device"), None)
        hbox.pack_start(self.g_alsa_radio, False, False, 0)

        self.g_alsa_device = Gtk.Button()
        self.g_alsa_device.connect('clicked', self.popup_alsa_connection_list)
        hbox.pack_start(self.g_alsa_device, False, False, 0)
        if solfege.soundcard.alsa_sequencer:
            connections = solfege.soundcard.alsa_sequencer.get_connection_list()
            for v in connections:
                if v[0:2] == self.get_list("sound/alsa-client-port"):
                    self.g_alsa_device.set_label(v[-1])
                    self.m_gui_client_port = v[0:2]
                    break
            else:
                if connections:
                    self.m_gui_client_port = connections[-1][0:2]
                    self.g_alsa_device.set_label(connections[-1][-1])
                else:
                    self.g_alsa_device.set_label("")
        else:
            self.g_alsa_device.set_sensitive(False)
            self.g_alsa_radio.set_sensitive(False)
            label = Gtk.Label(label="Disabled because the pyalsa Python module was not found.")
            label.show()
            hbox.pack_start(label, False, False, 0)
        ### OSS
        hbox = gu.bHBox(page_vbox, False)
        self.g_device_radio = gu.RadioButton(self.g_fakesynth_radio,
              _("Use OSS _device"), None)
        hbox.pack_start(self.g_device_radio, False, False, 0)

        self.g_device_file = gu.sComboBox('sound', 'device_file',
            ['/dev/sequencer', '/dev/sequencer2', '/dev/music'])
        self.g_synth_num = Gtk.SpinButton()
        self.g_synth_num.set_adjustment(Gtk.Adjustment(0, 0, 100, 1, 1))
        self.g_synth_num.set_value(self.get_int('sound/synth_number'))
        hbox.pack_start(self.g_device_file, False, False, 0)
        hbox.pack_start(self.g_synth_num, False, False, 0)

        ###
        hbox = gu.bHBox(page_vbox, False)
        self.g_midiplayer_radio = gu.RadioButton(self.g_fakesynth_radio,
             _("Use _external MIDI player"), None)
        hbox.pack_start(self.g_midiplayer_radio, False, False, 0)

        if self.get_string("sound/type") == "external-midiplayer":
            self.g_midiplayer_radio.set_active(True)
        elif self.get_string("sound/type") == "sequencer-device":
            self.g_device_radio.set_active(True)
        elif self.get_string("sound/type") == "alsa-sequencer":
            self.g_alsa_radio.set_active(True)
        else:
            self.g_fakesynth_radio.set_active(True)

        gu.bButton(page_vbox, _("_Test"), self.on_apply_and_play_test_sound, False)
    def __init__(self, exname):
        Gtk.VBox.__init__(self)
        cfg.ConfigUtils.__init__(self, exname)
        self.MAX_INT = self.get_int('maximum_number_of_intervals')
        if self.MAX_INT == 0:
            self.MAX_INT = 12
        self._watched_interval_id = None
        self._watched_interval = None
        self.m_ignore_iclick = 0
        box = gu.bHBox(self, expand=False)
        box.set_spacing(gu.PAD_SMALL)
        box.pack_start(Gtk.Label(_("Number of intervals:")), False, False, 0)
        self.g_num_int_spin = gu.nSpinButton(self.m_exname,
                       'number_of_intervals',
                       Gtk.Adjustment(1, 1, self.MAX_INT, 1, self.MAX_INT))
        self.add_watch('number_of_intervals', self.on_num_int_spin)
        box.pack_start(self.g_num_int_spin, False, False, 0)
        self.g_all_int_button = gu.bButton(box,
                  _("Configure all intervals in this exercise like this"),
                  self.configure_all_like_active_interval, expand=False)
        self.add_watch('number_of_intervals', lambda n, self=self: \
               self.g_all_int_button.set_sensitive(self.get_int(n)!=1))

        box = gu.bHBox(self, expand=False)
        box.set_spacing(gu.PAD_SMALL)
        box.pack_start(Gtk.Label(
                _("Toggle buttons are for interval number:")), False, False, 0)
        self.m_int_sel_adjustment \
             = Gtk.Adjustment(1, 1, self.get_int('number_of_intervals'), 1)
        self.g_int_sel_spin = gu.nSpinButton(self.m_exname,
                  'cur_edit_interval', self.m_int_sel_adjustment, digits=0)
        self.g_int_sel_spin.connect('changed', self.on_int_sel_spin)
        box.pack_start(self.g_int_sel_spin, False, False, 0)
        table = Gtk.Table()
        self.pack_start(table, False, False, 0)

        label = Gtk.Label(label=_("Up:"))
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0, 1, 0, 1, xpadding=gu.PAD_SMALL)
        self.g_interval_chk = {}
        V = self.get_list("ask_for_intervals_%i"
                  % (self.g_int_sel_spin.get_value_as_int()-1))
        for x in range(1, mpd.interval.max_interval + 1):
            self.g_interval_chk[x] = c = Gtk.ToggleButton(mpd.interval.short_name[x])
            if x in V:
                c.set_active(True)
            c.show()
            c.connect('clicked', self.on_interval_chk_clicked, x)
            table.attach(c, x, x+1, 0, 1)

        box = gu.bHBox(self, expand=False)
        label = Gtk.Label(label=_("Down:"))
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0, 1, 1, 2, xpadding=gu.PAD_SMALL)
        v = range(mpd.interval.min_interval, 0)
        v.reverse()
        for x in v:
            self.g_interval_chk[x] = c = Gtk.ToggleButton(mpd.interval.short_name[-x])
            if x in V:
                c.set_active(True)
            c.show()
            c.connect('clicked', self.on_interval_chk_clicked, x)
            table.attach(c, -x, -x+1, 1, 2)
        table.show_all()
        if self.g_num_int_spin.get_value_as_int() == 1:
            self.g_all_int_button.set_sensitive(False)
        gu.bButton(self, _("Reset to default values"), self.reset_to_default,
                  False, False)
        self._watch_interval(self.get_int('cur_edit_interval')-1)
Пример #31
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self._ignore_events = 0
        ##############
        # practise_box
        ##############
        self.practise_box.set_spacing(gu.PAD)
        hbox = gu.bHBox(self.practise_box)
        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.clear()
        hbox.pack_start(self.g_music_displayer)

        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False)

        hbox = gu.bHBox(self.practise_box, False)
        hbox.set_homogeneous(True)
        self.g_first_is_largest = gu.bButton(
            hbox,
            _("F_irst interval\nis largest"),
            lambda f, self=self: self.guess_answer(-1))
        self.g_first_is_largest.get_child().set_justify(gtk.JUSTIFY_CENTER)
        self.g_first_is_largest.set_sensitive(False)
        self.g_equal_size = gu.bButton(
            hbox,
            _("The intervals\nare _equal"),
            lambda f, self=self: self.guess_answer(0))
        self.g_equal_size.get_child().set_justify(gtk.JUSTIFY_CENTER)
        self.g_equal_size.set_sensitive(False)
        self.g_last_is_largest = gu.bButton(
            hbox,
            _("_Last interval\nis largest"),
            lambda f, self=self: self.guess_answer(1))
        self.g_last_is_largest.set_sensitive(False)
        self.g_last_is_largest.get_child().set_justify(gtk.JUSTIFY_CENTER)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda w, self=self: self.m_t.play_question()),
            ('repeat_first', self.m_t.play_first_interval),
            ('repeat_last', self.m_t.play_last_interval),
            ('give_up', self.give_up),
        )
        self.action_area.set_homogeneous(True)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self._add_auto_new_question_gui(self.config_box)

        # ----------------------------------------------

        def pack_rdbs(box, callback):
            D = {}
            D['harmonic'] = b = gu.RadioButton(None, _("Harmonic"), callback)
            b.set_data('idir', 'harmonic')
            box.pack_start(b, False)
            D['melodic'] = b = gu.RadioButton(b, _("Melodic"), callback)
            b.set_data('idir', 'melodic')
            box.pack_start(b, False)
            return D

        #---------
        self.g_intervalconfig_box = gu.bVBox(self.config_box, False)
        hbox = gu.bHBox(self.g_intervalconfig_box, False)
        hbox.pack_start(gtk.Label(_("First interval:")),
                        False,
                        padding=gu.PAD_SMALL)
        self.g_rdbs = [pack_rdbs(hbox, self.update_first)]
        self.g_first_interval_up = nIntervalCheckBox(self.m_exname,
                                                     'first_interval_up')
        self.g_intervalconfig_box.pack_start(self.g_first_interval_up, False)
        self.g_first_interval_down = nIntervalCheckBox(self.m_exname,
                                                       'first_interval_down')
        self.g_intervalconfig_box.pack_start(self.g_first_interval_down, False)
        #----------
        hbox = gu.bHBox(self.g_intervalconfig_box, False)
        hbox.pack_start(gtk.Label(_("Last interval:")),
                        False,
                        padding=gu.PAD_SMALL)
        self.g_rdbs.append(pack_rdbs(hbox, self.update_last))
        self.g_last_interval_up = nIntervalCheckBox(self.m_exname,
                                                    'last_interval_up')
        self.g_intervalconfig_box.pack_start(self.g_last_interval_up, False)
        self.g_last_interval_down = nIntervalCheckBox(self.m_exname,
                                                      'last_interval_down')
        self.g_intervalconfig_box.pack_start(self.g_last_interval_down, False)
        #------------
        s = self.get_string('first_interval_type')
        if not s in ('harmonic', 'melodic'):
            self.set_string('first_interval_type', 'harmonic')
        self.g_rdbs[0][self.get_string('first_interval_type')].set_active(True)
        self.update_first(
            self.g_rdbs[0][self.get_string('first_interval_type')])
        s = self.get_string('last_interval_type')
        if not s in ('harmonic', 'melodic'):
            self.set_string('last_interval_type', 'harmonic')
        self.g_rdbs[1][self.get_string('last_interval_type')].set_active(True)
        self.update_last(self.g_rdbs[1][self.get_string('last_interval_type')])
        self.config_box.show_all()
        self.add_watch('first_interval_type', self._watch_1_cb)
        self.add_watch('last_interval_type', self._watch_2_cb)