예제 #1
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()
예제 #2
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()
예제 #3
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)
예제 #4
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)
예제 #5
0
 def __init__(self, heading, st_data, st):
     """
     st_data is the statistics data we want displayled
     st is the statistics object the statistics are collected from.
     """
     gtk.VBox.__init__(self)
     label = gtk.Label(heading)
     label.set_name("StatisticsH2")
     label.set_alignment(0.0, 0.0)
     self.pack_start(label, False)
     hbox = gu.bHBox(self, False)
     frame = gtk.Frame()
     hbox.pack_start(frame, False)
     t = gtk.Table()
     frame.add(t)
     keys = st.get_keys(True)
     for x in range(len(keys)):
         t.attach(gtk.VSeparator(), x*2+1, x*2+2, 0, len(keys)*2)
     for x in range(len(keys)-1):
         t.attach(gtk.HSeparator(), 0, len(keys)*2+1, x*2+1, x*2+2)
     for y, key in enumerate(keys):
         l = lessonfilegui.new_labelobject(st.key_to_pretty_name(key))
         l.set_alignment(0.0, 0.5)
         t.attach(l, 0, 1, y*2, y*2+1, xpadding=gu.PAD)
         for x, skey in enumerate(keys):
             try:
                 s = st_data[key][skey]
             except KeyError:
                 s = '-'
             l = gtk.Label(s)
             if x == y:
                 l.set_name('BoldText')
             t.attach(l, x*2+2, x*2+3, y*2, y*2+1, xpadding=gu.PAD)
     self.show_all()
예제 #6
0
    def __init__(self, exname, name, sizegroup):
        Gtk.VBox.__init__(self)
        cfg.ConfigUtils.__dict__['__init__'](self, exname)
        self.m_name = name
        hbox = gu.bHBox(self)
        hbox.set_spacing(gu.PAD_SMALL)

        self.g_button = Gtk.Button(
              soundcard.instrument_names[self.get_int(self.m_name)])
        self.g_button.connect('clicked', self.on_btnclick)
        hbox.pack_start(self.g_button, True, True, 0)
        g = Gtk.VolumeButton()
        g.props.value = self.get_int('%s_volume' % name) / MAX_VOLUME

        def ff(volumebutton, value):
            self.set_int('%s_volume' % name, int(value * MAX_VOLUME))
        g.connect('value-changed', ff)
        hbox.pack_start(g, False, False, 0)

        self.g_menu = MidiInstrumentMenu(self.on_instrument_selected)
        self.m_instrument = self.get_int('preferred_instrument')

        hbox = Gtk.HBox()
        hbox.set_spacing(6)
        self.pack_start(hbox, True, True, 0)
예제 #7
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)
예제 #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.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()
예제 #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_grid #
        ###############
        self.add_select_elements_gui(row=0)
        #--------
        self.add_select_num_notes_gui(row=1)
        #-----
        self.g_config_grid.attach(Gtk.Label(_("Beats per minute:")),
            0, 2, 1, 1)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                 Gtk.Adjustment(60, 20, 240, 1, 10))
        self.g_config_grid.attach(spin, 1, 2, 1, 1)
        self.g_config_grid.attach(
           gu.nCheckButton(self.m_exname,
                           "show_first_note",
                           _("Show the first tone")),
           0, 3, 1, 1)
        self.g_config_grid.attach(gu.nCheckButton(self.m_exname,
                                        "play_cadence",
                                        _("Play cadence")),
                                  0, 4, 1, 1)
        self._add_auto_new_question_gui(row=5)
        self.g_config_grid.show_all()
