示例#1
0
 def add_select_num_beats_gui(self):
     ###
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = Gtk.Label(label=_("Number of beats in question:"))
     hbox.pack_start(label, False, False, 0)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(
         gu.nSpinButton(self.m_exname, "num_beats",
                        Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0)
     self.config_box.pack_start(hbox, False, False, 0)
     hbox.show_all()
     #
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = Gtk.Label(label=_("Count in before question:"))
     hbox.pack_start(label, False, False, 0)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(
         gu.nSpinButton(self.m_exname, "count_in",
                        Gtk.Adjustment(2, 0, 10, 1, 10)), False, False, 0)
     hbox.show_all()
     self.config_box.pack_start(hbox, False, False, 0)
示例#2
0
    def create_midi_config(self):
        it, page_vbox = self.new_page_box(None, _("Instruments"))
        vbox, category_vbox = gu.hig_category_vbox(_("Tempo"))
        page_vbox.pack_start(vbox, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        tempo_hbox = Gtk.Box(spacing=6)
        self.g_default_bpm = gu.nSpinButton(
            'config', 'default_bpm',
            Gtk.Adjustment(self.get_int('config/default_bpm'), 10, 500, 1, 10))
        self.g_arpeggio_bpm = gu.nSpinButton(
            'config', 'arpeggio_bpm',
            Gtk.Adjustment(self.get_int('config/arpeggio_bpm'), 10, 500, 1,
                           10))
        for text, widget in [(_("_Default:"), self.g_default_bpm),
                             (_("A_rpeggio:"), self.g_arpeggio_bpm)]:
            label = Gtk.Label(_("BPM"))
            tempo_hbox.pack_start(
                gu.hig_label_widget(text, [widget, label], None), False, False,
                0)
            label.set_tooltip_text(_("Beats per minute"))
        category_vbox.pack_start(tempo_hbox, False, False, 0)

        box, category_vbox = gu.hig_category_vbox(_("Preferred Instrument"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_instrsel = nInstrumentSelector('config', 'preferred_instrument',
                                              None)
        category_vbox.pack_start(self.g_instrsel, False, False, 0)

        box, category_vbox = gu.hig_category_vbox(_("Chord Instruments"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_instrument_configurator  \
              = InstrumentConfigurator("config", 3,
                    _("Use different instruments for chords and harmonic intervals"))
        category_vbox.pack_start(self.g_instrument_configurator, False, False,
                                 0)

        vbox, category_box = gu.hig_category_vbox(_("Percussion Instruments"))
        page_vbox.pack_start(vbox, False, False, 0)
        category_box.pack_start(
            gu.hig_label_widget(
                _("Count in:"),
                gu.PercussionNameButton("config", "countin_perc", "Claves"),
                sizegroup, True, True), True, True, 0)
        category_box.pack_start(
            gu.hig_label_widget(
                _("Rhythm:"),
                gu.PercussionNameButton("config", "rhythm_perc", "Side Stick"),
                sizegroup, True, True), False, False, 0)
示例#3
0
    def create_midi_config(self):
        it, page_vbox = self.new_page_box(None, _("Instruments"))
        vbox, category_vbox = gu.hig_category_vbox(_("Tempo"))
        page_vbox.pack_start(vbox, False)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        tempo_hbox = gtk.HBox(spacing=6)
        self.g_default_bpm = gu.nSpinButton('config', 'default_bpm',
            gtk.Adjustment(self.get_int('config/default_bpm'), 10, 500, 1, 10))
        self.g_arpeggio_bpm = gu.nSpinButton('config', 'arpeggio_bpm',
            gtk.Adjustment(self.get_int('config/arpeggio_bpm'), 10, 500, 1, 10))
        for text, widget in [(_("_Default:") ,self.g_default_bpm),
                             (_("A_rpeggio:") ,self.g_arpeggio_bpm)]:
            label = gtk.Label(text)
            label.set_alignment(0.0, 0.5)
            label.set_use_underline(True)
            tempo_hbox.pack_start(label, expand=False)
            label.set_mnemonic_widget(widget)
            tempo_hbox.pack_start(widget, expand=False)
            label = gtk.Label(_("BPM"))
            label.set_alignment(0.0, 0.5)
            label.set_tooltip_text(_("Beats per minute"))
            tempo_hbox.pack_start(label, expand=True)
        category_vbox.pack_start(tempo_hbox, False)

        box, category_vbox = gu.hig_category_vbox(_("Preferred Instrument"))
        page_vbox.pack_start(box, False)
        self.g_instrsel = nInstrumentSelector('config',
                        'preferred_instrument', sizegroup)
        category_vbox.pack_start(self.g_instrsel, False)

        box, category_vbox = gu.hig_category_vbox(_("Chord Instruments"))
        page_vbox.pack_start(box, False)
        self.g_instrument_configurator  \
              = InstrumentConfigurator("config", 3,
                    _("Use different instruments for chords and harmonic intervals"))
        category_vbox.pack_start(self.g_instrument_configurator, False)

        vbox, category_box = gu.hig_category_vbox(_("Percussion Instruments"))
        page_vbox.pack_start(vbox, False)
        category_box.pack_start(gu.hig_label_widget(
            _("Count in:"),
            gu.PercussionNameButton("config", "countin_perc", "Claves"),
            sizegroup, True, True))
        category_box.pack_start(gu.hig_label_widget(
            _("Rhythm:"),
            gu.PercussionNameButton("config", "rhythm_perc", "Side Stick"),
            sizegroup, True, True))
示例#4
0
 def add_select_num_notes_gui(self, row):
     label = Gtk.Label(label=_("Number of tones:"))
     label.set_alignment(1.0, 0.5)
     self.g_config_grid.attach(label, 0, row, 1, 1)
     self.g_config_grid.attach(
         gu.nSpinButton(self.m_exname, "num_notes",
                        Gtk.Adjustment(4, 1, 100, 1, 10)), 1, row, 1, 1)
示例#5
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()
示例#6
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()
示例#7
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)
示例#8
0
 def add_select_num_beats_gui(self, grid, row):
     ###
     label = Gtk.Label(label=_("Number of beats in question:"))
     label.props.halign = Gtk.Align.END
     label.show()
     grid.attach(label, 0, row, 1, 1)
     grid.attach(gu.nSpinButton(self.m_exname, "num_beats",
                                Gtk.Adjustment(4, 1, 100, 1, 10)),
                 1, row, 1, 1)
     #
     label = Gtk.Label(label=_("Count in before question:"))
     label.props.halign = Gtk.Align.END
     label.show()
     grid.attach(label, 0, row + 1, 1, 1)
     grid.attach(gu.nSpinButton(self.m_exname, "count_in",
                                Gtk.Adjustment(2, 0, 10, 1, 10)),
                 1, row + 1, 1, 1)
 def add_select_num_notes_gui(self, row):
     label = Gtk.Label(label=_("Number of tones:"))
     label.set_alignment(1.0, 0.5)
     self.g_config_grid.attach(label, 0, row, 1, 1)
     self.g_config_grid.attach(
         gu.nSpinButton(self.m_exname, "num_notes",
                        Gtk.Adjustment(4, 1, 100, 1, 10)),
         1, row, 1, 1)
示例#10
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.m_key_bindings = {'backspace_ak': self.on_backspace}
        self.g_answer_box = Gtk.VBox()
        self.answer_buttons = []
        self.m_answer_buttons = {}

        #-------
        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, 0)
        self.practise_box.pack_start(Gtk.HBox(), False, False,
                                     padding=gu.PAD_SMALL)
        self.g_rhythm_viewer = RhythmViewer(self)
        self.g_rhythm_viewer.create_holders()
        hbox.pack_start(self.g_rhythm_viewer, True, True, 0)

        self.practise_box.pack_start(self.g_answer_box, False, False, 0)

        # action area
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', self.repeat_question),
            #('play_answer', self.play_users_answer),
            ('give_up', self.give_up),
            ('backspace', self.on_backspace))

        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_select_elements_gui()
        #--------
        self.config_box.pack_start(Gtk.HBox(), False, False,
                                   padding=gu.PAD_SMALL)
        self.add_select_num_notes_gui()
        #-----
        self.config_box.pack_start(Gtk.HBox(), False, False,
                                   padding=gu.PAD_SMALL)
        #------
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        hbox.pack_start(Gtk.Label(_("Beats per minute:")), False, False, 0)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                 Gtk.Adjustment(60, 20, 240, 1, 10))
        hbox.pack_start(spin, False, False, 0)
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                                        "show_first_note",
                                        _("Show the first tone")), False, False, 0)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                                        "play_cadence",
                                        _("Play cadence")), False, False, 0)
        self._add_auto_new_question_gui(self.config_box)
        self.config_box.show_all()
