def build(self): main_layout = BoxLayout(padding=(10, 0), orientation="vertical") wimg = Image(source='s.png') wimg.allow_stretch = True wimg.keep_ratio = False wimg.size_hint_x = 1 wimg.size_hint_y = 0.2 scroll_container = BoxLayout(orientation="vertical", size_hint=(1, 0.90)) self.layout = BoxLayout(padding=(15, 10), orientation="vertical", spacing=50, size_hint_y=None) self.layout.bind(minimum_height=self.layout.setter('height')) colors = [red, green, blue, purple] root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height * 0.70)) root.add_widget(self.layout) bottom_layout = BoxLayout(padding=10, orientation="horizontal", size_hint=(1, 0.1)) self.textinput = TextInput(hint_text="Say something ", background_color=random.choice(colors), size_hint=(0.8, 1)) btn3 = Button(text="Send", background_color=random.choice(colors), size_hint=(0.2, 1)) btn3.bind(on_press=self.sent) bottom_layout.add_widget(self.textinput) bottom_layout.add_widget(btn3) scroll_container.add_widget(root) main_layout.add_widget(wimg) main_layout.add_widget(scroll_container) main_layout.add_widget(bottom_layout) Window.bind(on_key_down=self.on_key_down) btn = Label(padding=(0, 0), text="Bot> " + random.choice(ice_breakers), color=(1, 0, 1, 1), size_hint=(1.0, 1.0), halign="left", valign="middle") btn.bind(size=btn.setter('text_size')) self.layout.add_widget(btn) return main_layout
def __init__(self, sound, audio_engine, nb_steps, track_source, steps_left_align, **kwargs): super(TrackWidget, self).__init__(**kwargs) self.audio_engine = audio_engine self.sound = sound self.track_source = track_source sound_and_separtor_layout = BoxLayout() sound_and_separtor_layout.size_hint_x = None sound_and_separtor_layout.width = steps_left_align self.add_widget(sound_and_separtor_layout) sound_button = TrackSoundButton() sound_button.text = sound.displayname sound_button.on_press = self.on_sound_button_press sound_and_separtor_layout.add_widget(sound_button) # separateur separator_image = Image(source="images/track_separator.png") separator_image.size_hint_x = None separator_image.width = dp(15) sound_and_separtor_layout.add_widget(separator_image) # self.track_source = audio_engine.create_track(sound.samples, 120) self.step_buttons = [] self.nb_steps = nb_steps for i in range(0, nb_steps): step_button = TrackStepButton() if int(i / 4) % 2 == 0: step_button.background_normal = "images/step_normal1.png" else: step_button.background_normal = "images/step_normal2.png" step_button.bind(state=self.on_step_button_state) self.step_buttons.append(step_button) self.add_widget(step_button)
def entered(self): grid = self.children[0].children[0] grid.clear_widgets() self.books = [] self.book_filepaths = [ helper.get_resources_path() + "/books/" + b for b in os.listdir(helper.get_resources_path() + "/books/") ] self.titles = [] if self.book_filepaths == []: grid.add_widget(Label(text="No books found :(")) n = 0 for b in self.book_filepaths: n += 1 if n % 2 == 0: grid.height = 200 + n * 200 n = 0 for b in self.book_filepaths: n += 1 button = Button(on_press=self.goto_read) button.size_hint = (None, None) button.size = (200, 200) self.children[0].children[0].add_widget(button) layout = BoxLayout() button.add_widget(layout) x = ((1 - (n % 2)) * 240) + 70 y = grid.height - ((((n - 1) / 2) - (((n - 1) / 2) % 1)) * 240) - 250 layout.pos = (x, y) layout.size = button.size layout.orientation = "vertical" self.book_filename = b.split("/")[-1].split(".")[0] book = EPUBEE(b) cover = book.get_cover() if cover != "": cover_path = helper.get_app_path( ) + APP_NAME + "/covers/" + self.book_filename + ".jpeg" cover.save(cover_path) self.books.append(book) img = Image(source=cover_path) img.size_hint_x = None img.width = 100 img.height = 100 if len(book.title) > 18: text = book.title[:15] + "..." else: text = book.title self.titles.append(text) lbl = Label(text=text, color=[.5, .5, .5, 1], size_hint=(None, None), pos=(button.pos[0], button.pos[1])) if cover != "": layout.add_widget(img) print("adding") layout.add_widget(lbl)