예제 #11
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()
예제 #12
0
    def add_random_transpose_gui(self):
        self.g_random_transpose_box = hbox = gu.bHBox(self.config_box, False, False)
        label = Gtk.Label(label=_("Random transpose:"))
        label.show()
        hbox.pack_start(label, False, False, 0)
        hbox.set_spacing(6)
        self.g_random_transpose = Gtk.Label()
        self.g_random_transpose.show()
        hbox.pack_start(self.g_random_transpose, True, True, 0)

        button = Gtk.Button(_("Change ..."))
        button.show()
        button.connect('clicked', self.run_random_transpose_dialog)
        hbox.pack_start(button, True, True, 0)
예제 #13
0
    def add_random_transpose_gui(self):
        self.g_random_transpose_box = hbox = gu.bHBox(self.config_box, False, False)
        label = gtk.Label(_("Random transpose:"))
        label.show()
        hbox.pack_start(label, False)
        hbox.set_spacing(6)
        self.g_random_transpose = gtk.Label()
        self.g_random_transpose.show()
        hbox.pack_start(self.g_random_transpose)

        button = gtk.Button(_("Change ..."))
        button.show()
        button.connect('clicked', self.run_random_transpose_dialog)
        hbox.pack_start(button)
예제 #14
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()
예제 #15
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"))
예제 #16
0
파일: chord.py 프로젝트: yuanyelele/solfege
    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 _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)
예제 #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 __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 create_mainwin_ui(self):
        qbox = gu.hig_dlg_vbox()
        self.g_notebook.append_page(qbox, Gtk.Label(label=_("Questions")))
        gu.bLabel(qbox, _("Enter new chords using the mouse"), False, False)
        hbox = gu.bHBox(qbox, False, False)
        self.g_displayer = mpd.musicdisplayer.ChordEditor()
        self.g_displayer.connect('clicked', self.on_displayer_clicked)
        self.g_displayer.clear(2)
        gu.bLabel(hbox, "")
        hbox.pack_start(self.g_displayer, False)
        gu.bLabel(hbox, "")
        ##
        self.g_question_name = Gtk.Entry()
        qbox.pack_start(gu.hig_label_widget(_("Question title:", True, True, 0), self.g_question_name, None), False)
        self.g_navinfo = Gtk.Label(label="")
        qbox.pack_start(self.g_navinfo, False)

        ##
        self.m_P = EditorLessonfile()
        cvbox = Gtk.VBox()
        self.g_notebook.append_page(cvbox, Gtk.Label(label=_("Lessonfile header")))
        # Header section
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        self.g_title = Gtk.Entry()
        cvbox.pack_start(gu.hig_label_widget(_("File title:", True, True, 0), self.g_title,
                        sizegroup))
        self.g_content_chord = Gtk.RadioButton(None, "chord")
        self.g_content_chord_voicing = Gtk.RadioButton(self.g_content_chord, "chord-voicing")
        self.g_content_idbyname = Gtk.RadioButton(self.g_content_chord, "id-by-name")
        box = Gtk.HBox()
        box.pack_start(self.g_content_chord, True, True, 0)
        box.pack_start(self.g_content_chord_voicing, True, True, 0)
        box.pack_start(self.g_content_idbyname, True, True, 0)
        cvbox.pack_start(gu.hig_label_widget(_("Content:", True, True, 0), box, sizegroup))
        self.g_random_transpose = Gtk.Entry()
        cvbox.pack_start(gu.hig_label_widget(_("Random transpose:", True, True, 0),
            self.g_random_transpose, sizegroup))
        #
        #self.g_statusbar = Gtk.Statusbar()
        #self.toplevel_vbox.pack_start(self.g_statusbar, False)
        self.update_appwin()
