def __init__(self, exname, num, labeltext): Gtk.VBox.__init__(self) #cfg.ConfigUtils.__init__(self, exname) cfg.ConfigUtils.__dict__['__init__'](self, exname) assert num in (2, 3) self.m_num = num self.g_override_default_instrument_checkbutton \ = gu.nCheckButton(exname, 'override_default_instrument', labeltext, callback=self.update_instrument_override) self.pack_start(self.g_override_default_instrument_checkbutton, False, False, 0) hbox = gu.bVBox(self) hbox.set_spacing(gu.PAD_SMALL) sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self.g_instrsel_high = FramedInstrumentSelector(_("Highest:"), exname, 'highest_instrument',sizegroup) hbox.pack_start(self.g_instrsel_high, False, False, 0) if num == 3: self.g_instrsel_middle = FramedInstrumentSelector(_("Middle:"), exname, 'middle_instrument', sizegroup) hbox.pack_start(self.g_instrsel_middle, False, False, 0) else: self.g_instrsel_middle = None self.g_instrsel_low = FramedInstrumentSelector(_("Lowest:"), exname, 'lowest_instrument', sizegroup) hbox.pack_start(self.g_instrsel_low, False, False, 0) self.update_instrument_override()
def __init__(self, teacher): abstract.Gui.__init__(self, teacher) ################ # practise_box # ################ self.practise_box.set_spacing(gu.PAD) self.m_buttons = [] vbox = gu.bVBox(self.practise_box, False) for s, e in ((0, 9), (9, 18), (18, 26), (26, 34)): box = Gtk.HBox() vbox.pack_start(box, True, True, 0) for i in range(s, e): bpm = self.m_t.m_bpms[i] button = Gtk.Button(str(bpm)) box.pack_start(button, True, True, 0) button.connect('clicked', self.on_click) button.connect('button-release-event', self.on_event) button.m_bpm = bpm self.m_buttons.append(button) self.g_flashbar = gu.FlashBar() self.g_flashbar.show() self.practise_box.pack_start(self.g_flashbar, False, False, 0) self.std_buttons_add( ('new', self.on_new), ('repeat', self.on_repeat), ('give_up', self.on_give_up) ) self.practise_box.show_all() ############## # statistics # ############## self.g_statview = statisticsviewer.StatisticsViewer(self.m_t.m_statistics, _('Bpm')) self.g_statview.show() self.g_notebook.append_page(self.g_statview, Gtk.Label(label=_("Statistics"))) ######## # init # ######## self.g_notebook.get_nth_page(1).hide() self.update_buttons()
def __init__(self, teacher): abstract.Gui.__init__(self, teacher) self.g_percentage = gu.bLabel(self.practise_box, "") self.g_percentage.set_name("Heading1") self.g_piano = inputwidgets.PianoOctaveWithAccelName( self.on_answer_from_user, self.get_accel_key_list()) self.g_piano.m_visible_accels = not self.get_bool('hide_piano_accels') def update_accels(*ignore): self.g_piano.m_keys = self.get_accel_key_list() self.g_piano.queue_draw() for notename in mpd.MusicalPitch.notenames: self.add_watch('tone_%s_ak' % notename, update_accels) self.practise_box.pack_start(self.g_piano, True, True, 0) self.g_flashbar = gu.FlashBar() self.g_flashbar.show() self.practise_box.pack_start(self.g_flashbar, False, False, 0) self.practise_box.set_spacing(gu.PAD) self.std_buttons_add( ('new-tone', self.new_question), ('repeat', lambda _o, self=self: self.m_t.play_question()), ('give_up', self.give_up)) self.practise_box.show_all() ############## # config_box # ############## self.config_box.set_spacing(gu.PAD_SMALL) self.g_config_elems = gu.bVBox(self.config_box, False) table = Gtk.Table() table.set_border_width(gu.PAD_SMALL) frame = Gtk.Frame(label=_("Weight")) self.g_config_elems.pack_start(frame, False, False, 0) frame.add(table) for x, n in [(1, 'cis'), (3, 'dis'), (7, 'fis'), (9, 'gis'), (11, 'ais')]: label = Gtk.Label(label=mpd.MusicalPitch.new_from_notename( n).get_user_notename()) label.set_name("Heading2") label.set_alignment(0.2, 1.0) table.attach(label, x, x + 2, 0, 1, xoptions=Gtk.AttachOptions.FILL) b = gu.nSpinButton(self.m_exname, n + "_weight", Gtk.Adjustment(1, 0, 1000, 1, 10), digits=0) table.attach(b, x, x + 2, 1, 2, xoptions=Gtk.AttachOptions.FILL) for x, n in [(0, 'c'), (2, 'd'), (4, 'e'), (6, 'f'), (8, 'g'), (10, 'a'), (12, 'b')]: label = Gtk.Label(label=mpd.MusicalPitch.new_from_notename( n).get_user_notename()) label.set_name("Heading2") label.set_alignment(0.35, 1.0) table.attach(label, x, x + 2, 2, 3, xoptions=Gtk.AttachOptions.FILL) b = gu.nSpinButton(self.m_exname, n + "_weight", Gtk.Adjustment(1, 0, 1000, 1, 10), digits=0) table.attach(b, x, x + 2, 3, 4, xoptions=Gtk.AttachOptions.FILL) hbox = gu.bHBox(self.g_config_elems, False) hbox.pack_start(Gtk.Label(_("Octave:")), False, False, padding=4) for oct in self.m_t.OCTAVES: b = gu.nCheckButton(self.m_exname, "octave" + str(oct), str(oct), default_value=1) hbox.pack_start(b, False, False, 0) ############# self._add_auto_new_question_gui(self.config_box) ############# b = gu.nCheckButton('idtone', 'hide_piano_accels', _("Hide _piano keyboard shortcuts"), False) def show_hide_accels(checkbutton): self.g_piano.m_visible_accels = not b.get_active() b.connect('clicked', show_hide_accels) self.config_box.pack_start(b, False, False, 0) # frame = Gtk.Frame(label=_("When you guess wrong")) vbox = Gtk.VBox() vbox.set_border_width(gu.PAD_SMALL) frame.add(vbox) vbox.pack_start( gu.nCheckButton(self.m_exname, "warning_sound", _("Play warning sound")), False, False, 0) self.config_box.pack_start(frame, False, False, 0) self.config_box.show_all() ############## # statistics # ############## self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, _("Identify tone"))
def __init__(self, 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, 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)
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"))