def __init__(self, **kwargs): super().__init__(**kwargs) self.card_shifted = None # --------------------------------------------------------------------- if self.with_image: self.ids.root_box.clear_widgets() self._shift_x = dp(5) self.ids.root_box.x = self._shift_x self.card_size[1] = dp(335) card_post = CardPostImage( source=self.source, text_post=self.text_post, tile_text=self.tile_text, tile_font_style=self.tile_font_style, tile_text_color=self.tile_text_color, callback=self.callback, ) for name_icon in self.buttons: card_post.ids.box_buttons.add_widget( MDIconButton( icon=name_icon, on_release=lambda x, y=name_icon: self.callback(x, y), )) self.ids.root_box.add_widget(card_post) # --------------------------------------------------------------------- if len(self.right_menu) and not self.with_image: self.ids.title_box.add_widget( MDIconButton(icon="dots-vertical", on_release=self.open_menu)) # --------------------------------------------------------------------- if self.likes_stars: box_likes_stars_right = AnchorLayout(anchor_x="right", size_hint_y=None, height=dp(30)) self.box_likes_stars = BoxLayout(spacing=(dp(5))) self.box_likes_stars.add_widget(Widget()) for i in range(5): # adding stars like_star = MDIconButton( icon="star-outline", size_hint=(None, None), size=(dp(30), dp(30)), id=str(i), on_release=lambda x, y=i: self._update_likes_stars(y), ) self.box_likes_stars.add_widget(like_star) self._list_instance_likes_stars.append(like_star) box_likes_stars_right.add_widget(self.box_likes_stars) self.ids.root_box.remove_widget(self.ids.sep) self.add_widget(box_likes_stars_right)
def update_action_bar(self, action_bar, action_bar_items): action_bar.clear_widgets() new_width = 0 for item in action_bar_items: new_width += dp(48) if self.dropdown: dropdown_cls = item[1] action_bar.add_widget( MenuButton( icon=item[0], dropdown_cls=dropdown_cls, opposite_colors=True, text_color=self.specific_text_color, theme_text_color='Custom', on_release=lambda x: self.callback(x) ) ) else: action_bar.add_widget( MDIconButton( icon=item[0], on_release=item[1], opposite_colors=True, text_color=self.specific_text_color, theme_text_color='Custom' ) ) action_bar.width = new_width
def update_action_bar(self, action_bar, action_bar_items): action_bar.clear_widgets() new_width = 0 for item in action_bar_items: new_width += dp(48) action_bar.add_widget(MDIconButton(icon=item[0], on_release=item[1], opposite_colors=True)) action_bar.width = new_width
def update_action_bar(self, action_bar, action_bar_items): action_bar.clear_widgets() new_width = 0 for item in action_bar_items: new_width += dp(48) action_bar.add_widget( MDIconButton(icon=item[0], on_release=item[1], opposite_colors=True, text_color=self.specific_text_color, theme_text_color='Custom')) action_bar.width = new_width
def __init__(self, **kwargs): super(ListRightBox, self).__init__() self.expense_id = kwargs['expense_id'] self.add_widget( MDLabel(text=kwargs['right_text'], halign='right', theme_text_color='Primary', size_hint_x=.9)) self.add_widget( MDIconButton(icon='delete-outline', size_hint_x=.1, on_release=self.on_release))
def on_touch_down(self, touch): if self.collide_point(*touch.pos): self.callback(self.label) md_choose_chip = self.parent if md_choose_chip.__class__ is MDChooseChip: if md_choose_chip.selected_chip: md_choose_chip.selected_chip.color =\ md_choose_chip.selected_chip_color md_choose_chip.selected_chip = self md_choose_chip.selected_chip_color = self.color self.color = self.theme_cls.primary_color if self.check: if not len(self.ids.box_check.children): self.ids.box_check.add_widget( MDIconButton(icon='check', size_hint_y=None, height=dp(26), disabled=True)) else: check = self.ids.box_check.children[0] self.ids.box_check.remove_widget(check)
def add_attach(self, attach_list): self.ids.box_attach.clear_widgets() for text_link in attach_list: box_attach = BoxLayout(spacing=dp(10)) box_attach.add_widget( MDIconButton( icon='link', size_hint=(None, None), size=(dp(50), dp(50)), pos_hint={'center_y': .5}, disabled=True ) ) box_attach.add_widget( MDLabel( text=text_link, theme_text_color='Primary', markup=True, on_ref_press=self.tap_on_link ) ) self.ids.box_attach.add_widget(box_attach) self.height = dp(100 * attach_list.__len__())
def add_row(self, row_data): '''Adds a new row to the parent''' global counter self.rows += 1 n = 0 # Add a checkbox along with row data checkbox = ItemCheckbox(size_hint_y=None, height=dp(50)) # Generate hash using the row data and use it as Id for the row in the Data Table checkbox.id = self.generate_id(row_data) # if checkbox.id == self.selected_id: # checkbox.active = True checkbox.bind(active=self.select_row) self.bodyGrid.add_widget(checkbox) # Add a row cell for each item in the first row for i, item in enumerate(row_data.values()): cell = RowLabel(font_style='Body1', fullfilled=self.fullfilled, theme_text_color='Primary', text=str(item), size_hint_y=None, halign='left', height=dp(50), id=("row_" + str(counter) + "_col_" + str(n))) cell_width = Window.size[0] * cell.size_hint_x cell.text_size = (cell_width - 30, None) cell.texture_update() # Change background color if this cell belongs to the column that is used for sorting if self.sorted_column > -1 and self.sorted_column == n: cell.bgcolor = cell.theme_cls.divider_color # self.add_widget(cell) self.bodyGrid.add_widget(cell) n += 1 try: if len(self.action): from kivymd.button import MDIconButton action_col_size = dp(40) * len(self.action) if len( self.action) > 2 else dp(40) * 2 action_button = ActionColumn(disabled=False, size_hint_x=None, size=(action_col_size, 0), size_hint_y=None, height=dp(50)) action_button.id = self.generate_id(row_data) for j, item in enumerate(self.action): if item == 'edit': edit_button = MDIconButton( id=str(i) + str(j), icon='pencil-box-outline', theme_text_color="Custom", text_color=self.theme_cls.primary_color) edit_button.bind(on_press=self.edit_press) action_button.add_widget(edit_button) elif item == 'delete': delete_button = MDIconButton(id=str(i) + str(j), icon='close-box-outline', theme_text_color="Error") delete_button.bind(on_press=self.delete_press) action_button.add_widget(delete_button) elif item == 'copy': copy_button = MDIconButton(id=str(i) + str(j), icon='content-copy', theme_text_color="Primary") copy_button.bind(on_press=self.copy_press) action_button.add_widget(copy_button) else: info_button = MDIconButton( id=str(i) + str(j), icon='information', theme_text_color="Custom", text_color=self.theme_cls.primary_color) info_button.bind(on_press=self.info_press) action_button.add_widget(info_button) # self.add_widget(action_button) self.bodyGrid.add_widget(action_button) except Exception as e: print("exception while action column ", str(e)) counter += 1