예제 #21
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()
예제 #22
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"))
예제 #23
0
 def __init__(self, heading, st_data, st):
     """
     st_data is the statistics data we want displayled
     st is the statistics object the statistics are collected from.
     """
     gtk.VBox.__init__(self)
     label = gtk.Label(heading)
     label.set_name("StatisticsH2")
     label.set_alignment(0.0, 0.0)
     self.pack_start(label, False)
     hbox = gu.bHBox(self, False)
     frame = gtk.Frame()
     hbox.pack_start(frame, False)
     t = gtk.Table()
     frame.add(t)
     keys = st.get_keys(True)
     for x in range(len(keys)):
         t.attach(gtk.VSeparator(), x * 2 + 1, x * 2 + 2, 0, len(keys) * 2)
     for x in range(len(keys) - 1):
         t.attach(gtk.HSeparator(), 0,
                  len(keys) * 2 + 1, x * 2 + 1, x * 2 + 2)
     for y, key in enumerate(keys):
         l = label_from_key(st, key)
         t.attach(l, 0, 1, y * 2, y * 2 + 1, xpadding=gu.PAD)
         for x, skey in enumerate(keys):
             try:
                 s = st_data[key][skey]
             except KeyError:
                 s = '-'
             l = gtk.Label(s)
             if x == y:
                 l.set_name('BoldText')
             t.attach(l,
                      x * 2 + 2,
                      x * 2 + 3,
                      y * 2,
                      y * 2 + 1,
                      xpadding=gu.PAD)
     self.show_all()
예제 #24
0
    def _create_select_inputwidget_gui(self):
        """
        This will be called by HarmonicInterval and MelodicInterval
        constructor
        """
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        gu.bLabel(hbox, _("Input interface:"), False)

        combo = Gtk.ComboBoxText()
        for i in range(len(inputwidgets.inputwidget_names)):
            combo.append_text(inputwidgets.inputwidget_names[i])
        if self.get_int('inputwidget') < len(inputwidgets.inputwidget_names):
            combo.set_active(self.get_int('inputwidget'))
        else:
            combo.set_active(0)
        combo.connect('changed', lambda w: self.use_inputwidget(w.get_active()))
        hbox.pack_start(combo, False, False, 0)

        self.g_disable_unused_buttons = gu.nCheckButton(self.m_exname,
                    'disable_unused_intervals', _("_Disable unused buttons"))
        hbox.pack_start(self.g_disable_unused_buttons, True, True, 0)
예제 #25
0
    def _create_select_inputwidget_gui(self):
        """
        This will be called by HarmonicInterval and MelodicInterval
        constructor
        """
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        gu.bLabel(hbox, _("Input interface:"), False)

        combo = gtk.combo_box_new_text()
        for i in range(len(inputwidgets.inputwidget_names)):
            combo.append_text(inputwidgets.inputwidget_names[i])
        if self.get_int('inputwidget') < len(inputwidgets.inputwidget_names):
            combo.set_active(self.get_int('inputwidget'))
        else:
            combo.set_active(0)
        combo.connect('changed', lambda w: self.use_inputwidget(w.get_active()))
        hbox.pack_start(combo, False)

        self.g_disable_unused_buttons = gu.nCheckButton(self.m_exname,
                    'disable_unused_intervals', _("_Disable unused buttons"))
        hbox.pack_start(self.g_disable_unused_buttons)
예제 #26
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())
        hbox.pack_start(self.g_contents)
        hbox.pack_start(gtk.HBox())
        self.g_contents.set_col_spacings(gu.PAD)
        self.g_contents.set_row_spacings(gu.PAD)

        self.g_music_displayer = mpd.musicdisplayer.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)

        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)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False)
        self.g_select_questions.show()
예제 #27
0
    def __init__(self, exname, name, sizegroup):
        Gtk.VBox.__init__(self)
        cfg.ConfigUtils.__dict__['__init__'](self, exname)
        self.m_name = name
        hbox = gu.bHBox(self)
        hbox.set_spacing(gu.PAD_SMALL)

        self.g_button = Gtk.Button(
              soundcard.instrument_names[self.get_int(self.m_name)])
        self.g_button.connect('clicked', self.on_btnclick)
        hbox.pack_start(self.g_button, True, True, 0)
        g = Gtk.VolumeButton()
        g.props.value = self.get_int('%s_volume' % name) / MAX_VOLUME
        def ff(volumebutton, value):
            self.set_int('%s_volume' % name, int(value * MAX_VOLUME))
        g.connect('value-changed', ff)
        hbox.pack_start(g, False, False, 0)

        self.g_menu = MidiInstrumentMenu(self.on_instrument_selected)
        self.m_instrument = self.get_int('preferred_instrument')

        hbox = Gtk.HBox()
        hbox.set_spacing(6)
        self.pack_start(hbox, True, True, 0)