示例#11
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, False, 0)
        #-------
        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, 0)
        self.practise_box.pack_start(Gtk.HBox(False, 0),
                                     False,
                                     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, True, True, 0)

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

        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_select_elements_gui()
        #--------
        self.config_box.pack_start(Gtk.HBox(False, 0),
                                   False,
                                   False,
                                   padding=gu.PAD_SMALL)
        self.add_select_num_beats_gui()
        #-----
        self.config_box.pack_start(Gtk.HBox(False, 0),
                                   False,
                                   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,
            False, 0)
        sep = Gtk.VSeparator()
        hbox.pack_start(sep, False, False, 0)
        hbox.pack_start(Gtk.Label(_("Beats per minute:")), False, False, 0)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                              Gtk.Adjustment(60, 20, 240, 1, 10))
        hbox.pack_start(spin, False, False, 0)
        self._add_auto_new_question_gui(self.config_box)
        self.config_box.show_all()
示例#12
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.m_key_bindings = {'backspace_ak': self.on_backspace}
        self.g_answer_box = gtk.VBox()
        self.answer_buttons = []

        #-------
        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)
        self.g_rhythm_viewer.create_holders()
        hbox.pack_start(self.g_rhythm_viewer)

        self.practise_box.pack_start(self.g_answer_box, False)

        # action area
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', self.repeat_question),
            #('play_answer', self.play_users_answer),
            ('give_up', self.give_up),
            ('backspace', self.on_backspace))

        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_notes_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(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)
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                                        "show_first_note",
                                        _("Show the first tone")), False)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                                        "play_cadence",
                                        _("Play cadence")), False)
        self._add_auto_new_question_gui(self.config_box)
        self.config_box.show_all()
