Example #1
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        self.m_key_bindings = {'backspace_ak': self.on_backspace}
        self.g_music_displayer = mpd.MusicDisplayer()
        self.practise_box.pack_start(self.g_music_displayer, False, False, 0)

        self.g_answer_button_box = gu.NewLineBox()
        self.practise_box.pack_start(self.g_answer_button_box, False, False, 0)
        # The user fill the answer in this box
        self.g_answer_frame = Gtk.Frame()
        self.g_answer_frame.set_shadow_type(Gtk.ShadowType.IN)
        self.practise_box.pack_start(self.g_answer_frame, False, False, 0)
        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, False, 0)
        # 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),
            ('backspace', self.on_backspace),
        )
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, "")
Example #2
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)
Example #3
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()
Example #4
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        self.m_stacking_frame_min_height = 0

        ###############
        # practise_box
        ###############
        self.practise_box.set_spacing(gu.PAD)

        hbox = gu.bHBox(self.practise_box, True, True)
        hbox.set_spacing(gu.PAD)
        ##################
        # chordtype frame
        ##################
        frame = Gtk.Frame(label=_("Identify chord type"))
        hbox.pack_start(frame, True, True, 0)
        self.g_chordtype_box = Gtk.VBox()
        self.g_chordtype_box.set_border_width(gu.PAD_SMALL)
        frame.add(self.g_chordtype_box)

        #################
        # stacking frame
        #################
        self.g_stacking_frame = Gtk.Frame(label=_("Chord voicing"))
        self.g_stacking_frame.set_sensitive(False)
        hbox.pack_start(self.g_stacking_frame, True, True, 0)
        vbox = Gtk.VBox()
        vbox.set_border_width(gu.PAD_SMALL)
        self.g_stacking_frame.add(vbox)
        t = Gtk.Table(1, 1, 1)
        vbox.pack_start(t, True, True, 0)
        self.g_source = Gtk.VBox()
        t.attach(self.g_source, 0, 1, 0, 1,
                 Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL)
        self.g_answer = Gtk.VBox()
        t.attach(self.g_answer, 1, 2, 0, 1,
                 Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL)
        self.g_redo = Gtk.Button("<<<")
        self.g_redo.connect('clicked',
                            lambda o, self=self: self.fill_stacking_frame())
        vbox.pack_end(self.g_redo, False, False, 0)

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

        self.std_buttons_add(
            ('new-chord', self.new_question),
            ('repeat', lambda _o: self.m_t.m_P.play_question()),
            ('repeat_arpeggio',
             lambda _o: self.m_t.m_P.play_question_arpeggio()),
            ('give_up', lambda _o, self=self: self.give_up()))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
Example #5
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, False, False, 0)
        self.g_bb = QuestionNameButtonTable(self.m_t.m_exname)
        self.practise_box.pack_start(self.g_bb, False, False, 0)

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

        self.std_buttons_add(
            ('new', self.new_question),
            ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio)),
            ('repeat_slowly', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_slowly)),
            ('play_tonic', lambda w: self.run_exception_handled(self.m_t.play_tonic)),
            ('display_music', self.show_answer),
            ('show', self.show_answer),
            ('give_up', self.give_up),
        )

        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_border_width(12)
        self.config_box.set_spacing(18)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Questions to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, False, False, 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()
        # ------------------------------------------
        self._add_auto_new_question_gui(self.config_box)
        # ----------------------------------------------
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                   _("Identify by name"))
        def _f(varname):
            self.m_t.q_status = self.QSTATUS_NO
            self.setup_action_area_buttons()
        self.add_watch('ask_for_names', _f)
Example #6
0
    def __init__(self, teacher):
        Gui.__init__(self, teacher)

        self.g_input = None

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

        self.std_buttons_add(('new-interval', self.new_question),
                             ('repeat', self.repeat_question))
        self.setup_key_bindings()
Example #7
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)
Example #8
0
 def __init__(self, teacher):
     abstract.LessonbasedGui.__init__(self, teacher)
     self.g_w = RhythmWidget()
     self.g_w.connect('score-updated', self.on_score_updated)
     self.practise_box.pack_start(self.g_w, False, False, 0)
     self.g_c = RhythmWidgetController(self.g_w)
     self.practise_box.pack_start(self.g_c, False, False, 0)
     self.g_flashbar = gu.FlashBar()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.g_flashbar.show()
     self.std_buttons_add(
         ('new', self.new_question), ('guess_answer', self.guess_answer),
         ('repeat', self.repeat_question), ('give_up', self.give_up))
     self.g_w.show()
