Ejemplo n.º 1
0
 def on_touch_down(self, touch):
     #print 'ML tD',self.target.children[0], "Collide:",self.collide_point(*touch.pos)
     if self.collide_point(*touch.pos):
         if self.target:
             self.target.manager.current_screen = self.target.wrapped
             self.target.manager.activated = False #trigger the othrs tuff
             return True
     return Label.on_touch_down(self, touch)
Ejemplo n.º 2
0
 def update_model_entries(self):
     self.models_options.clear_widgets()
     for model_id in self.model_manager.model_files:
         label = Label(text=model_id,
                       pos=(0, 0),
                       height=20,
                       size_hint=(1, None),
                       color=(0, 0, 0, 1))
         label.on_touch_down = partial(self.update_model_id, label)
         self.models_options.add_widget(label)
Ejemplo n.º 3
0
 def update_audio_entries(self):
     self.audio_options.clear_widgets()
     for audio_id in self.audio_manager.all_audio_ids():
         label = Label(text=audio_id,
                       pos=(0, 0),
                       height=20,
                       size_hint=(1, None),
                       color=(0, 0, 0, 1))
         label.on_touch_down = partial(self.update_audio_id, label)
         self.audio_options.add_widget(label)
Ejemplo n.º 4
0
class ModelEntry(SparseGridLayout):
    def __init__(self, model_id, is_active, model_manager: ModelManager,
                 open_callback, save_callback, delete_callback,
                 rename_callback):
        super().__init__(rows=1, cols=6, size_hint_y=None, height=40)
        self.model_id = model_id
        self.model_manager = model_manager
        self.open_callback = open_callback
        self.save_callback = save_callback
        self.delete_callback = delete_callback
        self.rename_callback = rename_callback

        background_color = (0.3, 0.3, 0.3, 1)
        if is_active:
            background_color = (0.3, 0.3, 0.6, 1)
        self.background = Label(padding_x=10)
        self.add_entry(self.background,
                       position=(0, 0),
                       shape=(1, 6),
                       padding_x=(0.01, 0.01),
                       padding_y=(0.05, 0.05),
                       color=background_color)

        self.model_label = Label(text=model_id,
                                 halign="left",
                                 valign="middle",
                                 padding_x=10)
        self.model_label.bind(size=self.model_label.setter('text_size'))
        self.model_label.on_touch_down = self.on_label_press
        self.add_entry(self.model_label,
                       position=(0, 0),
                       shape=(1, 3),
                       padding_x=(0.01, 0.01),
                       padding_y=(0.05, 0.05))

        if model_id in self.model_manager.unsaved_models:
            self.save_button = Button(text="Save")
            self.save_button.on_press = self.save_model
            self.add_entry(self.save_button,
                           position=(0, 3),
                           shape=(1, 1),
                           padding_x=(0.01, 0.01),
                           padding_y=(0.1, 0.1),
                           index=10)

        self.open_button = Button(text="Open")
        self.open_button.on_press = self.open_model
        self.add_entry(self.open_button,
                       position=(0, 4),
                       shape=(1, 1),
                       padding_x=(0.01, 0.01),
                       padding_y=(0.1, 0.1),
                       index=10)

        self.delete_button = Button(text="Delete")
        self.delete_button.on_press = self.delete_model
        self.add_entry(self.delete_button,
                       position=(0, 5),
                       shape=(1, 1),
                       padding_x=(0.01, 0.01),
                       padding_y=(0.1, 0.1),
                       index=10)

    def open_model(self):
        self.update_color(self.background, (0.3, 0.3, 0.6, 1))
        self.open_callback(self.model_id)

    def on_label_press(self, touch):
        if self.model_label.collide_point(*touch.pos):
            self.remove_entry(self.model_label)
            self.model_label = TextInput(text=self.model_id, multiline=False)
            self.model_label.bind(focus=self.rename_model)
            self.model_label.on_touch_down(touch)
            self.add_entry(self.model_label,
                           position=(0, 0),
                           shape=(1, 3),
                           padding_x=(0.01, 0.01),
                           padding_y=(0.05, 0.05))

    def rename_model(self, instance, value):
        if not value:
            new_id = self.model_label.text
            self.remove_entry(self.model_label)
            if new_id != self.model_id:
                self.model_manager.rename_model(self.model_id, new_id)
                self.rename_callback(self.model_id, new_id)
                self.model_id = new_id
            self.model_label = Label(text=self.model_id,
                                     halign="left",
                                     valign="middle",
                                     padding_x=10)
            self.model_label.bind(size=self.model_label.setter('text_size'))
            self.model_label.on_touch_down = self.on_label_press
            self.add_entry(self.model_label,
                           position=(0, 0),
                           shape=(1, 3),
                           padding_x=(0.01, 0.01),
                           padding_y=(0.05, 0.05))

    def save_model(self):
        self.model_manager.save_model(self.model_id)
        self.remove_widget(self.save_button)
        self.save_callback(self.model_id)

    def delete_model(self):
        self.model_manager.delete_model(self.model_id)
        self.parent.remove_widget(self)
        self.delete_callback(self.model_id)
        EventListener.trigger_event("refresh_training_models")