示例#13
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()
 def add_select_num_notes_gui(self):
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = Gtk.Label(label=_("Number of tones:"))
     hbox.pack_start(label, False, False, 0)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(gu.nSpinButton(self.m_exname, "num_notes",
                                    Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0)
     self.config_box.pack_start(hbox, False, False, 0)
     hbox.show_all()
     self.config_box.pack_start(hbox, False, False, 0)
 def add_select_num_notes_gui(self):
     hbox = gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = gtk.Label(_("Number of tones:"))
     hbox.pack_start(label, False)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(gu.nSpinButton(self.m_exname, "num_notes",
                                    gtk.Adjustment(4, 1, 100, 1, 10)), False)
     self.config_box.pack_start(hbox, False)
     hbox.show_all()
     self.config_box.pack_start(hbox, False)
示例#16
0
 def add_select_num_beats_gui(self):
     ###
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = Gtk.Label(label=_("Number of beats in question:"))
     hbox.pack_start(label, False, False, 0)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(gu.nSpinButton(self.m_exname, "num_beats",
                  Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0)
     self.config_box.pack_start(hbox, False, False, 0)
     hbox.show_all()
     #
     hbox = Gtk.HBox()
     hbox.set_spacing(gu.hig.SPACE_SMALL)
     label = Gtk.Label(label=_("Count in before question:"))
     hbox.pack_start(label, False, False, 0)
     self.config_box_sizegroup.add_widget(label)
     label.set_alignment(1.0, 0.5)
     hbox.pack_start(gu.nSpinButton(self.m_exname, "count_in",
                  Gtk.Adjustment(2, 0, 10, 1, 10)), False, False, 0)
     hbox.show_all()
     self.config_box.pack_start(hbox, False, False, 0)
示例#17
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, False, 0)
        #-------
        hbox = gu.bHBox(self.practise_box, False)
        b = Gtk.Button(_("Play"))
        b.show()
        b.connect('clicked', self.play_users_answer)
        hbox.pack_start(b, False, True, 0)
        self.practise_box.pack_start(Gtk.HBox(False, 0), False, 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, True, True, 0)

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

        self.practise_box.show_all()
        ###############
        # config_grid #
        ###############
        self.add_select_elements_gui(self.g_config_grid, 0)
        #--------
        self.add_select_num_beats_gui(self.g_config_grid, 1)
        #-----
        self.g_config_grid.attach(
                gu.nCheckButton(self.m_exname,
                 "not_start_with_rest",
                 _("Don't start the question with a rest")),
                0, 3, 1, 1)
        label = Gtk.Label(_("Beats per minute:"))
        label.props.halign = Gtk.Align.END
        self.g_config_grid.attach(label, 0, 4, 1, 1)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                 Gtk.Adjustment(60, 20, 240, 1, 10))
        self.g_config_grid.attach(spin, 1, 4, 1, 1)
        self._add_auto_new_question_gui(row=5)
        self.g_config_grid.show_all()
