def build(self): Builder.load_string(demo) self.screen = Factory.Root() for name_tab in colors.keys(): tab = Tab(text=name_tab) self.screen.ids.android_tabs.add_widget(tab) return self.screen
def on_switch_tabs( self, bottom_navigation_instance, bottom_navigation_item_instance, name_tab, ) -> None: """Called when switching tabs of bottom navigation.""" if name_tab == "bottom navigation gradient": self._current_tab = self.gradient_tab bottom_navigation_item_instance.children[0].updated_canvas( None, None, self._rgb if self._rgb[0] > 1 else self.get_rgb(self._rgb), ) instance_slider_tab = (bottom_navigation_instance.ids.tab_manager. get_screen("tune").children[0]) select_alpha_channel_widget = ( self.gradient_tab.ids.select_alpha_channel_widget) select_alpha_channel_widget.ids.slider.value = ( instance_slider_tab.ids.select_alpha_channel_widget.ids.slider. value) select_alpha_channel_widget.ids.slider.color = [ x / 255.0 for x in self._rgb ] + [1] elif name_tab == "tune": if self._rgb[0] <= 1: color = self.get_rgb(self._rgb) else: color = self._rgb instance_slider_tab = self.ids.tune.children[0] self._current_tab = instance_slider_tab instance_slider_tab.ids.slider_red.ids.slider.value = color[0] instance_slider_tab.ids.slider_green.ids.slider.value = color[1] instance_slider_tab.ids.slider_blue.ids.slider.value = color[2] instance_slider_tab.ids.select_alpha_channel_widget.ids.slider.value = ( self._opacity_value_selected_color) elif name_tab == "view headline": color = self._rgb + [1] color_list_tabs = self.ids.view_headline.children[0] self._current_tab = color_list_tabs try: color_list_tabs.background_color = color except ValueError: color_list_tabs.background_color = [x / 255.0 for x in color][:-1] + [1] if not color_list_tabs.get_tab_list(): for color in _colors.keys(): tab_widget = TabColorList(title=str(color)) color_list_tabs.add_widget(tab_widget)
def build(self): # # primary_palette, primary_hue # self.theme_cls.primary_palette = 'Purple' # self.theme_cls.primary_hue = "500" # self.theme_cls.theme_style = "Light" Builder.load_string(KV) self.screen = Factory.Root() # Tabs에 colors의 key를 이름으로 하는 Tab 추가 # Tab : MDTabsBase를 상속 받음 for name_tab in colors.keys(): self.screen.ids.android_tabs.add_widget(Tab(text=name_tab)) return self.screen
def on_enter(self): if not self.tabs_created: for color in _colors.keys(): tab_widget = KitchenSinkThemeTab(text=str(color)) self.tabs_manager.add_widget(tab_widget) self.tabs_created = True