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 on_start(self): settings = self.store.get('settings') self.auto_clear = settings['auto_clear'] self.theme_cls.theme_style = settings['color_mode'] self.screen.ids.screen_manager.get_screen( 'settings' ).ids.color_mode.active = settings['switch_color_mode_value'] self.screen.ids.screen_manager.get_screen( 'settings' ).ids.clear_mode.active = settings['switch_clear_mode_value'] self.active_data_items = self.store['items_data']['active'] self.history_data_items = self.store['items_data']['history'] for item in self.active_data_items: self.screen.ids.screen_manager.get_screen( 'main').ids.scroll_active.add_widget( TwoLineAvatarIconListItem( text=item['text'], secondary_text=item['secondary_text'], on_release=self.click_on_active_list_item)) for item in self.history_data_items: self.screen.ids.screen_manager.get_screen( 'main').ids.scroll_history.add_widget( TwoLineAvatarIconListItem( text=item['text'], secondary_text=item['secondary_text'], on_release=self.click_on_history_list_item))
def add_new_zutat(self, new_zutat): #print("Ok!") self.new_zutat_zeile = TwoLineAvatarIconListItem( text=new_zutat.name, secondary_text=str(new_zutat.get_guid())) self.new_zutat_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.zutaten_list.add_widget( self.new_zutat_zeile)
def init_stocks_ist(self): self.root.get_screen('main').ids.main_list.clear_widgets() for stock in self.my_stocks.get_stocks(): self.neue_speise_zeile = TwoLineAvatarIconListItem( text=stock[0], secondary_text=str(stock[1]), #on_touch_up=self.test ) self.neue_speise_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.main_list.add_widget( self.neue_speise_zeile)
def add_new_speise(self, new_speise): #print("Ok!") #self.speisen.append(new_speise) self.neue_speise_zeile = TwoLineAvatarIconListItem( text=new_speise.name, secondary_text=str(new_speise.get_guid()), #on_touch_up=self.test ) self.neue_speise_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.speisen_list.add_widget( self.neue_speise_zeile)
def lade_speisen_zutaten(self, speise_guid): print("lade_speisen_zutaten: " + speise_guid) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.clear_widgets() speise = self.kochbuch.get_speise(speise_guid) print("Zutaten in Speise: " + str(len(speise.get_zutaten()))) for zutat in speise.get_zutaten(): self.new_zutat_zeile = TwoLineAvatarIconListItem( text=zutat.get_name(), secondary_text=zutat.get_guid()) self.new_zutat_zeile.bind(on_press=self.list_item_click_speise) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.add_widget( self.new_zutat_zeile)
def add_new_speise_zutat(self): print(self.root.get_screen('edit_speise').ids.sp_guid.text) new_zutat = Zutat("Neue Zutat", "", "", "", "") self.new_zutat_zeile = TwoLineAvatarIconListItem( text=new_zutat.name, secondary_text=str(new_zutat.get_guid())) self.new_zutat_zeile.bind(on_press=self.list_item_click_speise) self.kochbuch.get_speise( self.root.get_screen('edit_speise').ids.sp_guid.text).add_zutat( new_zutat) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.add_widget( self.new_zutat_zeile)
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 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 generate_list(self, *args): with open("grocery_store.json") as f: recipe_book = json.load(f) for key in recipe_book.keys(): self.list_item = TwoLineAvatarIconListItem( text=f"{key}", secondary_text=str(len(recipe_book[key])) + ' ingredients', on_release=lambda x=key: self.pressed(x)) #self.list_item = IconRightWidget('plus') #add new page screen = NewPage(name=key) App.get_running_app().root.add_widget(screen) self.ids.container.add_widget(self.list_item)
def dialog_new_item_ok(self, *args): item = self.dialog_new_item.content_cls.ids.item.text number = self.dialog_new_item.content_cls.ids.number.text details = self.dialog_new_item.content_cls.ids.details.text self.screen.ids.screen_manager.get_screen( 'main').ids.scroll_active.add_widget( TwoLineAvatarIconListItem( text=item + ' ' + number, secondary_text=details, on_release=self.click_on_active_list_item)) self.active_data_items.append({ 'text': item + ' ' + number, 'secondary_text': details }) self.dialog_new_item.dismiss()
def list_item_click(self, listitem): self.my_stocks.set_current_stock_isin(listitem.secondary_text) print(listitem.secondary_text) self.root.get_screen('div_details').ids.div_detail_list.clear_widgets() for i, row in self.borsaitaliana.get_all_dividends().iterrows(): #print(f"{row['DataPagamento']}") if f"{row['ISIN']}" == self.my_stocks.get_current_stock_isin(): self.neue_div_zeile = TwoLineAvatarIconListItem( text=f"{row['Provento']}", secondary_text=f"{row['DataPagamento']}", #on_touch_up=self.test ) #self.neue_div_zeile.bind(on_press=self.list_item_click) self.root.get_screen( 'div_details').ids.div_detail_list.add_widget( self.neue_div_zeile) self.root.current = "div_details" self.root.transition.direction = "left"
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 dialog_complete_yes(self, *args): self.dialog_complete.dismiss() self.screen.ids.screen_manager.get_screen( 'main').ids.scroll_active.remove_widget(self.buffer_item) self.active_data_items.remove({ 'text': self.buffer_item.text, 'secondary_text': self.buffer_item.secondary_text }) if not self.auto_clear: self.buffer_item = TwoLineAvatarIconListItem( text=self.buffer_item.text, secondary_text=self.buffer_item.secondary_text, on_release=self.click_on_history_list_item) self.screen.ids.screen_manager.get_screen( 'main').ids.scroll_history.add_widget(self.buffer_item) self.history_data_items.append({ 'text': self.buffer_item.text, 'secondary_text': self.buffer_item.secondary_text }) self.buffer_item = None
def new_message(self, name, message, image_name): new_message = TwoLineAvatarIconListItem(text=name, secondary_text=message) new_message.add_widget(ImageLeftWidget(source=image_name)) self.root.ids.list.add_widget(new_message)
def new_message_private(self, name, message): new_message = TwoLineAvatarIconListItem(text=name, secondary_text=message) new_message.add_widget(IconLeftWidget(icon="message-outline")) self.chatscreen.ids.privatelist.add_widget(new_message)
class MainApp(MDApp): def on_start(self): # Set colors self.theme_cls.primary_palette = 'Blue' self.active_tab = "Speisen" self.kochbuch = Kochbuch("Kochbuch") self.lager = Lager("Lager") self.lade_speisen() self.lade_zutaten() def build(self): A = ScreenManagement() A.current = 'main' return A def on_tab_switch(self, instance_tabs, instance_tab, instance_tab_label, tab_text): self.active_tab = tab_text #instance_tab.ids.label.text = tab_text return def lade_speisen(self): self.root.get_screen('main').ids.speisen_list.clear_widgets() for speise in self.kochbuch.get_speisen(): self.add_new_speise(speise) def lade_zutaten(self): self.root.get_screen('main').ids.zutaten_list.clear_widgets() for zutat in self.lager.get_zutaten(): self.add_new_zutat(zutat) def lade_speisen_zutaten(self, speise_guid): print("lade_speisen_zutaten: " + speise_guid) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.clear_widgets() speise = self.kochbuch.get_speise(speise_guid) print("Zutaten in Speise: " + str(len(speise.get_zutaten()))) for zutat in speise.get_zutaten(): self.new_zutat_zeile = TwoLineAvatarIconListItem( text=zutat.get_name(), secondary_text=zutat.get_guid()) self.new_zutat_zeile.bind(on_press=self.list_item_click_speise) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.add_widget( self.new_zutat_zeile) def save_speise(self): self.kochbuch.get_speise( self.root.get_screen('edit_speise').ids.sp_guid.text).set_name( self.root.get_screen('edit_speise').ids.sp_name.text) self.lade_speisen() self.root.current = "main" self.root.transition.direction = "right" def save_zutat(self): zutat = self.lager.get_zutat( self.root.get_screen('edit_zutat').ids.zt_guid.text) zutat.set_name(self.root.get_screen('edit_zutat').ids.zt_name.text) zutat.set_einheit( self.root.get_screen('edit_zutat').ids.zt_einheit.text) zutat.set_preis(self.root.get_screen('edit_zutat').ids.zt_preis.text) zutat.set_menge(self.root.get_screen('edit_zutat').ids.zt_menge.text) zutat.set_mindest( self.root.get_screen('edit_zutat').ids.zt_mindest.text) self.lade_zutaten() self.root.current = "main" self.root.transition.direction = "right" def save_speise_zutat(self): speise_guid = self.root.get_screen( 'edit_speise_zutat').ids.zt_speise_guid.text zutat_guid = self.root.get_screen('edit_speise_zutat').ids.zt_guid.text zutat = self.kochbuch.get_speise(speise_guid).get_zutat(zutat_guid) zutat.set_name( self.root.get_screen('edit_speise_zutat').ids.zt_name.text) zutat.set_einheit( self.root.get_screen('edit_speise_zutat').ids.zt_einheit.text) zutat.set_preis( self.root.get_screen('edit_speise_zutat').ids.zt_preis.text) zutat.set_menge( self.root.get_screen('edit_speise_zutat').ids.zt_menge.text) zutat.set_mindest( self.root.get_screen('edit_speise_zutat').ids.zt_mindest.text) # self.lade_speise_zutaten() self.root.current = "edit_speise" self.root.transition.direction = "right" def add_new_speise(self, new_speise): #print("Ok!") #self.speisen.append(new_speise) self.neue_speise_zeile = TwoLineAvatarIconListItem( text=new_speise.name, secondary_text=str(new_speise.get_guid()), #on_touch_up=self.test ) self.neue_speise_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.speisen_list.add_widget( self.neue_speise_zeile) def add_new_zutat(self, new_zutat): #print("Ok!") self.new_zutat_zeile = TwoLineAvatarIconListItem( text=new_zutat.name, secondary_text=str(new_zutat.get_guid())) self.new_zutat_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.zutaten_list.add_widget( self.new_zutat_zeile) def add_new_speise_zutat(self): print(self.root.get_screen('edit_speise').ids.sp_guid.text) new_zutat = Zutat("Neue Zutat", "", "", "", "") self.new_zutat_zeile = TwoLineAvatarIconListItem( text=new_zutat.name, secondary_text=str(new_zutat.get_guid())) self.new_zutat_zeile.bind(on_press=self.list_item_click_speise) self.kochbuch.get_speise( self.root.get_screen('edit_speise').ids.sp_guid.text).add_zutat( new_zutat) self.root.get_screen( 'edit_speise').ids.edit_speise_zutaten_list.add_widget( self.new_zutat_zeile) def add_new(self): if self.active_tab == "Speisen": neue_speise = Speise("Omlette NEW!") self.kochbuch.add_speise(neue_speise) self.add_new_speise(neue_speise) else: neue_zutat = Zutat("Zutat NEW!", "", "", "", "") self.lager.add_zutat(neue_zutat) self.add_new_zutat(neue_zutat) def list_item_click(self, listItem): if self.root.current == "main": if self.active_tab == "Speisen": print("list_item_click Speise: ", listItem.secondary_text) speise = self.kochbuch.get_speise(listItem.secondary_text) self.root.get_screen( 'edit_speise').ids.sp_name.text = speise.get_name() self.root.get_screen( 'edit_speise').ids.sp_guid.text = speise.get_guid() self.lade_speisen_zutaten(listItem.secondary_text) self.root.current = "edit_speise" self.root.transition.direction = "left" if self.active_tab == "Zutaten": print("Zutat: ", listItem.secondary_text) zutat = self.lager.get_zutat(listItem.secondary_text) self.root.get_screen( 'edit_zutat').ids.zt_name.text = zutat.get_name() self.root.get_screen( 'edit_zutat').ids.zt_guid.text = zutat.get_guid() self.root.get_screen( 'edit_zutat').ids.zt_einheit.text = zutat.get_einheit() self.root.get_screen( 'edit_zutat').ids.zt_preis.text = zutat.get_preis() self.root.get_screen( 'edit_zutat').ids.zt_mindest.text = zutat.get_mindest() self.root.get_screen( 'edit_zutat').ids.zt_menge.text = zutat.get_menge() self.root.current = "edit_zutat" self.root.transition.direction = "left" def list_item_click_speise(self, listItem): print("Zutat: ", listItem.secondary_text) speise_guid = self.root.get_screen('edit_speise').ids.sp_guid.text zutat = self.kochbuch.get_speise(speise_guid).get_zutat( listItem.secondary_text) self.root.get_screen( 'edit_speise_zutat').ids.zt_name.text = zutat.get_name() self.root.get_screen( 'edit_speise_zutat').ids.zt_speise_guid.text = speise_guid self.root.get_screen( 'edit_speise_zutat').ids.zt_guid.text = zutat.get_guid() self.root.get_screen( 'edit_speise_zutat').ids.zt_einheit.text = zutat.get_einheit() self.root.get_screen( 'edit_speise_zutat').ids.zt_preis.text = zutat.get_preis() self.root.get_screen( 'edit_speise_zutat').ids.zt_mindest.text = zutat.get_mindest() self.root.get_screen( 'edit_speise_zutat').ids.zt_menge.text = zutat.get_menge() self.root.current = "edit_speise_zutat" self.root.transition.direction = "left" def del_current(self): if self.root.current == "edit_speise": print(self.root.get_screen('edit_speise').ids.sp_guid.text) self.kochbuch.del_speise( self.root.get_screen('edit_speise').ids.sp_guid.text) self.kochbuch.save() self.lade_speisen() self.root.current = "main" self.root.transition.direction = "right" if self.root.current == "edit_zutat": zt_guid = self.root.get_screen('edit_zutat').ids.zt_guid.text print(zt_guid) self.lager.del_zutat(zt_guid) self.lager.save() self.lade_zutaten() self.root.current = "main" self.root.transition.direction = "right" if self.root.current == "edit_speise_zutat": speise_guid = self.root.get_screen( 'edit_speise_zutat').ids.zt_speise_guid.text zutat_guid = self.root.get_screen( 'edit_speise_zutat').ids.zt_guid.text self.kochbuch.get_speise(speise_guid).del_zutat(zutat_guid) self.kochbuch.save() self.lade_speisen_zutaten(speise_guid) self.root.current = "edit_speise" self.root.transition.direction = "right" def tb_option_click(self): # dropdown = DropDown() # for index in range(10): # # Adding button in drop down list # btn = Button(text ='Value % d' % index, size_hint_y = None, height = 40) # # binding the button to show the text when selected # btn.bind(on_release = lambda btn: dropdown.select(btn.text)) # # then add the button inside the dropdown # dropdown.add_widget(btn) # dropdown.bind(on_select = lambda instance, x: setattr(mainbutton, 'text', x)) # runTouchApp(self.root.get_screen('edit_zutat')) if self.root.current == "main": print("Konfig!") self.kochbuch.save() self.lager.save() def sort_speisen(self): print("sort") #self.root.ids.speisen_list.so def nav_main(self): self.root.current = "main" self.root.transition.direction = "right" def nav_speise_edit(self): self.root.current = "edit_speise" self.root.transition.direction = "right"
class App(MDApp): def build(self): A = ScreenManagement() A.current = 'main' #conn = sqlite3.connect(MYConfig().get_db_name()) #c = conn.cursor() #c.close() #conn.close() # #Tabelle für Stocks anlegen #c.execute('CREATE TABLE IF NOT EXISTS STOCKS (Name, ISIN, Ticker)') #conn.commit() # #Tabelle für History anlegen # c.execute('CREATE TABLE IF NOT EXISTS Historie (Date, ISIN, Ticker, Open, High, Low, Close, AdjClose, Volume, Valuta)') # conn.commit() # #Tabelle für Div anlegen # c.execute('CREATE TABLE IF NOT EXISTS Dividends (DataDividendo, ISIN, Provento, Valuta, DataPagamento, TipoPagamento)') # conn.commit() return A def on_start(self): self.my_config = MYConfig() self.my_stocks = myStocks() self.borsaitaliana = BorsaItaliana() self.yahoo = YahooAPI() self.init_stocks_ist() # Backup Database if path.exists(self.my_config.get_db_name()): shutil.copyfile( self.my_config.get_db_name(), self.my_config.get_db_name().replace( ".db", "_" + date.today().strftime("%Y%m%d") + ".db")) def init_stocks_ist(self): self.root.get_screen('main').ids.main_list.clear_widgets() for stock in self.my_stocks.get_stocks(): self.neue_speise_zeile = TwoLineAvatarIconListItem( text=stock[0], secondary_text=str(stock[1]), #on_touch_up=self.test ) self.neue_speise_zeile.bind(on_press=self.list_item_click) self.root.get_screen('main').ids.main_list.add_widget( self.neue_speise_zeile) def list_item_click(self, listitem): self.my_stocks.set_current_stock_isin(listitem.secondary_text) print(listitem.secondary_text) self.root.get_screen('div_details').ids.div_detail_list.clear_widgets() for i, row in self.borsaitaliana.get_all_dividends().iterrows(): #print(f"{row['DataPagamento']}") if f"{row['ISIN']}" == self.my_stocks.get_current_stock_isin(): self.neue_div_zeile = TwoLineAvatarIconListItem( text=f"{row['Provento']}", secondary_text=f"{row['DataPagamento']}", #on_touch_up=self.test ) #self.neue_div_zeile.bind(on_press=self.list_item_click) self.root.get_screen( 'div_details').ids.div_detail_list.add_widget( self.neue_div_zeile) self.root.current = "div_details" self.root.transition.direction = "left" def nav_main(self): self.root.current = "main" self.root.transition.direction = "right" def get_date(self, date, start): ''' :type date: <class 'datetime.date'> ''' self.root.get_screen('main').ids.dtEnd.text = str(date) print(date) def show_date_picker_start(self): date_dialog = MDDatePicker(callback=self.get_date) date_dialog.open() def call_ticker(self): dh = self.yahoo now = datetime.datetime.strptime( self.root.get_screen('main').ids.dtEnd.text, "%Y-%m-%d" ) #datetime.datetime(2021, 1, 28) # get data up to 6/28/2020 then = datetime.datetime.strptime( self.root.get_screen('main').ids.dtStart.text, "%Y-%m-%d" ) #datetime.datetime(2020, 1, 1) # get data from 01/01/2020 df = dh.get_ticker_data(self.my_stocks.get_current_stock_ticker(), then, now) print(df) def call_div(self): dh = self.borsaitaliana print(dh.count()) df = dh.get_new_ticker_div(self.my_stocks.get_current_stock_isin()) print(dh.count()) print(df.count()[0]) #print(dh.load()) def call_all_ticker(self): dh = self.yahoo now = datetime.datetime.strptime( self.root.get_screen('main').ids.dtEnd.text, "%Y-%m-%d" ) #datetime.datetime(2021, 1, 28) # get data up to 6/28/2020 then = datetime.datetime.strptime( self.root.get_screen('main').ids.dtStart.text, "%Y-%m-%d" ) #datetime.datetime(2020, 1, 1) # get data from 01/01/2020 df = dh.get_ticker_data( self.root.get_screen('main').ids.txt_ticker.text, then, now) print(df) def call_all_div(self): dh = self.borsaitaliana for stock in self.my_stocks.get_stocks(): df = dh.get_new_ticker_div( self.my_stocks.get_isin_from_name(stock[0])) try: print(df.count()[0]) except: pass #print(dh.load()) def print_all_div(self): dh = self.borsaitaliana df = dh.get_all_dividends() print(df) #print(dh.load()) def set_csv_path(self): self.my_config.set_csv_path( self.root.get_screen('main').ids.txt_ticker.text) print(self.my_config.get_csv_path()) def save_div_csv_div(self): dh = self.borsaitaliana dh.save_to_csv(self.my_config.get_csv_path() + "div_" + date.today().strftime("%Y%m%d") + ".csv") pass def test_1(self): print(self.my_stocks.get_current_stock_isin()) print(self.my_stocks.get_current_stock_name()) #self.root.get_screen('main').ids.btn_test_1.text= "Save All Div ("+str(self.borsaitaliana.get_all_dividends().count()[0])+")" def test_2(self): pass def test_3(self): pass def test_4(self): pass
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)