示例#1
0
    def __init__(self, **kwargs):
        super(KeyDisplay, self).__init__(**kwargs)

        print(self.pos)
        x = self.pos[0]
        y = self.pos[1]
        sz = metrics.pt(21)
        sz2 = metrics.pt(21) * 2.5
        gap = metrics.mm(2)  # 2 millimeters

        # print(metrics.pt(21), metrics.sp(21), metrics.dp(21), metrics.mm(10))

        # keyboard up / down messages
        self.active_keys = {}
        self.slots = []
        for i in range(5):
            self.slots.append(
                SimpleNamespace(icon=None,
                                pos=(x + (gap + sz) * i, y + gap + sz),
                                size=(sz, sz)))
        self.meta_slots = []
        for i in range(5):
            self.meta_slots.append(
                SimpleNamespace(icon=None,
                                pos=(x + (gap + sz2) * i, y),
                                size=(sz2, sz)))

        kb = Window.request_keyboard(target=self, callback=None)
        kb.bind(on_key_down=self._key_down)
        kb.bind(on_key_up=self._key_up)
示例#2
0
    def __init__(self, **kwargs):
        super(MessagesScreen, self).__init__(**kwargs)
        self.name = "messages"

        self.message_input = TextInput(multiline=True,
                                       text="",
                                       font_size=pt(10))
        btn_send = Button(text="Send",
                          size_hint=(.2, 1),
                          on_release=self.on_send_button)
        btn_voice = Button(text="Voice",
                           size_hint=(.2, 1),
                           on_release=self.on_voice_message)

        vbox = BoxLayout(orientation="vertical")

        messagebar = GridLayout(cols=3, rows=1)
        messagebar.size_hint = (1, .3)
        messagebar.add_widget(self.message_input)
        messagebar.add_widget(btn_send)
        messagebar.add_widget(btn_voice)
        vbox.add_widget(messagebar)

        vbox.add_widget(
            BoxLayout(orientation="horizontal",
                      size_hint=(1, None),
                      height=dp(20)))

        # Create second row
        rc_messages = RecycleViewMessages()
        rc_messages.viewclass = "RecycleViewMessagesButton"
        vbox.add_widget(rc_messages)

        self.add_widget(vbox)
    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)
示例#4
0
    def update_app_widgets(self):
        '''To add/update self.custom_category with new custom classes loaded
           by project.
        '''
        if self.custom_category:
            self.accordion.remove_widget(self.custom_category)
            self._list = []
        self.custom_category = ToolboxCategory(title='App Widgets')
        self._list.append(self.custom_category)

        self.accordion.add_widget(self.custom_category)

        custom_widgets = []
        for widget in toolbox_widgets:
            if widget[1] == 'custom':
                custom_widgets.append(widget)

        custom_widgets.sort()
        for widget in custom_widgets:
            self.custom_category.gridlayout.add_widget(
                ToolboxButton(text=widget[0]))

        # Setting appropriate height to gridlayout to enable scrolling
        self.custom_category.gridlayout.size_hint_y = None
        self.custom_category.gridlayout.height = \
            (len(self.custom_category.gridlayout.children) + 5) * pt(22)
示例#5
0
    def update_app_widgets(self):
        '''To add/update self.custom_category with new custom classes loaded
           by project.
        '''
        if self.custom_category:
            self.accordion.remove_widget(self.custom_category)
            self._list = []
        self.custom_category = ToolboxCategory(title='App Widgets')
        self._list.append(self.custom_category)

        self.accordion.add_widget(self.custom_category)

        custom_widgets = []
        for widget in toolbox_widgets:
            if widget[1] == 'custom':
                custom_widgets.append(widget)

        custom_widgets.sort()
        for widget in custom_widgets:
            self.custom_category.gridlayout.add_widget(
                ToolboxButton(text=widget[0]))

        # Setting appropriate height to gridlayout to enable scrolling
        self.custom_category.gridlayout.size_hint_y = None
        self.custom_category.gridlayout.height = \
            (len(self.custom_category.gridlayout.children) + 5) * pt(22)