예제 #28
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)
    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)
예제 #30
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"))
예제 #31
0
 def _display_data(self, page, display_only_tests=False,
         is_search_result=False, show_topics=False):
     """
     display_only_tests should be True when we are browsing available tests.
     This will validate statistics for each lesson and display the test result.
     """
     if not is_search_result:
         self.m_page = page
     try:
         self.g_hbox.destroy()
     except AttributeError:
         pass
     self.g_hbox = gu.bHBox(self.g_box)
     self.g_hbox.set_spacing(gu.hig.SPACE_MEDIUM)
     label = None
     do_sg = True
     if len(page[0]) > 0 and isinstance(page[0][0], frontpage.LinkList):
         count = 0
         for p in page[0]:
             count += len(page[0][0])
         if count > 80:
             do_sg = False
     for column in page:
         sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
         assert isinstance(column, frontpage.Column)
         first = True
         vbox = gtk.VBox()
         vbox.set_spacing(gu.hig.SPACE_MEDIUM)
         self.g_hbox.pack_start(vbox, False)
         for sect_id, linklist in enumerate(column):
             if isinstance(linklist, frontpage.Paragraph):
                 label = gtk.Label(linklist.m_text)
                 label.set_line_wrap(True)
                 label.set_alignment(0.0, 0.5)
                 vbox.pack_start(label, False)
                 continue
             assert isinstance(linklist, frontpage.LinkList)
             if (display_only_tests
                 and not frontpage._TreeCommon.tests_in_sub(linklist)):
                     continue
             linkbox = gtk.VBox()
             vbox.pack_start(linkbox, False)
             heading = gtk.Label("<b>%s</b>" % _no_xgettext(linklist.m_name))
             heading.set_alignment(0.0, 0.5)
             heading.set_use_markup(True)
             linkbox.pack_start(heading, False)
             sizegroups = dict((k, gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)) for k in self.m_fields)
             for idx, link in enumerate(linklist):
                 if isinstance(self, TestsView) and not frontpage._TreeCommon.tests_in_sub(link):
                     continue
                 if isinstance(link, frontpage.Page):
                     label = gu.ClickableLabel(_no_xgettext(link.m_name))
                     label.connect('clicked', self.on_page_link_clicked, link)
                 else:
                     assert isinstance(link, unicode), type(link)
                     label = gtk.HBox()
                     label.set_spacing(gu.hig.SPACE_SMALL)
                     if display_only_tests:
                         solfege.db.validate_stored_statistics(link)
                     try:
                         for fieldname in self.m_fields:
                             if fieldname in (u'link', u'link-with-filename-tooltip'):
                                 labeltxt = lessonfile.infocache.get(link, 'title')
                                 lbl = gu.ClickableLabel(_no_xgettext(labeltxt))
                                 if fieldname == u'link-with-filename-tooltip':
                                     lbl.set_tooltip_text(link)
                                 if do_sg:
                                     sizegroups[fieldname].add_widget(lbl)
                                 if show_topics:
                                     topic = solfege.app.m_frontpage_data.get_topic_of_lesson_file(link)
                                     if topic and topic not in labeltxt:
                                         lbl.add_heading(topic)
                                 lbl.connect('clicked', self.on_link_clicked, link)
                             else:
                                 if fieldname == 'filename':
                                     lbl = gtk.Label(link)
                                 else:
                                     lbl = gtk.Label(lessonfile.infocache.get(link, fieldname))
                                 lbl.set_alignment(0.0, 0.5)
                                 if do_sg:
                                     sizegroups[fieldname].add_widget(lbl)
                             label.pack_start(lbl, False)
                     except lessonfile.InfoCache.FileNotFound:
                         label = gu.ClickableLabel(_(u"«%s» was not found") % link)
                         label.make_warning()
                     except lessonfile.InfoCache.FileNotLessonfile:
                         label = gu.ClickableLabel(_(u"Failed to parse «%s»") % link)
                         label.make_warning()
                 if first:
                     label.set_data('first', True)
                     first = False
                 w = label.size_request()[0]
                 if w > self.max_exercise_label_width:
                     w = self.max_exercise_label_width
                     if isinstance(link, unicode):
                         txt = _(lessonfile.infocache.get(link, "title"))
                     else:
                         txt = link.m_name
                     label.set_tooltip_text(txt)
                     label.set_size_request(w / len(page), -1)
                 self.m_linkbuttons.append(label)
                 label.connect('focus-in-event', self.on_focus_in)
                 if display_only_tests:
                     box = gtk.HBox()
                     box.pack_start(label)
                     if isinstance(link, unicode):
                         passed, result = solfege.db.get_test_status(link)
                         if passed == True:
                             box.pack_start(gtk.Label(_("passed, %.1f%%") % (result * 100)))
                         if passed == False:
                             box.pack_start(gtk.Label(_("failed, %.1f%%") % (result * 100)))
                         # do nothing if passed == None since
                     linkbox.pack_start(box, True)
                 else:
                     linkbox.pack_start(label, True)
                 if do_sg:
                     sizegroup.add_widget(label)
         if label:
             label.set_data('last', True)
     self.g_hbox.show_all()
     self.adjust_scrolledwin_size()
     self.get_vadjustment().value = 0.0