Example #9
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        t = gtk.Table()
        self.g_buttons = fill_table(gtk.Button, t)
        for key, button in self.g_buttons.items():
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(t, False)
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.hig_dlg_vbox.spacing)
        self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic',
                                        _("Random transpose"))
        self.config_box.pack_start(self.g_random, False)
        self._add_auto_new_question_gui(self.config_box)
        #
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.config_box.pack_start(self.g_tones_category, False)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        self.g_tone_selector.show_all()
        box.pack_start(self.g_tone_selector, False)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(
            _("Cadences"))
        self.g_cadences.show()
        self.config_box.pack_start(self.g_cadences_category, False)

        #
        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                #self.on_end_practise()
                #self.on_start_practise()
                self.cancel_question()

        self.add_watch('tones', _ff)
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                    _("Tone in cadence"))
Example #10
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()
Example #11
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.practise_box.set_spacing(gu.PAD)
        self.m_buttons = []
        vbox = gu.bVBox(self.practise_box, False)
        for s, e in ((0, 9), (9, 18), (18, 26), (26, 34)):
            box = Gtk.HBox()
            vbox.pack_start(box, True, True, 0)
            for i in range(s, e):
                bpm = self.m_t.m_bpms[i]
                button = Gtk.Button(str(bpm))
                box.pack_start(button, True, True, 0)
                button.connect('clicked', self.on_click)
                button.connect('button-release-event', self.on_event)
                button.m_bpm = bpm
                self.m_buttons.append(button)

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

        self.std_buttons_add(
            ('new', self.on_new),
            ('repeat', self.on_repeat),
            ('give_up', self.on_give_up)
        )
        self.practise_box.show_all()
        ##############
        # statistics #
        ##############
        self.g_statview = statisticsviewer.StatisticsViewer(self.m_t.m_statistics, _('Bpm'))
        self.g_statview.show()
        self.g_notebook.append_page(self.g_statview,
                                    Gtk.Label(label=_("Statistics")))
        ########
        # init #
        ########
        self.g_notebook.get_nth_page(1).hide()
        self.update_buttons()
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        # This module was marked as deprecated in solfege 3.15.
        # Let us remove it in 3.18
        self.add_module_is_deprecated_label()
        self.g_music_displayer = mpd.MusicDisplayer()
        self.practise_box.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)
        self.practise_box.set_spacing(gu.PAD)

        self.g_entry = Gtk.Entry()
        self.g_entry.set_activates_default(True)
        self.g_entry.connect('changed', self.on_entry_changed)
        self.practise_box.pack_start(self.g_entry, False)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('play_tonic',
             lambda w: self.run_exception_handled(self.m_t.play_tonic)),
            ('show', self.show_answer), ('give_up', self.give_up),
            ('guess_answer', self.guess_answer))
        self.g_guess_answer.set_can_default(True)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_random_transpose_gui()
        self._add_auto_new_question_gui(self.config_box)
        # ----------------------------------------------

        ###############
        # statistics
        ###############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                    _("Harmonic progression dictation"))
Example #13
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_contents = Gtk.Table()
        hbox = gu.bHBox(self.practise_box, True, False)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        hbox.pack_start(self.g_contents, True, True, 0)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        self.g_contents.set_col_spacings(gu.PAD)
        self.g_contents.set_row_spacings(gu.PAD)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        self.g_contents.attach(self.g_music_displayer, 1, 2, 1, 2)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat',
             lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(
                self.m_t.m_P.play_question_arpeggio)),
            ('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()
Example #14
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()
Example #15
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     ################
     # practice_box #
     ################
     self.std_buttons_add(
         ('new', None),  # add callback
         ('give_up', self.give_up),
     )
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.practise_box.set_spacing(gu.PAD)
     ###############
     # config_grid #
     ###############
     self._add_auto_new_question_gui(row=0)
     # ----------------------------------------------
     self.config_grid.show_all()
     ##############
     # statistics #
     ##############
     self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                 "Statistics for this example exercise")