示例#18
0
 def _add_auto_new_question_gui(self, box):
     hbox = gu.bHBox(box, False)
     hbox.set_spacing(gu.PAD_SMALL)
     adj = Gtk.Adjustment(0, 0, 10, 0.1, 1)
     spin = gu.nSpinButton(self.m_exname, 'seconds_before_new_question',
                    adj)
     spin.set_digits(1)
     label = Gtk.Label(label=_("Delay (seconds):"))
     label.show()
     def f(button, spin=spin, label=label):
         spin.set_sensitive(button.get_active())
         label.set_sensitive(button.get_active())
     b = gu.nCheckButton(self.m_exname, 'new_question_automatically',
                         _("_New question automatically."), callback=f)
     hbox.pack_start(b, False, False, 0)
     label.set_sensitive(b.get_active())
     hbox.pack_start(label, False, False, 0)
     spin.set_sensitive(b.get_active())
     hbox.pack_start(spin, False, False, 0)
示例#19
0
 def _add_auto_new_question_gui(self, box):
     hbox = gu.bHBox(box, False)
     hbox.set_spacing(gu.PAD_SMALL)
     adj = gtk.Adjustment(0, 0, 10, 0.1, 1)
     spin = gu.nSpinButton(self.m_exname, 'seconds_before_new_question',
                    adj)
     spin.set_digits(1)
     label = gtk.Label(_("Delay (seconds):"))
     label.show()
     def f(button, spin=spin, label=label):
         spin.set_sensitive(button.get_active())
         label.set_sensitive(button.get_active())
     b = gu.nCheckButton(self.m_exname, 'new_question_automatically',
                         _("_New question automatically."), callback=f)
     hbox.pack_start(b, False)
     label.set_sensitive(b.get_active())
     hbox.pack_start(label, False)
     spin.set_sensitive(b.get_active())
     hbox.pack_start(spin, False)