예제 #32
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)
예제 #33
0
    def __init__(self, initial_value, parent):
        Gtk.Dialog.__init__(self, _("Set transposition"), parent, 0, (
            Gtk.STOCK_CANCEL,
            Gtk.ResponseType.CANCEL,
            Gtk.STOCK_OK,
            Gtk.ResponseType.OK,
        ))
        dlg_vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(dlg_vbox, True, True, 0)
        xbox, vbox = gu.hig_category_vbox(
            _("Select how to do random transposition"))
        dlg_vbox.pack_start(xbox, True, True, 0)
        label = Gtk.Label(label=_(
            """You can read about the different types of transposition in the lesson file documentation available on the Help menu."""
        ))
        spin_sg = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        label.set_line_wrap(True)
        vbox.pack_start(label, True, True, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        self.m_buttons = {}
        self.m_spins = {}
        self.m_buttons['no'] = b1 = Gtk.RadioButton.new_with_label(
            None, _("No"))
        self.m_spins['no'] = []
        vbox.pack_start(b1, True, True, 0)
        self.m_buttons[
            'yes'] = b2 = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Yes"))
        self.m_spins['yes'] = []
        hbox = gu.bHBox(vbox)
        label_b = Gtk.Label()
        label_b.set_alignment(0.4, 0.5)
        label_b.set_markup('<span size="xx-large">♭</span>')
        label_x = Gtk.Label()
        label_x.set_alignment(0.4, 0.5)
        label_x.set_markup('<span size="xx-large">♯</span>')
        spin_sg.add_widget(label_b)
        spin_sg.add_widget(label_x)
        hbox.pack_start(b2, True, True, 0)
        hbox.pack_start(label_b, True, True, 0)
        hbox.pack_start(label_x, True, True, 0)

        self.m_buttons[
            'accidentals'] = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Fifths relative to C major/a minor"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['accidentals'], True, True, 0)
        self.m_spins['accidentals'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -7, 7, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -7, 7, 1, 1))
        ]  #, 0.0, 0)]
        spin_sg.add_widget(self.m_spins['accidentals'][0])
        spin_sg.add_widget(self.m_spins['accidentals'][1])
        hbox.pack_start(self.m_spins['accidentals'][0], True, True, 0)
        hbox.pack_start(self.m_spins['accidentals'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['accidentals'][0],
                                     self.m_spins['accidentals'][1], -7, 7)

        self.m_buttons['key'] = Gtk.RadioButton.new_with_label_from_widget(
            b1, _i("Fifths relative to current key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['key'], True, True, 0)
        self.m_spins['key'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -10, 10, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -10, 10, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['key'][0], True, True, 0)
        hbox.pack_start(self.m_spins['key'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['key'][0],
                                     self.m_spins['key'][1], -10, 10)

        self.m_buttons['atonal'] = Gtk.RadioButton.new_with_label_from_widget(
            b1, _i("Transpose notes without changing key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['atonal'], True, True, 0)
        self.m_spins['atonal'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -10, 10, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -10, 10, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['atonal'][0], True, True, 0)
        hbox.pack_start(self.m_spins['atonal'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['atonal'][0],
                                     self.m_spins['atonal'][1], -10, 10)

        self.m_buttons[
            'semitones'] = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Semitones"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['semitones'], True, True, 0)
        self.m_spins['semitones'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -100, 100, 1, 1)),  #, 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -100, 100, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['semitones'][0], True, True, 0)
        hbox.pack_start(self.m_spins['semitones'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['semitones'][0],
                                     self.m_spins['semitones'][1], -100, 100)
        for n, w in self.m_buttons.items():
            sizegroup.add_widget(w)
            for ww in self.m_spins[n]:
                ww.set_sensitive(False)
            w.connect('clicked', self.on_spins_clicked, n)
        if initial_value[0] == False:
            k = 'no'
        elif initial_value[0] == True:
            k = 'yes'
        else:
            k = initial_value[0]
        self.m_buttons[k].set_active(True)
        if k in ('accidentals', 'key', 'semitones', 'atonal'):
            t, v1, v2 = initial_value
            # FIXME Because of the RangeController, we have to do this
            # twice to be sure both values are set properly.
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
        self.show_all()
예제 #34
0
 def _display_data(self, page, display_only_tests=False,
         is_search_result=False, show_topics=False):
     """
     display_only_tests should be True when we are browsing available tests.
     This will validate statistics for each lesson and display the test result.
     """
     if not is_search_result:
         self.m_page = page
     try:
         self.g_hbox.destroy()
     except AttributeError:
         pass
     self.g_hbox = gu.bHBox(self.g_box)
     self.g_hbox.set_spacing(gu.hig.SPACE_MEDIUM)
     label = None
     do_sg = True
     if len(page[0]) > 0 and isinstance(page[0][0], frontpage.LinkList):
         count = 0
         for column in page:
             assert isinstance(column, frontpage.Column)
             for linklist in column:
                 assert isinstance(linklist, (frontpage.LinkList,
                                              frontpage.Paragraph))
                 if isinstance(linklist, frontpage.LinkList):
                     count += len(linklist)
         if count > 80:
             do_sg = False
     for column in page:
         sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
         assert isinstance(column, frontpage.Column)
         first = True
         vbox = gtk.VBox()
         vbox.set_spacing(gu.hig.SPACE_MEDIUM)
         self.g_hbox.pack_start(vbox, False)
         for sect_id, linklist in enumerate(column):
             if isinstance(linklist, frontpage.Paragraph):
                 label = gtk.Label(linklist.m_text)
                 label.set_use_markup(True)
                 label.set_line_wrap(True)
                 label.set_alignment(0.0, 0.5)
                 vbox.pack_start(label, False)
                 continue
             assert isinstance(linklist, frontpage.LinkList)
             if (display_only_tests
                 and not frontpage._TreeCommon.tests_in_sub(linklist)):
                     continue
             linkbox = gtk.VBox()
             vbox.pack_start(linkbox, False)
             heading = gtk.Label("<b>%s</b>" % _no_xgettext(linklist.m_name))
             heading.set_alignment(0.0, 0.5)
             heading.set_use_markup(True)
             linkbox.pack_start(heading, False)
             sizegroups = dict((k, gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)) for k in self.m_fields)
             for idx, link in enumerate(linklist):
                 if isinstance(self, TestsView) and not frontpage._TreeCommon.tests_in_sub(link):
                     continue
                 if isinstance(link, frontpage.Page):
                     label = gu.ClickableLabel(_no_xgettext(link.m_name))
                     label.connect('clicked', self.on_page_link_clicked, link)
                 else:
                     assert isinstance(link, unicode), type(link)
                     label = gtk.HBox()
                     label.set_spacing(gu.hig.SPACE_SMALL)
                     if display_only_tests:
                         solfege.db.validate_stored_statistics(link)
                     try:
                         for fieldname in self.m_fields:
                             if fieldname in (u'link', u'link-with-filename-tooltip'):
                                 labeltxt = lessonfile.infocache.get(link, 'title')
                                 lbl = gu.ClickableLabel(_no_xgettext(labeltxt))
                                 if solfege.app.m_options.debug:
                                     lbl.set_tooltip_text(u"%s\n%s module" % (link, lessonfile.infocache.get(link, 'module')))
                                 elif fieldname == u'link-with-filename-tooltip':
                                     lbl.set_tooltip_text(link)
                                 if do_sg:
                                     sizegroups[fieldname].add_widget(lbl)
                                 if show_topics:
                                     topic = solfege.app.m_frontpage_data.get_topic_of_lesson_file(link)
                                     if topic and topic not in labeltxt:
                                         lbl.add_heading(topic)
                                 lbl.connect('clicked', self.on_link_clicked, link)
                             else:
                                 if fieldname == 'filename':
                                     lbl = gtk.Label(link)
                                 else:
                                     lbl = gtk.Label(lessonfile.infocache.get(link, fieldname))
                                 lbl.set_alignment(0.0, 0.5)
                                 if do_sg:
                                     sizegroups[fieldname].add_widget(lbl)
                             label.pack_start(lbl, False)
                     except lessonfile.InfoCache.FileNotFound:
                         label = gu.ClickableLabel(_(u"«%s» was not found") % link)
                         label.make_warning()
                     except lessonfile.InfoCache.FileNotLessonfile:
                         label = gu.ClickableLabel(_(u"Failed to parse «%s»") % link)
                         label.make_warning()
                 if first:
                     label.set_data('first', True)
                     first = False
                 w = label.size_request()[0]
                 if w > self.max_exercise_label_width:
                     w = self.max_exercise_label_width
                     if isinstance(link, unicode):
                         txt = _(lessonfile.infocache.get(link, "title"))
                     else:
                         txt = link.m_name
                     label.set_tooltip_text(txt)
                     label.set_size_request(w / len(page), -1)
                 self.m_linkbuttons.append(label)
                 label.connect('focus-in-event', self.on_focus_in)
                 if display_only_tests:
                     box = gtk.HBox()
                     box.pack_start(label)
                     if isinstance(link, unicode):
                         passed, result = solfege.db.get_test_status(link)
                         if passed == True:
                             box.pack_start(gtk.Label(_("passed, %.1f%%") % (result * 100)))
                         if passed == False:
                             box.pack_start(gtk.Label(_("failed, %.1f%%") % (result * 100)))
                         # do nothing if passed == None since
                     linkbox.pack_start(box, True)
                 else:
                     linkbox.pack_start(label, True)
                 if do_sg:
                     sizegroup.add_widget(label)
         if label:
             label.set_data('last', True)
     self.g_hbox.show_all()
     self.adjust_scrolledwin_size()
     self.get_vadjustment().set_value(0.0)
예제 #35
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)
예제 #36
0
    def __init__(self, initial_value, parent):
        gtk.Dialog.__init__(self, _("Set transposition"), parent, 0,
           (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OK, gtk.RESPONSE_OK,
            ))
        dlg_vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(dlg_vbox)
        xbox, vbox = gu.hig_category_vbox(_("Select how to do random transposition"))
        dlg_vbox.pack_start(xbox)
        label = gtk.Label(_("""You can read about the different types of transposition in the lesson file documentation available on the Help menu."""))
        spin_sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        label.set_line_wrap(True)
        vbox.pack_start(label)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        self.m_buttons = {}
        self.m_spins = {}
        self.m_buttons['no'] = b1 = gtk.RadioButton(None, _("No"))
        self.m_spins['no'] = []
        vbox.pack_start(b1)
        self.m_buttons['yes'] = b2 = gtk.RadioButton(b1, _("Yes"))
        self.m_spins['yes'] = []
        hbox = gu.bHBox(vbox)
        label_b = gtk.Label()
        label_b.set_alignment(0.4, 0.5)
        label_b.set_markup('<span size="xx-large">♭</span>')
        label_x = gtk.Label()
        label_x.set_alignment(0.4, 0.5)
        label_x.set_markup('<span size="xx-large">♯</span>')
        spin_sg.add_widget(label_b)
        spin_sg.add_widget(label_x)
        hbox.pack_start(b2)
        hbox.pack_start(label_b)
        hbox.pack_start(label_x)

        self.m_buttons['accidentals'] = gtk.RadioButton(b1, _("Fifths relative to C major/a minor"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['accidentals'])
        self.m_spins['accidentals'] = [
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0)]
        spin_sg.add_widget(self.m_spins['accidentals'][0])
        spin_sg.add_widget(self.m_spins['accidentals'][1])
        hbox.pack_start(self.m_spins['accidentals'][0])
        hbox.pack_start(self.m_spins['accidentals'][1])
        gu.SpinButtonRangeController(self.m_spins['accidentals'][0],
                                     self.m_spins['accidentals'][1],
                                     -7, 7)

        self.m_buttons['key'] = gtk.RadioButton(b1, _i("Fifths relative to current key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['key'])
        self.m_spins['key'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['key'][0])
        hbox.pack_start(self.m_spins['key'][1])
        gu.SpinButtonRangeController(self.m_spins['key'][0],
                                     self.m_spins['key'][1],
                                     -10, 10)

        self.m_buttons['atonal'] = gtk.RadioButton(b1, _i("Transpose notes without changing key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['atonal'])
        self.m_spins['atonal'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['atonal'][0])
        hbox.pack_start(self.m_spins['atonal'][1])
        gu.SpinButtonRangeController(self.m_spins['atonal'][0],
                                     self.m_spins['atonal'][1],
                                     -10, 10)

        self.m_buttons['semitones'] = gtk.RadioButton(b1, _("Semitones"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['semitones'])
        self.m_spins['semitones'] = [
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        gu.SpinButtonRangeController(self.m_spins['semitones'][0],
                                     self.m_spins['semitones'][1],
                                     -100, 100)
        for n, w in self.m_buttons.items():
            sizegroup.add_widget(w)
            for ww in self.m_spins[n]:
                ww.set_sensitive(False)
            w.connect('clicked', self.on_spins_clicked, n)
        if initial_value[0] == False:
            k = 'no'
        elif initial_value[0] == True:
            k = 'yes'
        else:
            k = initial_value[0]
        self.m_buttons[k].set_active(True)
        if k in ('accidentals', 'key', 'semitones', 'atonal'):
            t, v1, v2 = initial_value
            # FIXME Because of the RangeController, we have to do this
            # twice to be sure both values are set properly.
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
        self.show_all()
예제 #37
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"))
예제 #38
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)