Example #16
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)

        self.g_percentage = gu.bLabel(self.practise_box, "")
        self.g_percentage.set_name("Heading1")
        self.g_piano = inputwidgets.PianoOctaveWithAccelName(
            self.on_answer_from_user, self.get_accel_key_list())
        self.g_piano.m_visible_accels = not self.get_bool('hide_piano_accels')

        def update_accels(*ignore):
            self.g_piano.m_keys = self.get_accel_key_list()
            self.g_piano.queue_draw()

        for notename in mpd.MusicalPitch.notenames:
            self.add_watch('tone_%s_ak' % notename, update_accels)
        self.practise_box.pack_start(self.g_piano, True, True, 0)

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

        self.std_buttons_add(
            ('new-tone', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.g_config_elems = gu.bVBox(self.config_box, False)
        table = Gtk.Table()
        table.set_border_width(gu.PAD_SMALL)
        frame = Gtk.Frame(label=_("Weight"))
        self.g_config_elems.pack_start(frame, False, False, 0)
        frame.add(table)
        for x, n in [(1, 'cis'), (3, 'dis'), (7, 'fis'), (9, 'gis'),
                     (11, 'ais')]:
            label = Gtk.Label(label=mpd.MusicalPitch.new_from_notename(
                n).get_user_notename())
            label.set_name("Heading2")
            label.set_alignment(0.2, 1.0)
            table.attach(label,
                         x,
                         x + 2,
                         0,
                         1,
                         xoptions=Gtk.AttachOptions.FILL)
            b = gu.nSpinButton(self.m_exname,
                               n + "_weight",
                               Gtk.Adjustment(1, 0, 1000, 1, 10),
                               digits=0)
            table.attach(b, x, x + 2, 1, 2, xoptions=Gtk.AttachOptions.FILL)
        for x, n in [(0, 'c'), (2, 'd'), (4, 'e'), (6, 'f'), (8, 'g'),
                     (10, 'a'), (12, 'b')]:
            label = Gtk.Label(label=mpd.MusicalPitch.new_from_notename(
                n).get_user_notename())
            label.set_name("Heading2")
            label.set_alignment(0.35, 1.0)
            table.attach(label,
                         x,
                         x + 2,
                         2,
                         3,
                         xoptions=Gtk.AttachOptions.FILL)
            b = gu.nSpinButton(self.m_exname,
                               n + "_weight",
                               Gtk.Adjustment(1, 0, 1000, 1, 10),
                               digits=0)
            table.attach(b, x, x + 2, 3, 4, xoptions=Gtk.AttachOptions.FILL)

        hbox = gu.bHBox(self.g_config_elems, False)
        hbox.pack_start(Gtk.Label(_("Octave:")), False, False, padding=4)
        for oct in self.m_t.OCTAVES:
            b = gu.nCheckButton(self.m_exname,
                                "octave" + str(oct),
                                str(oct),
                                default_value=1)
            hbox.pack_start(b, False, False, 0)
        #############
        self._add_auto_new_question_gui(self.config_box)
        #############
        b = gu.nCheckButton('idtone', 'hide_piano_accels',
                            _("Hide _piano keyboard shortcuts"), False)

        def show_hide_accels(checkbutton):
            self.g_piano.m_visible_accels = not b.get_active()

        b.connect('clicked', show_hide_accels)
        self.config_box.pack_start(b, False, False, 0)
        #
        frame = Gtk.Frame(label=_("When you guess wrong"))
        vbox = Gtk.VBox()
        vbox.set_border_width(gu.PAD_SMALL)
        frame.add(vbox)
        vbox.pack_start(
            gu.nCheckButton(self.m_exname, "warning_sound",
                            _("Play warning sound")), False, False, 0)
        self.config_box.pack_start(frame, False, False, 0)
        self.config_box.show_all()
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                    _("Identify tone"))
Example #17
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.g_buttongrid = grid = Gtk.Grid()
        grid.set_row_spacing(gu.hig.SPACE_SMALL)
        grid.set_column_spacing(gu.hig.SPACE_SMALL)
        self.g_buttons = fill_grid(Gtk.Button, grid,
                                   labels[self.get_int("labels")][1])
        for key, button in list(self.g_buttons.items()):
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(grid, False, False, gu.hig.SPACE_SMALL)
        #########################################
        # GUI to practise what is answered wrong
        self.g_wgrid = Gtk.Grid()
        self.g_wgrid.set_row_spacing(gu.hig.SPACE_SMALL)
        self.g_wgrid.set_column_spacing(gu.hig.SPACE_SMALL)

        self.g_wgrid.attach(
            Gtk.Label(_("You answered:"), halign=Gtk.Align.END), 0, 1, 1, 1)
        self.g_wrong = Gtk.Label()
        self.g_wgrid.attach(self.g_wrong, 1, 1, 1, 1)
        b = Gtk.Button(_("Play cadence and tone"))
        b.connect('clicked', lambda w: self.m_t.play_wrong_guess())
        self.g_wgrid.attach(b, 2, 1, 1, 1)
        b = Gtk.Button(_("Play tone"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_tone(self.m_t.m_guessed)))
        self.g_wgrid.attach(b, 3, 1, 1, 1)
        b = Gtk.Button(_("Play tone with solution"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_solution(self.m_t.m_guessed)))
        self.g_wgrid.attach(b, 4, 1, 1, 1)

        self.g_wgrid.attach(
            Gtk.Label(_("Correct answer:"), halign=Gtk.Align.END), 0, 2, 1, 1)
        self.g_correct = Gtk.Label()
        self.g_wgrid.attach(self.g_correct, 1, 2, 1, 1)
        b = Gtk.Button(_("Play cadence and tone"))
        b.connect('clicked', lambda w: self.m_t.play_question())
        self.g_wgrid.attach(b, 2, 2, 1, 1)
        b = Gtk.Button(_("Play tone"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_tone(self.m_t.m_tone)))
        self.g_wgrid.attach(b, 3, 2, 1, 1)
        b = Gtk.Button(_("Play tone with solution"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_solution(self.m_t.m_tone)))
        self.g_wgrid.attach(b, 4, 2, 1, 1)
        l = Gtk.Label(
            _("You should listen to both tones several times and try to hear the difference and the similarity between the tones."
              ))
        self.g_wgrid.attach(l, 0, 3, 4, 1)
        b = Gtk.Button(_("Play cadence"))

        def play_cadence(*w):
            solfege.soundcard.synth.play_track(self.m_t.get_track_of_cadence())

        b.connect('clicked', play_cadence)
        self.g_wgrid.attach(b, 0, 4, 3, 1)
        b = Gtk.Button(_("Done"))

        def done(*w):
            self.end_practise_wrong_answer()
            self.new_question()

        b.connect('clicked', done)
        self.g_wgrid.attach(b, 3, 4, 2, 1)
        l.set_line_wrap(True)
        l.set_max_width_chars(40)
        self.practise_box.pack_start(self.g_wgrid, False, False, 0)
        ###########
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()))
        self.practise_box.show_all()
        self.g_wgrid.hide()
        ###############
        # config_grid #
        ###############
        # FIXME we need a ComboBox
        # self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic', _("Random transpose"))
        # self.g_config_grid.attach(self.g_random, 0, 0, 1, 1)
        #
        self.g_config_grid.set_column_homogeneous(True)
        # Let us say the grid has 8 columns
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.g_config_grid.attach(self.g_tones_category, 0, 2, 8, 1)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        box.pack_start(self.g_tone_selector, False, False, 0)
        self.g_many_octaves = b = gu.nCheckButton('toneincontext',
                                                  'many_octaves',
                                                  _("Many octaves"))
        self.g_config_grid.attach(b, 0, 3, 4, 1)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(
            _("Cadences"))
        self.g_config_grid.attach(self.g_cadences_category, 0, 4, 4, 1)

        #

        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                # self.on_end_practise()
                # self.on_start_practise()
                self.cancel_question()

        self.add_watch('tones', _ff)

        # Tempo the music is played
        self.g_config_grid.attach(Gtk.Label("BPM:"), 0, 5, 1, 1)
        min_bpm, max_bpm = 30, 250
        scale = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, min_bpm,
                                         max_bpm, 10)
        scale.set_value_pos(Gtk.PositionType.LEFT)
        if not (min_bpm < self.m_t.get_int("bpm") < max_bpm):
            self.m_t.set_int("bpm", 90)
        scale.set_value(self.m_t.get_int("bpm"))

        def scale_value_changed(scale):
            self.m_t.set_int("bpm", int(scale.get_value()))

        scale.connect('value-changed', scale_value_changed)
        self.g_config_grid.attach(scale, 1, 5, 7, 1)

        # Select answer button labels
        combo = gu.nComboBox(self.m_t.m_exname, 'labels', labels[0][0],
                             [n[0] for n in labels])
        self.g_config_grid.attach(combo, 1, 6, 7, 1)
        combo.connect('changed', self.update_tone_button_labels)

        self.g_config_grid.show_all()
        ##############
        # Statistics #
        ##############
        self.g_statview = StatisticsViewer(self.m_t)
        self.g_statview.show()
        self.g_notebook.append_page(self.g_statview,
                                    Gtk.Label(label=_("Statistics")))
        self.g_notebook.connect('switch_page', self.g_statview.update)
Example #18
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)