def set_objects_labels(self) -> None: """ Creates labels objects for the parameters`helper_text`,`hint_text`, etc. """ self._helper_text_label = TextfieldLabel( font_style="Caption", halign="left", valign="middle", field=self, font_name=self.font_name_helper_text, ) self._max_length_label = TextfieldLabel( font_style="Caption", halign="right", valign="middle", text="", field=self, ) self._hint_text_label = TextfieldLabel( font_style="Subtitle1", halign="left", valign="middle", field=self ) self._icon_right_label = MDIcon(theme_text_color="Custom") self._icon_left_label = MDIcon(theme_text_color="Custom")
def __init__(self, **kwargs): super().__init__(**kwargs) self._lbl_icon_left = MDIcon(theme_text_color="Custom") self._lbl_icon_right = MDIcon(theme_text_color="Custom") self.cursor_color = self.theme_cls.primary_color if not self.normal_color: self.normal_color = self.theme_cls.primary_light if not self.line_color: self.line_color = self.theme_cls.primary_dark if not self.color_active: self._color_active = [0, 0, 0, 0.5]
def on_touch_down(self, touch): if self.collide_point(*touch.pos): self.dispatch("on_press") self.dispatch("on_release") md_choose_chip = self.parent if self.selected_chip_color: Animation( color=self.theme_cls.primary_dark if not self.selected_chip_color else self.selected_chip_color, d=0.3, ).start(self) if issubclass(md_choose_chip.__class__, MDChooseChip): for chip in md_choose_chip.children: if chip is not self: chip.color = (self.theme_cls.primary_color if not chip._color else chip._color) else: chip.color = self.theme_cls.primary_color if self.check: if not len(self.ids.box_check.children): self.ids.box_check.add_widget( MDIcon( icon="check", size_hint=(None, None), size=("26dp", "26dp"), font_size=sp(20), )) else: check = self.ids.box_check.children[0] self.ids.box_check.remove_widget(check)
def set_objects_labels(self): """Creates labels objects for the parameters `helper_text`,`hint_text`, etc.""" # Label object for `helper_text` parameter. self._msg_lbl = TextfieldLabel( font_style="Caption", halign="left", valign="middle", text=self.helper_text, field=self, ) # Label object for `max_text_length` parameter. self._right_msg_lbl = TextfieldLabel( font_style="Caption", halign="right", valign="middle", text="", field=self, ) # Label object for `hint_text` parameter. self._hint_lbl = TextfieldLabel(font_style="Subtitle1", halign="left", valign="middle", field=self) # MDIcon object for the icon on the right. self._lbl_icon_right = MDIcon(theme_text_color="Custom")
def set_color(self, *args): self._color = ( self.theme_cls.primary_color if not self.color else self.color ) if self.active: self.color = ( self.theme_cls.primary_dark if not self.selected_chip_color else self.selected_chip_color ) if self.check and self.parent.multiple: self.ids.box_check.add_widget( MDIcon( icon="check", size_hint=(None, None), size=("26dp", "26dp"), font_size=sp(20), ) ) self.parent.selected.append(self.text) else: self.color = ( self.theme_cls.primary_color if not self._color else self._color )
def on_touch_down(self, touch): if self.collide_point(*touch.pos): md_chip_container = self.parent if issubclass(md_chip_container.__class__, MDChipContainer): if md_chip_container.type == "choice": if md_chip_container.multiple == True: if not self.active: self.active = True else: self.active = False else: if not self.active: self.active = True for chip in md_chip_container.children: if chip is not self: chip.active = False else: self.dispatch("on_press") self.dispatch("on_release") if self.check and md_chip_container.multiple: if self.active: self.ids.box_check.add_widget( MDIcon( icon="check", size_hint=(None, None), size=("26dp", "26dp"), font_size=sp(20), ) ) else: check = self.ids.box_check.children[0] self.ids.box_check.remove_widget(check)
def build(self): label = MDLabel(text='Hello World', halign='center', theme_text_color='Custom', text_color=(6 / 255.0, 192 / 255.0, 174 / 255.0, 1), font_style='H1') icon_label = MDIcon(icon='leaf-maple', halign='center') return icon_label
def build(self): label = MDLabel(text="Hello World", halign='center', theme_text_color='Custom', text_color=(236 / 255.0, 98 / 255.0, 81 / 255.0, 1), font_style="H2") icon_label = MDIcon(icon="language-python", halign='center') return icon_label
def build(self): screen = Screen() label = MDLabel(text='hello', halign='center', theme_text_color='Custom', text_color=(190 / 255, 19 / 255, 148 / 255, 1), font_style='Caption') icon_label = MDIcon(icon='flash-red-eye', pos_hint={'center_x': 0.5}) return label
def build(self): label = MDLabel( text='Hello world', halign='center', theme_text_color='Custom', text_color=(54 / 255.0, 36 / 255.0, 53 / 255.0, 1), font_style='H5') # theme_text_color=Primary,Secondary,Hint,Error icon_lab = MDIcon(icon='account-clock', halign='center', theme_text_color='Error') return icon_lab
def build(self): label = MDLabel(text="Demo App", halign="center", theme_text_color='Custom', text_color=(0, 0.6, 1, 1), font_style='H1') icon_label = MDIcon(icon='language-python', halign='center') #return label return icon_label
def build(self): text_label = MDLabel( text="Hello World!", halign="center", theme_text_color="Custom", text_color=(43 / 255.0, 164 / 255.0, 55 / 255.0, 1), #here 1 is opecity of text which we use to display font_style="H1") #we can choise any type of font icon = MDIcon(icon='language-python', halign="center") return text_label
def update_game(self): if not self.game.is_running: self.win() return self.remove_widget(self.game_grid) self.game_grid = MDGridLayout(cols=5, pos_hint={"center": 0.5}) self.add_widget(self.game_grid) for i in range(self.game.get_pos() - 1): self.game_grid.add_widget(MDIcon(icon="square-outline")) self.game_grid.add_widget(MDIcon(icon="radiobox-marked")) if self.game.get_pos() < 5: for i in range(5 - self.game.get_pos()): self.game_grid.add_widget(MDIcon(icon="square-outline")) for row in self.game.show_field(): for chip in row: if chip == 0: self.game_grid.add_widget(MDIcon(icon="moon-new")) elif chip == 1: self.game_grid.add_widget(MDIcon(icon="numeric-1-circle")) elif chip == 2: self.game_grid.add_widget(MDIcon(icon="numeric-2-circle")) self.remove_widget(self.game_controls) self.add_widget(self.game_controls)
def build(self): Window.size=(500,500) self.theme_cls.primary_palette="Red" self.theme_cls.primary_hue="A700" self.theme_cls.theme_style="Light" screen=Screen() label=MDLabel(text="Face Mask Detection",bold=True, size_hint=(0.5,0.5), font_style='H3',halign='center', pos_hint={'center_x':0.5,'center_y':0.84}, font_size="100sp", theme_text_color="Error") btn_flat=MDRectangleFlatButton(text="Click Here", pos_hint={'center_x':0.40,'center_y':0.12}, md_bg_color=self.theme_cls.primary_light, on_release=self.show_data) icon_label=MDIcon(icon='video',halign='center', pos_hint={'center_x':0.65,'center_y':0.12}, text_color=self.theme_cls.primary_color, theme_text_color="Custom", font_size= "48sp") top_label=MDIcon(icon='youtube',halign='center', pos_hint={'center_x':0.1,'center_y':0.92}, font_size="200sp") img=Image(source='background.jpg',opacity=.36) screen.add_widget(label) screen.add_widget(img) screen.add_widget(btn_flat) screen.add_widget(top_label) screen.add_widget(icon_label) return screen
def __init__(self, **kwargs): super(ScreenMenu, self).__init__(**kwargs) layout_menu = DefaultFloatLayout(screen_size=size_screen) layout_menu.add_widget(MDIcon(icon='icons/hexagon-outline.png', pos_hint={'center_x': .1, 'center_y': .93}, size_hint=(.1, .055))) layout_menu.add_widget(DefaultLabel(text='RS', pos_hint={'center_x': .1, 'center_y': .93})) layout_menu.add_widget(DefaultLabel(text='Register Sell', pos_hint={'center_x': .35, 'center_y': .93}, font_size=size_screen[1] / 25)) # IMPLEMENTAR: Botão de configuração: # MDIconButton(pos_hint={'center_x': .5, 'center_y': .5}, # icon='icons/config.png', # user_font_size=str(size_screen[1] / 40) + 'sp')) layout_menu.add_widget(DefaultButtonMenu(text='Cadastrar dívida', on_release=self.change_screen_for_register, pos_hint={'center_x': .5, 'center_y': .8}, icon='account-plus')) layout_menu.add_widget(DefaultButtonMenu(text='Cadastrar pagamento', on_release=self.change_screen_for_payment, pos_hint={'center_x': .5, 'center_y': .66}, icon='account-cash')) layout_menu.add_widget(DefaultButtonMenu(text='Buscar dívida', on_release=self.change_screen_for_search, pos_hint={'center_x': .5, 'center_y': .52}, icon='magnify')) layout_menu.add_widget(DefaultButtonMenu(text='Todos os devedores', on_release=self.change_screen_for_all_debtors, pos_hint={'center_x': .5, 'center_y': .38}, icon='account-search')) layout_menu.add_widget(DefaultButtonMenu(text='Total de dívidas', on_release=self.change_screen_for_all_debts, pos_hint={'center_x': .5, 'center_y': .24}, icon='cash-register')) layout_menu.add_widget(DefaultButtonMenu(text='Excluir dados', on_release=self.change_screen_for_remove_data, pos_hint={'center_x': .5, 'center_y': .10}, icon='database-remove')) self.add_widget(layout_menu)
def __init__(self, **kwargs): super(ContactCard, self).__init__(orientation='horizontal', size_hint=(1, None), height=dp(90), pos_hint={'center_x': 0.5}, padding=(dp(5), dp(1))) self.contact = kwargs.get('contact') # Gather first character of contact to get icon cef first_char = self.contact[0] if first_char.isdigit(): icon_name = 'numeric-%s-circle-outline' % first_char else: icon_name = 'alpha-%s-circle' % first_char.lower() icon = MDIcon(icon=icon_name) icon.theme_text_color = 'Custom' icon.text_color = [1, 1, 1, 1] icon.font_size = 60 self.add_widget(icon) # Create name Label contact_label = MDLabel(text=self.contact, font_style='H3', size_hint=(5, 1)) contact_label.theme_text_color = 'Custom' contact_label.text_color = [1, 1, 1, 1] self.add_widget(contact_label) self.add_widget(Widget()) self.add_widget(Widget()) self.add_widget(Widget()) # Create message Icon message_icon = MDIcon(icon='message') message_icon.theme_text_color = 'Custom' message_icon.text_color = [1, 1, 1, 1] message_icon.font_size = 60 self.add_widget(message_icon)
def __init__(self, **kwargs): self._msg_lbl = TextfieldLabel( font_style="Caption", halign="left", valign="middle", text=self.helper_text, field=self, ) self._right_msg_lbl = TextfieldLabel( font_style="Caption", halign="right", valign="middle", text="", field=self, ) self._hint_lbl = TextfieldLabel(font_style="Subtitle1", halign="left", valign="middle", field=self) self._lbl_icon_right = MDIcon(theme_text_color="Custom") super().__init__(**kwargs) self.line_color_normal = self.theme_cls.divider_color self.line_color_focus = self.theme_cls.primary_color self.error_color = self.theme_cls.error_color self._current_hint_text_color = self.theme_cls.disabled_hint_text_color self._current_line_color = self.theme_cls.primary_color self.bind( helper_text=self._set_msg, hint_text=self._set_hint, _hint_lbl_font_size=self._hint_lbl.setter("font_size"), helper_text_mode=self._set_message_mode, max_text_length=self._set_max_text_length, text=self.on_text, ) self.theme_cls.bind( primary_color=self._update_primary_color, theme_style=self._update_theme_style, accent_color=self._update_accent_color, ) self.has_had_text = False
def __init__(self, return_back): super(GameWidget, self).__init__() self.orientation = "vertical" self.return_back = return_back self.ids.return_button.on_press = return_back self.game = Game() self.game_grid = GameField(cols=5) for i in range(20): self.game_grid.add_widget(MDIcon(icon="moon-new")) self.game_controls = ControlsBox() self.game_controls.add_widget( MDIconButton(icon="arrow-collapse-left", on_press=lambda _: self.move(True))) self.game_controls.add_widget( MDIconButton(icon="arrow-down-bold", on_press=self.drop_cell)) self.game_controls.add_widget( MDIconButton(icon="arrow-collapse-right", on_press=lambda _: self.move(False))) self.add_widget(self.game_grid) self.add_widget(self.game_controls) self.update_game()
def newmdicon(iconname, **kwargs): image = BoxLayout(padding=5, size_hint=(0.1, 0.1)) image.add_widget(MDIcon(icon=iconname, **kwargs)) return image
def __init__(self, **kwargs): self._lbl_icon_left = MDIcon() self._lbl_icon_right = MDIcon() super().__init__(**kwargs)
def build(self): label=MDLabel(text="THIS IS HACKER",halign='center',theme_text_color='Custom' ,text_color=( 236/ 225.0,152/255.0,142/255.0,1) ,font_style='H1') icon=MDIcon(icon="google",halign='center') return icon,label
def load_bookmarked(self): """ This function reads the json's stored in /bookmarks. It then proceeds to initialize the widgets for each listing It adds all the widget to the boxlayout. Finally, it checks which listing has the lowest price/highest rating and add tags accordingly. The lowest price cannot be 0 and the best rated listing must have at least 10 ratings. """ best_price_box = {} best_rating_box = {} web_button_data = {} location_data = {} path = 'bookmarks' full_path = os.path.join(os.getcwd(), path) for filenames in os.walk(full_path): for filename in filenames[2]: current_file = open(os.path.join(full_path, filename), "r") data = json.load(current_file) main_box_per_listing = MDBoxLayout(size_hint_y=None, height="240dp", orientation="horizontal", padding=[dp(4), dp(4)], spacing=dp(4)) image_box = MDFloatLayout(size_hint=[0.4, 1]) text_box = MDBoxLayout(orientation='horizontal') super_vertical_box = MDBoxLayout(orientation='vertical', ) super_horizontal_box = MDBoxLayout(orientation='horizontal', padding=dp(10)) vertical_box_tile_and_room_type = MDBoxLayout( orientation='vertical', size_hint_y=0.7) vertical_box_room_type = MDBoxLayout(size_hint_y=0.3) vertical_box_title = MDBoxLayout(size_hint_y=0.7) vertical_box_buttons = MDFloatLayout(size_hint_x=0.1) vertical_box_nr_of_guests = MDBoxLayout( orientation='horizontal') horizontal_box_rating = MDBoxLayout(orientation='horizontal') horizontal_box_star = MDBoxLayout(orientation='horizontal', size_hint_x=0.3) img = AsyncImage(source=data['picture_url'], allow_stretch=True, keep_ratio=False, pos_hint={ 'center_x': .5, 'center_y': .5 }, size_hint_y=1, width=100) roomtype_label = MDLabel( text= f"[color=808080]{data['room_type']} in {data['village']}" f" ({data['borough']})[/color]", markup=True, halign='left', pos_hint={ 'center_x': .5, 'center_y': .75 }) title_label = MDLabel(text=f"[size=25]{data['name']}[/size]", markup=True, halign='left', pos_hint={ 'center_x': .5, 'center_y': .85 }) """ reviews_expansion = MDExpansionPanel( icon="", # panel icon content=ContentReviews(), # panel content panel_cls=MDExpansionPanelOneLine(text="Reviews"), # panel class ) """ if data['guests_included'] == 1: guest_text = f"{data['guests_included']} guest · {data['minimum_nights']} minimum nights · " \ f"{data['maximum_nights']} maximum nights" else: guest_text = f"{data['guests_included']} guests · {data['minimum_nights']} minimum nights · " \ f"{data['maximum_nights']} maximum nights" guests_included_label = MDLabel(text=guest_text, halign='left', pos_hint={ 'center_x': .5, 'center_y': .35 }) price_label = MDLabel( text=f"[size=35][b]{data['price']}$[/b]/night[/size]", markup=True, halign='right', pos_hint={ 'center_x': 0.3, 'center_y': .1 }) line = MDSeparator(height=dp(1)) if not data['price'] == 0: best_price_box[image_box] = data['price'] if data['number_of_reviews'] >= 10: best_rating_box[image_box] = float( data['review_score']) / 20 superhost_chip = MDChip( text='SUPERHOST', pos_hint={ 'center_x': .20, 'center_y': .90 }, icon='', color=[1, 1, 1, 1], ) staricon = MDIcon(icon='star', pos_hint={ 'left_x': .50, 'center_y': .08 }) starlabel = MDLabel( text= f"[b]{float(data['review_score']) / 20}[/b] ({data['number_of_reviews']})", markup=True, pos_hint={ 'left_x': .50, 'center_y': .07 }) webbutton = WebButton(icon='search-web', user_font_size="36sp", pos_hint={ 'center_x': .9, 'center_y': .3 }, url_dictionary=web_button_data) web_button_data[webbutton] = data['listing_url'] bookmarkbutton = ListingSaveButton(data, pos_hint={ 'center_x': .9, 'center_y': .7 }, opposite_colors=False, icon='delete') loc_button = LocationButton(icon='map-outline', pos_hint={ 'center_x': .9, 'center_y': .5 }, location_dictionary=location_data, listing_id=data['id']) location_data[loc_button] = [ float(data['latitude']), float(data['longitude']) ] # ADD WIDGETS image_box.add_widget(img) if data['is_superhost']: image_box.add_widget(superhost_chip) vertical_box_title.add_widget(title_label) vertical_box_room_type.add_widget(roomtype_label) vertical_box_tile_and_room_type.add_widget( vertical_box_room_type) vertical_box_tile_and_room_type.add_widget(vertical_box_title) vertical_box_buttons.add_widget(bookmarkbutton) vertical_box_buttons.add_widget(loc_button) vertical_box_buttons.add_widget(webbutton) horizontal_box_star.add_widget(staricon) horizontal_box_star.add_widget(starlabel) horizontal_box_rating.add_widget(horizontal_box_star) horizontal_box_rating.add_widget(price_label) super_horizontal_box.add_widget(horizontal_box_rating) vertical_box_nr_of_guests.add_widget(guests_included_label) #vertical_box_nr_of_guests.add_widget(reviews_expansion) super_vertical_box.add_widget(vertical_box_tile_and_room_type) super_vertical_box.add_widget(vertical_box_nr_of_guests) super_vertical_box.add_widget(super_horizontal_box) text_box.add_widget(super_vertical_box) text_box.add_widget(vertical_box_buttons) main_box_per_listing.add_widget(image_box) main_box_per_listing.add_widget(text_box) self.ids.comparebox.add_widget(main_box_per_listing) self.ids.comparebox.add_widget(line) best_price_chip = MDChip(text='BEST PRICE', pos_hint={ 'center_x': .8, 'center_y': .9 }, icon='', text_color=[1, 1, 1, 1], color=[0.01, 0.28, 0.99, 1], spacing=dp(4)) #if no listing is bookmarked then return print(len(self.ids.comparebox.children)) if (len(self.ids.comparebox.children) == 0): empty_label = MDLabel( text= "No listing on Wishlist.\nPlease add some listings on the Map screen", pos_hint={ "center_x": 0.9, "center_y": 4 }) self.ids.comparebox.height = self.height self.ids.comparebox.add_widget(empty_label) elif (len(self.ids.comparebox.children) <= 2): return else: min(best_price_box, key=best_price_box.get).add_widget(best_price_chip) if min(best_price_box, key=best_price_box.get) == max(best_rating_box, key=best_rating_box.get): pos = {'center_x': .8, 'center_y': 0.77} else: pos = {'center_x': .8, 'center_y': .9} best_rating_chip = MDChip(text='BEST RATING', pos_hint=pos, icon='', color=[0.98, 0.92, 0.01, 1], spacing=dp(4)) # needs 10 ratings if len(best_rating_box) is not 0: max(best_rating_box, key=best_rating_box.get).add_widget(best_rating_chip)
def build(self): self.how = "2" self.edges = True self.points = False self.file_eq = "" self.file_start = "" Window.size=(1400, 700) self.title = "Equation Engine" self.variables_list = []#"float x = 0.5", "float yy = 3.0", "float z 0", "float c 1", "float y = 0"] self.types_list = []#"float", "float", "float", "float", "float" ] self.values_list = []#"0.5", "3.0", "0", "1", "0" ] self.names_list = []#"x", "yy", "z", "c","y" ] #theme self.theme_cls.primary_palette = "Yellow" self.theme_cls.primary_hue = "500" self.theme_cls.theme_style = "Dark" self.screen = Screen() self.title_builder = Builder.load_string(title_helper) self.window_x_builder = Builder.load_string(window_x_helper) self.window_y_builder = Builder.load_string(window_y_helper) self.toolbar = Builder.load_string(toolbar) self.run_button = MDRectangleFlatButton(text = "Run", pos_hint={"center_x": 0.086-.025, "center_y": 0.217}, on_release = self.call_exec_algorithm) #self.save_button = MDRectangleFlatButton(text = "Save", # pos_hint={"center_x": 0.086, "center_y": 0.317}, # on_release = self.call_exec_algorithm) #self.load_button = MDRectangleFlatButton(text = "Load", # pos_hint={"center_x": 0.086, "center_y": 0.317}, # on_release = self.call_exec_algorithm) self.add_var_button = MDIconButton(icon = "plus", pos_hint={"center_x":0.9, "center_y": 0.61+.025}, on_release = self.add_variable) #self.remv_var_button = MDIconButton(icon = "minus", pos_hint={"center_x":0.912, "center_y":0.61+.025}) self.edges_icon = MDIcon(icon = "graph-outline", pos_hint={"center_x": 0.22-.02, "center_y":0.31-.092}, size_hint =(.1, .1)) self.points_icon = MDIcon(icon = "star-four-points-outline", pos_hint={"center_x": 0.25+0.02, "center_y":0.31-.092}, size_hint =(.1, .1)) self.var_table = MDDataTable(#check = True, pos_hint={"center_x":0.7, "center_y":0.575}, rows_num = 10, size_hint=(.2,0.55), column_data=[ ("Name", dp(15)), ("Type", dp(15)), ("Value", dp(15)),], row_data=[]) self.points_x_builder = Builder.load_string(point_x_helper) self.points_y_builder = Builder.load_string(point_y_helper) self.points_z_builder = Builder.load_string(point_z_helper) self.framerate_builder = Builder.load_string(framerate_helper) #script_builder self.algorithm_builder = Builder.load_string(algorithm_helper) self.start_builder = Builder.load_string(start_helper) self.edges_checkbox_builder = Builder.load_string(edges_checkbox) self.points_checkbox_builder = Builder.load_string(points_checkbox) self.update_all_widgets() return self.screen
def __init__(self, **kwargs): self._lbl_icon_left = MDIcon() self._lbl_icon_right = MDIcon() super().__init__(**kwargs) self.register_event_type("on_info_press")
def __init__(self, **kwargs): kwargs.update(auto_dismiss=False) # ToDo: Properly position progress indicator. super(BlockingPopup, self).__init__(**kwargs) self.ids.spacer_top_box.add_widget( MDIcon(icon='progress-upload', halign='center'))