def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) app = MDApp.get_running_app() scroll = ScrollView() Mlist = MDList() self.products = app.customconfig.load_products() for i in app.customconfig.load_orders(): item = OrderListItem(i) item.text = f"Order: {i.order_number}" item.secondary_text = f"Customer: {i.customer}" item.tertiary_text = f"Status: {i.status}" icon = IconRightWidget(icon="account-details") icon.bind(on_release=item.show_popup) item.add_widget(icon) item.bind(on_release=item.show_popup) Mlist.add_widget(item) layout = BoxLayout() layout.orientation = "vertical" toolbar = MDToolbar(title="Orders") toolbar.left_action_items = [["menu", lambda x: self.openNav()]] layout.add_widget(toolbar) scroll.add_widget(Mlist) layout.add_widget(scroll) self.action = MDFloatingActionButton(icon="plus", pos_hint={"center_x": 0.5}, on_release=self.openAction) layout.add_widget(self.action) self.add_widget(layout)
def ConstructTeamsList(self): self.USERNAME = self.root.current_screen.ids.username.text self.root.current = "teams" self.root.transition.direction = "left" network = threading.Thread(target=Networking) network.start() time.sleep(2) if incoming_data: for team_name in incoming_data: button = IconRightWidget(icon="remove_icon.png") info = TooltipMDIconButton( icon="information", tooltip_text=incoming_data[team_name][2], pos_hint={ "center_x": .5, "center_y": .5 }) button.add_widget(info) item = TwoLineAvatarIconListItem( text=team_name, secondary_text=incoming_data[team_name][0], secondary_theme_text_color='Custom', secondary_text_color=(1, 0, 0, 0.6), on_release=self.ListItemPressed) item.add_widget(button) tooltips[team_name] = info self.root.current_screen.ids.container.add_widget(item) list_items.append(item)
def build_list(self): self.Mlist.clear_widgets() app = MDApp.get_running_app() for i in app.customconfig.load_materials(): item = MaterialListItem(i, self.build_list) item.text = f"{i.name}" item.secondary_text = f"Cost: £{i.cost} Quantity: {i.quantity}" icon = IconRightWidget(icon="layers-outline") icon.bind(on_release=item.show_popup) item.add_widget(icon) item.bind(on_release=item.show_popup) self.Mlist.add_widget(item)
def build_list(self): self.Mlist.clear_widgets() app = MDApp.get_running_app() for i in app.customconfig.load_products(): item = ProductListItem(i, self.build_list) item.text = f"{i.name}" item.secondary_text = f"Raw Cost: £{round(i.cost, 2)}" icon = IconRightWidget(icon="layers-outline") icon.bind(on_release=item.show_popup) item.add_widget(icon) item.bind(on_release=item.show_popup) self.Mlist.add_widget(item)
def build_list(self): self.Mlist.clear_widgets() app = MDApp.get_running_app() for i in self.product.materials: item = MaterialListItem(i, self.build_list) item.text = f"{i.name}" item.secondary_text = f"Cost: £{round(i.unit_price, 2)}" icon = IconRightWidget(icon="layers-outline") icon.bind(on_release=item.show_popup) item.add_widget(icon) item.bind(on_release=item.show_popup) self.Mlist.add_widget(item)
def custom_on_enter(self, *args): self.manager.transition = WipeTransition(clearcolor=get_color_from_hex('#303030'), duration=0.2) self.ids.container.clear_widgets() connection = sqlite3.connect(os.path.join(getattr(MDApp.get_running_app(), 'user_data_dir'), 'read_runner.db')) cursor = connection.cursor() try: cursor.execute('SELECT * FROM texts') except sqlite3.OperationalError: copy('read_runner.db', os.path.join(getattr(MDApp.get_running_app(), 'user_data_dir'))) cursor.execute('SELECT * FROM texts') texts = cursor.fetchall() for text in texts: icon_left = IconLeftWidget(icon='book-open-variant' if text[3] == 'Book' else 'note-text-outline', on_release=partial(self.select_text, text[0])) icon_right = IconRightWidget(icon='dots-vertical', on_release=partial(self.show_text_sub_menu, text[0])) item = ThreeLineAvatarIconListItem(text=str(text[4]), secondary_text=str(text[5]), tertiary_text=f'Progress - {text[2]}%', on_release=partial(self.select_text, text[0])) item.add_widget(icon_left) item.add_widget(icon_right) self.ids.container.add_widget(item)
def __init__( self, taxon: Taxon = None, disable_button: bool = False, highlight_observed: bool = True, **kwargs, ): self.taxon = taxon # Set click event unless disabled if not disable_button: self.bind(on_touch_down=self._on_touch_down) self.disable_button = disable_button super().__init__( font_style='H6', text=taxon.name, secondary_text=taxon.rank, tertiary_text=taxon.preferred_common_name, **kwargs, ) # Add thumbnail self.add_widget( ThumbnailListItem( source=taxon.default_photo.thumbnail_url or taxon.icon_path)) # Add user icon if taxon has been observed by the user if highlight_observed and get_app().is_observed(taxon.id): self.add_widget(IconRightWidget(icon='account-search'))
def on_pre_enter(self): db.cmd_reset_connection() MDApp.get_running_app().root.ids.nav_drawer.set_state("close") try: cursor = db.cursor() previousOrderSQL_statement = "select * from orderDetailsTimeTable where studentUsername = "******"\"" + username_current + "\"" cursor.execute(previousOrderSQL_statement) self.resultsPreviousOrders = pd.DataFrame(cursor.fetchall()).rename(columns={0: "ordernum", 1: "studentUsername", 2: "hotelName", 3: "timeTakeAway", 4: "totalPay", 5: "orderStatus"}).sort_values(by="timeTakeAway",ascending=False).reset_index(drop=True) cursor.close() self.ids.historySummary.clear_widgets() for i in range(len(self.resultsPreviousOrders)): order_history = ThreeLineRightIconListItem( text = "Code : " + (self.resultsPreviousOrders.loc[i,"ordernum"][:5] if self.resultsPreviousOrders.loc[i, "orderStatus"] == 1 else "*****"), secondary_text = "TakeAway Time: " + str(self.resultsPreviousOrders.loc[i, "timeTakeAway"]), tertiary_text = "Hotel: " + self.resultsPreviousOrders.loc[i, "hotelName"], bg_color = (0,1,0,0.25) if self.resultsPreviousOrders.loc[i, "orderStatus"] == 1 else (0,0,0,0) if self.resultsPreviousOrders.loc[i, "orderStatus"] == 0 else (1,0,0,0.25) if self.resultsPreviousOrders.loc[i, "orderStatus"] == -1 else (0,0,1,0.25) ) right_icon = IconRightWidget(icon = 'plus', on_release = self.show_previous_order_selected, lbl_txt = str(self.resultsPreviousOrders.loc[i,"ordernum"][:5]) + str(self.resultsPreviousOrders.loc[i, "timeTakeAway"].to_pydatetime().date().year) + str(self.resultsPreviousOrders.loc[i, "timeTakeAway"].to_pydatetime().date().month) + str(self.resultsPreviousOrders.loc[i, "timeTakeAway"].to_pydatetime().date().day)) order_history.add_widget(right_icon) self.ids.historySummary.add_widget(order_history) except (KeyError, TypeError): pass
def __init__(self, item, *args, **kwargs): super(MyItem, self).__init__() self.id = item['id'] self.text = item['name'] self._no_ripple_effect = True self.icon = IconRightWidget(icon="delete", on_release=self.on_delete) self.add_widget(self.icon)
def load_list(self): c.execute("SELECT * FROM timer ORDER BY number DESC LIMIT 1 ") for i in c: self.load_name = i[0] self.load_hours = i[1] self.load_minutes = i[2] self.load_seconds = i[3] + self.load_minutes*60 self.Limit_for = True for i in range(8): if self.Limit_for == True: self.listit.append(self.lists) self.help.ids.leep.add_widget(self.lists) image = IconLeftWidget(icon="plus") imageright = IconRightWidget(icon="minus") self.lists.add_widget(image) self.lists.add_widget(imageright) imageright.bind(on_press=lambda x: self.delete_row((imageright.parent.parent))) self.Limit_for = False self.help.ids.frij.text = ""
def __init__(self, item, *args, **kwargs): super(MyItem, self).__init__() self.id = item['id'] self.text = item['name'] self.secondary_text = f"{item['state_short']}, \n {item['city']}" self._no_ripple_effect = True self.image = ImageLeftWidget() self.image.source = f"images/{item['state_short']}.png" self.add_widget(self.image) self.icon = IconRightWidget(icon="delete", on_release=self.on_delete) self.add_widget(self.icon)
def add_profile(profile, profileparam, profileparamstr): item = TwoLineAvatarIconListItem( text=profile, secondary_text="Settings: " + profileparamstr, on_release=partial(self.load_profile, profileparam), ) item.add_widget(IconRightWidget(icon="trash-can", on_release=partial(self.remove_profile, profile))) if 'default' in profileparam and profileparam['default'] == False: item.add_widget(IconLeftWidget(icon="star-outline", on_release=partial(self.set_to_default, profile))) else: item.add_widget(IconLeftWidget(icon="star", on_release=partial(self.unset_default, profile))) self.layout.add_widget(item)
def __init__(self, item, *args, **kwargs): super(MyItem, self).__init__() self.id = item['id'] self.text = item['name'] self.secondary_text = item['author'] #self.tertiary_text = item['genre'] self._no_ripple_effect = True self.image = ImageLeftWidget() self.image.source = "images/book.png" self.add_widget(self.image) self.icon = IconRightWidget(icon="delete", on_release=self.on_delete) self.add_widget(self.icon)
def __init__(self, **kwargs): super(inventoryList,self).__init__(**kwargs) self.focus_behavior = True self.bg_color = (1,0,1,0.5) self.height = 58 self._backbutton = OneLineAvatarIconListItem( bg_color = (1,0,1,0.5),on_press = lambda s: Intphone().app.createMe()) # Had to make custom height adjustment formula because of FloatLayout in a MDlist in a ScrollView self.add_widget(self._backbutton) self._backbutton.add_widget(IconRightWidget(icon="file-edit", on_press = lambda q: [self.show_alert_dialog_def(True,self.my_id())],text_color= (.2,.2,.2,1),theme_text_color= "Custom")) # how to add multiple func to >>on_press = lambda x: [self.show_alert_dialog_def(), self.my_id()] self._description1 = MDLabel(text= self._header,markup = True) self._description1.font_size = 18 self._backbutton.add_widget(self._description1,index = -1)
def dish_filler(self, hotel_selected): self.ids.list_dish.clear_widgets() self.cursor = db.cursor() search = "select dish, price from dish where username = \"" + hotel_selected + "\" and available = 1" self.cursor.execute(search) HotelScreen.dish_available_in_currentSelectedHotel = pd.DataFrame(self.cursor.fetchall()).rename(columns={0: "Dish", 1: "Price"}) self.cursor.close() for i in range(len(HotelScreen.dish_available_in_currentSelectedHotel)): l = IconLeftWidget(icon="minus", on_release=self.minus_dish) r = IconRightWidget(icon="plus", on_release=self.plus_dish) dish_toShow = TwoLineAvatarIconListItem(text=HotelScreen.dish_available_in_currentSelectedHotel.loc[i, "Dish"], secondary_text=str('\u20B9') + str(HotelScreen.dish_available_in_currentSelectedHotel.loc[i, "Price"])) dish_toShow.add_widget(l) dish_toShow.add_widget(r) self.ids.list_dish.add_widget(dish_toShow)
def __init__(self, item, *args, **kwargs): """ Konstruktoru se předává parametr item - datový objekt jedné osoby """ super(MyItem, self).__init__() # Předání informací o osobě do parametrů widgetu self.id = item['id'] self.text = item['name'] self.secondary_text = item['state'] self._no_ripple_effect = True # Zobrazení vlajky podle státu osoby self.image = ImageLeftWidget(source=f"images/{item['state']}.png") self.add_widget(self.image) # Vložení ikony pro vymazání osoby ze seznamu self.icon = IconRightWidget(icon="delete", on_release=self.on_delete) self.add_widget(self.icon)
def build(self): screen = Screen() scroll = ScrollView() my_list = MDList() for i in range(30): img = ImageLeftWidget(source='gerFlag.png') icon = IconRightWidget(icon='android') item = TwoLineAvatarIconListItem(text='Item ' + str(i), secondary_text='Hello world') item.add_widget(icon) item.add_widget(img) my_list.add_widget(item) scroll.add_widget(my_list) screen.add_widget(scroll) return screen
def add_item(model): description = self.modelinfos.get(model).get('description', '') description = 'No description' if description == '' else description item = TwoLineAvatarIconListItem(text=model, secondary_text=description, on_release=partial( self.set_model, model), size_hint=(None, None), size=(600, 1)) if model not in self.checked_models: self.checked_models[model] = False item.add_widget(LeftCheckbox(active=self.checked_models[model])) item.add_widget( IconRightWidget(icon='file-edit', on_release=partial(self.edit_description, model, description))) self.layout.add_widget(item)
def start_load_list(self): c.execute("SELECT * FROM timer ORDER BY number ASC") d = c.fetchall() for t in d: u = 0 self.bar = MDProgressBar(id="counter", max=t[3], value=t[3], size_hint=(0.7, 0), pos_hint={"center_x": 0.5, "center_y": 0.3}) lists = ProgressList(text=t[0], secondary_text=str(self.bar.value//60) + ":" + str(self.bar.value)+str(self.bar.value), tertiary_text=" ", bar=self.bar) self.help.ids.leep.add_widget(lists) image = IconLeftWidget(icon="plus") self.image2 = IconRightWidget(icon="minus",on_press=lambda x: self.delete_row(x.parent.parent)) self.listitdown.append(lists) lists.add_widget(self.image2) lists.add_widget(image) u += 1
def down_button(self, country, *args): try: self.clear_screen() except: pass self.phone_number_screen_manager.current = 'phone_number_list' numbers = self.pickle_list()[3][country] if len(numbers) == self.NORMAL: names = self.pickle_list()[0] self.container = SecondScreen() self.phone_container.add_widget(self.container) for i in range(self.NORMAL): self.container.add_widget( MDExpansionPanel( icon=f'images/emergency/{names[i]}.png', content=PhoneContent(numbers[i]), panel_cls=MDExpansionPanelOneLine(text=names[i]))) elif len(numbers) == self.EXTENDED: names = self.pickle_list()[1] self.container = SecondScreen() self.phone_container.add_widget(self.container) self.prov_item = OneLineAvatarIconListItem( text='Numery ws. koronawirusa w Województwach', on_release=self.clear_add_provinces) prov_item_icon_left = IconLeftWidget( icon='images/emergency/mask.png', size_hint=(0.9, 0.9)) prov_item_icon_right = IconRightWidget(icon='arrow-right') self.phone_list_container.add_widget(self.prov_item) self.prov_item.add_widget(prov_item_icon_left) self.prov_item.add_widget(prov_item_icon_right) for i in range(self.EXTENDED): self.container.add_widget( MDExpansionPanel( icon=f'images/emergency/{names[i]}.png', content=PhoneContent(numbers[i]), panel_cls=MDExpansionPanelOneLine(text=names[i])))
def new_message(self, name, text, image_location): new_message = TwoLineAvatarIconListItem(text=name, secondary_text=text) new_message.add_widget(ImageLeftWidget(source=image_location)) new_message.add_widget(IconRightWidget(icon="minus")) self.root.ids.list.add_widget(new_message)