Ejemplo n.º 5
0
class AudioEntry(SparseGridLayout):

    def __init__(self, audio_id, audio_manager: AudioManager):
        super().__init__(rows=1, cols=6, size_hint_y=None, height=40)
        self.audio_id = audio_id
        self.audio_manager = audio_manager

        self.background = Label(padding_x=10)
        self.add_entry(self.background, position=(0, 0), shape=(1, 6), padding_x=(0.01, 0.01), padding_y=(0.05, 0.05), color=(0.3, 0.3, 0.3, 1))

        self.audio_label = Label(text=audio_id, halign="left", valign="middle", padding_x=10)
        self.audio_label.bind(size=self.audio_label.setter('text_size'))
        self.audio_label.on_touch_down = self.on_label_press
        self.add_entry(self.audio_label, position=(0, 0), shape=(1, 3), padding_x=(0.01, 0.01), padding_y=(0.05, 0.05),)

        if audio_id in self.audio_manager.unsaved_audio:
            self.save_button = Button(text="Save")
            self.save_button.on_press = self.save_clip
            self.add_entry(self.save_button, position=(0, 3), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1), index=10)

        self.play_button = Button(text="Play")
        self.play_button.on_press = self.play_audio
        self.add_entry(self.play_button, position=(0, 4), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1), index=10)

        self.delete_button = Button(text="Delete")
        self.delete_button.on_press = self.delete_clip
        self.add_entry(self.delete_button, position=(0, 5), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1), index=10)

    def on_label_press(self, touch):
        if self.audio_label.collide_point(*touch.pos):
            self.remove_entry(self.audio_label)
            self.audio_label = TextInput(text=self.audio_id, multiline=False)
            self.audio_label.bind(focus=self.update_audio_label)
            self.audio_label.on_touch_down(touch)
            self.add_entry(self.audio_label, position=(0, 0), shape=(1, 3), padding_x=(0.01, 0.01), padding_y=(0.05, 0.05), color=(0.3, 0.3, 0.3, 1))

    def update_audio_label(self, instance, value):
        if not value:
            new_id = self.audio_label.text
            self.remove_entry(self.audio_label)
            if new_id != self.audio_id:
                self.audio_manager.rename_audio(self.audio_id, new_id)
                self.audio_id = new_id
            self.audio_label = Label(text=self.audio_id, halign="left", valign="middle", padding_x=10)
            self.audio_label.bind(size=self.audio_label.setter('text_size'))
            self.audio_label.on_touch_down = self.on_label_press
            self.add_entry(self.audio_label, position=(0, 0), shape=(1, 3), padding_x=(0.01, 0.01), padding_y=(0.05, 0.05), color=(0.3, 0.3, 0.3, 1))

    def update_stop_to_play(self):
        self.play_button.text = "Play"
        self.play_button.on_press = self.play_audio

    def play_audio(self):
        self.audio_manager.play_audio(self.audio_id, on_complete=self.update_stop_to_play)
        self.play_button.text = "Stop"
        self.play_button.on_press = self.stop_audio

    def stop_audio(self):
        self.audio_manager.stop_audio()
        self.update_stop_to_play()

    def save_clip(self):
        self.audio_manager.save_audio(self.audio_id)
        self.remove_widget(self.save_button)

    def delete_clip(self):
        self.audio_manager.delete_audio(self.audio_id)
        self.parent.remove_widget(self)
        EventListener.trigger_event("update_audio_entries")
Ejemplo n.º 6
0
 def on_touch_down(self, touch):
     if self.collide_point(*touch.pos):
         self.parent.parent.parent.getTags(self.full_name)
         return True
     else:
         return Label.on_touch_down(self, touch)
Ejemplo n.º 7
0
 def on_touch_down(self, touch):
     if touch.is_double_tap:
         self.dispatch('on_double_press', touch)
         return True
     return Label.on_touch_down(self, touch)