示例#20
0
    def _add_auto_new_question_gui(self, row):
        """
        Add the user interface used to configure if we should get a new
        question automatically. The GUI is added to self.g_config_grid
        at the row set by the ROW variable.
        """
        adj = Gtk.Adjustment(0, 0, 10, 0.1, 1)
        spin = gu.nSpinButton(self.m_exname, 'seconds_before_new_question',
                       adj)
        spin.set_digits(1)
        label = Gtk.Label(label=_("seconds delay"))
        label.props.halign = Gtk.Align.START

        def f(button, spin=spin, label=label):
            spin.set_sensitive(button.get_active())
            label.set_sensitive(button.get_active())
        b = gu.nCheckButton(self.m_exname, 'new_question_automatically',
                            _("_New question automatically"), callback=f)
        b.props.halign = Gtk.Align.END
        label.set_sensitive(b.get_active())
        spin.set_sensitive(b.get_active())
        self.g_config_grid.attach(b, 0, row, 1, 1)
        self.g_config_grid.attach(spin, 1, row, 1, 1)
        self.g_config_grid.attach(label, 2, row, 1, 1)
    def __init__(self, exname, grid, x, y):
        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._children = []
        self.m_ignore_iclick = 0
        #####
        l = Gtk.Label(_("Number of intervals:"))
        self._children.append(l)
        l.props.halign = Gtk.Align.END
        grid.attach(l, x, y, 1, 1)
        #####
        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._children.append(self.g_num_int_spin)
        self.add_watch('number_of_intervals', self.on_num_int_spin)
        grid.attach(self.g_num_int_spin, x + 1, y, 1, 1)
        #####
        self.g_all_int_button = Gtk.Button(
            _("Configure all intervals like this"))
        self._children.append(self.g_all_int_button)
        self.g_all_int_button.connect('clicked',
                                      self.configure_all_like_active_interval)
        grid.attach(self.g_all_int_button, x + 2, y, 1, 1)
        self.add_watch('number_of_intervals',
                       lambda n, self=self: self.g_all_int_button.
                       set_sensitive(self.get_int(n) != 1))
        #####
        l = Gtk.Label(_("Toggle buttons are for interval number:"))
        self._children.append(l)
        l.props.halign = Gtk.Align.END
        grid.attach(l, x, y + 1, 1, 1)
        #####
        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._children.append(self.g_int_sel_spin)
        self.g_int_sel_spin.connect('changed', self.on_int_sel_spin)
        grid.attach(self.g_int_sel_spin, x + 1, y + 1, 1, 1)
        #####
        g = Gtk.Grid()
        self._children.append(g)
        grid.attach(g, x, y + 2, 3, 1)

        label = Gtk.Label(_("Up:"))
        label.props.halign = Gtk.Align.END
        g.attach(label, 0, 0, 1, 1)
        self.g_interval_chk = {}
        for i in range(1, mpd.interval.max_interval + 1):
            self.g_interval_chk[i] = c = Gtk.ToggleButton(
                mpd.interval.short_name[i])
            c.set_name("intervalToggleButton")
            c.set_active(True)
            c.connect('clicked', self.on_interval_chk_clicked, i)
            g.attach(c, i, 0, 1, 1)

        label = Gtk.Label(_("Down:"))
        label.props.halign = Gtk.Align.END
        g.attach(label, 0, 1, 1, 1)
        v = list(range(mpd.interval.min_interval, 0))
        v.reverse()
        for i in v:
            self.g_interval_chk[i] = c = Gtk.ToggleButton(
                mpd.interval.short_name[-i])
            c.set_name("intervalToggleButton")
            c.set_active(True)
            c.connect('clicked', self.on_interval_chk_clicked, i)
            g.attach(c, -i, 1, 1, 1)
        self.show()
        if self.g_num_int_spin.get_value_as_int() == 1:
            self.g_all_int_button.set_sensitive(False)
        ######
        b = Gtk.Button(_("Reset to default values"))
        self._children.append(b)
        grid.attach(b, x, y + 3, 4, 1)
        b.connect('clicked', self.reset_to_default)
        self._watch_interval(self.get_int('cur_edit_interval') - 1)
示例#22
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_grid #
        ###############
        table = Gtk.Table()
        table.set_border_width(gu.PAD_SMALL)
        self.g_tones_frame = frame = Gtk.Frame(label=_("Weight"))
        self.g_config_grid.attach(frame, 0, 0, 3, 1)
        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)

        self.g_octaves_select = hbox = Gtk.HBox()
        self.g_config_grid.attach(hbox, 0, 1, 3, 1)
        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(row=4)
        #############
        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.g_config_grid.attach(b, 0, 2, 1, 1)
        #
        self.g_config_grid.attach(gu.nCheckButton(self.m_exname,
                    "warning_sound",
                    _("Play warning sound when you guess wrong")),
                0, 3, 1, 1)
        self.g_config_grid.show_all()
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                   _("Identify tone"))
示例#23
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"))
    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)