示例#6
0
    def _setup_width(self, *args):
        '''To set appropriate width of RecentFilesBox.
        '''
        max_width = -1
        for child in self.grid.children:
            max_width = max(child.texture_size[0], max_width)

        self.width = max_width + pt(20)
示例#7
0
    def add_recent(self, list_files):
        for i in list_files:
            btn = Button(text=i, size_hint_y=None, height=pt(22))
            self.grid.add_widget(btn)
            btn.bind(size=self._btn_size_changed)
            btn.bind(on_release=self.btn_release)
            btn.valign = 'middle'
            self.grid.height += btn.height

        self.grid.height = max(self.grid.height, self.height)
        Clock.schedule_once(self._setup_width, 0.01)
示例#8
0
 def __init__(self, *args, **kwargs):
     super(LoadingDialog, self).__init__(*args, **kwargs)
     self.auto_dismiss = False
     self.size_hint = (None, None)
     self.size = (int(Window.width / 1.2), int(Window.height / 1.2))
     self.title = ""
     self.label = Label(text="", size_hint=(1, 1))
     self.label.texture_size = self.size
     self.label.font_size = pt(20)
     self.dot_count = 0
     self.is_open = False
     self.add_widget(self.label)
示例#9
0
    def add_custom(self):
        '''To add/update self.custom_category with new custom classes loaded
           by project.
        '''
        self.custom_category = ToolboxCategory(title='custom')
        self._list.append(self.custom_category)

        self.accordion.add_widget(self.custom_category)

        for widget in widgets:
            if widget[1] == 'custom':
                self.custom_category.gridlayout.add_widget(
                    ToolboxButton(text=widget[0]))

        #Setting appropriate height to gridlayout to enable scrolling
        self.custom_category.gridlayout.size_hint_y = None
        self.custom_category.gridlayout.height = \
            (len(self.custom_category.gridlayout.children)+5)*pt(22)
示例#10
0
    def add_custom(self):
        '''To add/update self.custom_category with new custom classes loaded
           by project.
        '''
        self.custom_category = ToolboxCategory(title='custom')
        self._list.append(self.custom_category)

        self.accordion.add_widget(self.custom_category)

        for widget in widgets:
            if widget[1] == 'custom':
                self.custom_category.gridlayout.add_widget(
                    ToolboxButton(text=widget[0]))

        #Setting appropriate height to gridlayout to enable scrolling
        self.custom_category.gridlayout.size_hint_y = None
        self.custom_category.gridlayout.height = \
            (len(self.custom_category.gridlayout.children)+5)*pt(22)
示例#11
0
文件: main.py 项目: quiche19/Vocagen
from kivy.uix.behaviors import ButtonBehavior, ToggleButtonBehavior
from ashika_play_area.input_demo import *

from graphics import Scene

## not necessary while using .kv file
from kivy.uix.checkbox import CheckBox
# To do some manupulation on window impoet window
from kivy.core.window import Window
from kivy.factory import Factory
from kivy.config import Config
Config.set('graphics', 'resizable', False)
Config.set('graphics', 'height', '450')
Config.set('graphics', 'width', '800')

font_sz = metrics.pt(20)
button_sz = metrics.pt(100)
THEME = {
    "red": Color(1, 0, 0),
    "dark-red": Color(.5, 0, 0),
    "white": Color(1, 1, 1),
    "black": Color(0, 0, 0),
}


class Checkboxes():
    def __init__(self, labels_and_defaults):
        self.labels = {}
        self.init_active = {}
        for group in labels_and_defaults:
            labels, index_active = labels_and_defaults[group]
    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)
示例#13
0
 def _setup_width(self, *args):
     max_width = -1
     for child in self.grid.children:
          max_width = max(child.texture_size[0], max_width)
     
     self.width = max_width + pt(20)