def __init__(self, fretboard, player_panel, note_trainer_panel, **kwargs): super(MenuPanel, self).__init__(**kwargs) self.fretboard = fretboard self.player_panel = player_panel self.note_trainer_panel = note_trainer_panel self.orientation = 'vertical' self.padding = 10 self.spacing = 10 button_panel = BoxLayout(orientation='horizontal', size_hint=(1, None)) button_panel.height = pt(20) button_panel.center_x = self.center_x player_button = Button(id='player', text='player', on_release=self.button_press) trainer_button = Button(id='notetrainer', text='note trainer', on_release=self.button_press) button_panel.add_widget(player_button) button_panel.add_widget(trainer_button) self.add_widget(button_panel) self.add_widget(self.sm) player_screen = Screen(name='player') player_screen.add_widget(player_panel) note_trainer_screen = Screen(name='notetrainer') note_trainer_screen.add_widget(note_trainer_panel) self.sm.add_widget(player_screen) self.sm.add_widget(note_trainer_screen) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, fretboard, midi_config, tuning, **kwargs): super(NoteTrainerPanel, self).__init__(**kwargs) self.fretboard = fretboard self.midi_config = midi_config self.tuning = tuning self.orientation = 'vertical' self.padding = 10 self.spacing = 10 button_panel = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) button_panel.height = pt(20) button_panel.center_x = self.center_x self.play_button = Button(id='play', text='play', on_press=self.button_press, size_hint=(None, None)) # self.play_button.height = pt(20) self.play_label_text = 'play' self.curr_line_num = -1 self.bind(play_label_text=self.update_play_button_text) self.bind(current_note=self.update_current_note) button_panel.add_widget(Widget()) # button_panel.add_widget(rewind_button) button_panel.add_widget(self.play_button) # button_panel.add_widget(stop_button) button_panel.add_widget(Widget()) self.add_widget(button_panel) notes_container = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) notes_panel = GridLayout(cols=14, row_force_default=True, row_default_height=40) self.note_label_a = Label(halign='right', text='A:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_a = CheckBox(active=True) self.note_checkbox_a.bind(active=partial(self.note_checked, 'A')) notes_panel.add_widget(self.note_label_a) notes_panel.add_widget(self.note_checkbox_a) self.note_label_b = Label(halign='right', text='B:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_b = CheckBox(active=True) self.note_checkbox_b.bind(active=partial(self.note_checked, 'B')) notes_panel.add_widget(self.note_label_b) notes_panel.add_widget(self.note_checkbox_b) self.note_label_c = Label(halign='right', text='C:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_c = CheckBox(active=True) self.note_checkbox_c.bind(active=partial(self.note_checked, 'C')) notes_panel.add_widget(self.note_label_c) notes_panel.add_widget(self.note_checkbox_c) self.note_label_d = Label(halign='right', text='D:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_d = CheckBox(active=True) self.note_checkbox_d.bind(active=partial(self.note_checked, 'D')) notes_panel.add_widget(self.note_label_d) notes_panel.add_widget(self.note_checkbox_d) self.note_label_e = Label(halign='right', text='E:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_e = CheckBox(active=True) self.note_checkbox_e.bind(active=partial(self.note_checked, 'E')) notes_panel.add_widget(self.note_label_e) notes_panel.add_widget(self.note_checkbox_e) self.note_label_f = Label(halign='right', text='F:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_f = CheckBox(active=True) self.note_checkbox_f.bind(active=partial(self.note_checked, 'F')) notes_panel.add_widget(self.note_label_f) notes_panel.add_widget(self.note_checkbox_f) self.note_label_g = Label(halign='right', text='G:', font_size='16sp', color=(0, 0, 0, 1)) self.note_checkbox_g = CheckBox(active=True) self.note_checkbox_g.bind(active=partial(self.note_checked, 'G')) notes_panel.add_widget(self.note_label_g) notes_panel.add_widget(self.note_checkbox_g) notes_container.add_widget(Widget()) notes_container.add_widget(notes_panel) notes_container.add_widget(Widget()) self.add_widget(notes_container) options_container = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) options_panel = GridLayout(cols=14, row_force_default=True, row_default_height=40) self.accidental_label_none = Label(halign='right', text="none:", font_size='16sp', color=(0, 0, 0, 1)) self.accidental_checkbox_none = CheckBox(group='accidentals', active=False) options_panel.add_widget(self.accidental_label_none) options_panel.add_widget(self.accidental_checkbox_none) self.accidental_label_sharp = Label(halign='right', text="#'s:", font_size='16sp', color=(0, 0, 0, 1)) self.accidental_checkbox_sharp = CheckBox(group='accidentals') options_panel.add_widget(self.accidental_label_sharp) options_panel.add_widget(self.accidental_checkbox_sharp) self.accidental_label_flat = Label(halign='right', text="b's:", font_size='16sp', color=(0, 0, 0, 1)) self.accidental_checkbox_flat = CheckBox(group='accidentals', active=True) options_panel.add_widget(self.accidental_label_flat) options_panel.add_widget(self.accidental_checkbox_flat) self.show_notes_label = Label(halign='right', text="show notes:", font_size='16sp', color=(0, 0, 0, 1)) self.show_notes_checkbox = CheckBox(active=True) self.show_notes_checkbox.bind(active=self.show_notes) options_panel.add_widget(self.show_notes_label) options_panel.add_widget(self.show_notes_checkbox) self.require_all_label = Label(halign='right', text="require all:", font_size='16sp', color=(0, 0, 0, 1)) self.require_all_checkbox = CheckBox() options_panel.add_widget(self.require_all_label) options_panel.add_widget(self.require_all_checkbox) self.error_sound_label = Label(halign='right', text="beep on error:", font_size='16sp', color=(0, 0, 0, 1)) self.error_sound_checkbox = CheckBox() options_panel.add_widget(self.error_sound_label) options_panel.add_widget(self.error_sound_checkbox) options_container.add_widget(Widget()) options_container.add_widget(options_panel) options_container.add_widget(Widget()) self.add_widget(options_container) self.current_note_label = Label(halign='center', text="?", font_size='340sp', color=(0, 0.1, 0.8, 1), size_hint=(1, .7)) self.add_widget(self.current_note_label) fretboard.set_target_tone_callback(self)