def __init__(self, **kwargs): super(MenuScreen, self).__init__(**kwargs) self.layout = CustomLayout(scrollable=True) # back home button back_up_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(back_up_img, on_release_func=lambda: back(self.manager), alignment='left')) self.layout.add_item(lm.createLabel(text='TryInvest', font_size=30, rel_size=(1, .2))) self.layout.add_item(lm.createLabel(text='Portfolios', font_size=30, color=DARK_GREEN, rel_size=(1, .08), alignment='left')) # Portfolio Buttons self.portfolio_buttons = [] for i in range(MAX_PORTFOLIOS): self.portfolio_buttons.append(Button(text="Empty", bold=False, font_size=28, background_normal='', background_color=TRANSPARENT, on_release=self.portfolio_selected)) self.layout.add_widget(self.portfolio_buttons[i], rel_size=(1, .05), alignment='left') # Add portfolio Button self.add_portfolio_button = Button(text="+ New Portfolio", bold=False, font_size=28, background_normal='', background_color=TRANSPARENT, on_release=self.new_portfolio) self.layout.add_widget(self.add_portfolio_button, rel_size=(1, .1)) self.layout.add_item(lm.createSpace(rel_size=(1, .1))) # Delete portfolio Button self.delete_portfolio_button = Button(text="Delete Portfolio", bold=False, font_size=28, color=RED, background_normal='', background_color=TRANSPARENT, on_release=self.delete_portfolio) self.layout.add_widget(self.delete_portfolio_button, rel_size=(1, .1)) self.layout.add_item(lm.createLabel(text='About', font_size=30, rel_size=(1, .08))) self.add_widget(self.layout.create())
def __init__(self, **kwargs): super(NewPortfolioScreen, self).__init__(**kwargs) self.layout = CustomLayout(scrollable=True) # back button back_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(back_img, on_release_func=lambda: back(self.manager), alignment='left')) self.layout.add_item(lm.createLabel(text='Create Portfolio', font_size=35, rel_size=(1, .1))) self.layout.add_item(lm.createLabel(text='Name:', font_size=30, rel_size=(1, .05))) self.name_input = TextInput(text=f"New Portfolio", font_size=32) self.layout.add_widget(self.name_input, rel_size=(.8, .06)) self.layout.add_item(lm.createLabel(text='Starting Cash:', font_size=30, rel_size=(1, .05))) self.starting_cash_input = TextInput(font_size=32) self.layout.add_widget(self.starting_cash_input, rel_size=(.8, .06)) self.layout.add_item(lm.createSpace(rel_size=(1, .15))) self.create_button = Button(text="Create", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=self.create) self.layout.add_widget(self.create_button, rel_size=(.7, .1)) self.add_widget(self.layout.create())
def reload(self): """ Reset the home screen with a new CustomLayout """ self.layout = CustomLayout(scrollable=False) # menu button menu_img = lm.createImage(source='images/menu.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(menu_img, on_release_func=self.show_menu, alignment='left')) self.personal_value = lm.createLabel(text= "$-,---.--", font_size= 50, rel_size=(1, .1)) self.personal_value_change = lm.createLabel(text= "+0.00%", font_size= 25, rel_size=(1, .05)) self.cash_value = lm.createLabel(text= "$---.--", font_size= 50, rel_size=(1, .1)) self.layout.add_item(self.personal_value) self.layout.add_item(self.personal_value_change) self.layout.add_item(lm.createLabel(text='Personal Value', font_size=20, rel_size=(1, .05), color= DARK_GREEN)) self.layout.add_item(self.cash_value) self.layout.add_item(lm.createLabel(text='Cash', font_size=20, rel_size=(1, .05), color= DARK_GREEN)) self.rendered_layout = self.layout.create(size_hint=(1,.3), pos_hint={"top": 1}) self.add_widget(self.rendered_layout) self.share_section = None
def create_share_button(self, icon, symbol, *labels): col = [] font_size = 20 col.append(lm.createLabel(text=symbol, font_size=font_size, rel_size=(.1,.02))) col.append(lm.createImage(icon, rel_size=lm.rel_square(rel_width=.3))) for label in labels: col.append(lm.createLabel(text=label, font_size=font_size, rel_size=(.1, .02))) font_size *= .5 out = CustomButton(*col, spacing=0, padding=0) out.bind_on_release(lambda: self.share_pressed(symbol)) return out
def __init__(self, **kwargs): super(StockDetailScreen, self).__init__(**kwargs) self.layout = CustomLayout() back_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(back_img, on_release_func=lambda: back(self.manager), alignment='left')) self.stock_name = lm.createLabel(bold= False, rel_size= (1, .1), text_rel_size = (.95, .1), halign='center', valign='middle') self.layout.add_item(self.stock_name) self.layout.add_widget(Button(text="TRADE", bold=True, font_size=40, background_color=DARK_GREEN, on_release=self.trade), rel_size=(.8, .1)) self.current_price = lm.createLabel(font_size= 50, rel_size= (1, .1)) self.layout.add_item(self.current_price) self.center_image = lm.createImage(source='images/up_arrow.png', rel_size=lm.rel_square(rel_width=.5)) self.layout.add_item(self.center_image) self.stock_symbol = lm.createLabel(font_size= 50, rel_size= (1, .1)) self.layout.add_item(self.stock_symbol) self.num_shares = lm.createLabel(font_size= 28, rel_size= (1, .1)) self.layout.add_item(self.num_shares) self.layout.add_item(lm.createLabel(text = 'Past Week Performace', font_size= 28, rel_size= (1, .1))) # graph self.graph = Graph(x_ticks_major=1, tick_color = (0,0,0,.5), xlabel='Days', y_grid_label=True, x_grid_label=True, precision='%.2f', padding=5, x_grid=True, y_grid=True, xmin=-5, xmax=-1, ymin=0, ymax=100, border_color = (0,0,0,0), label_options = {'color': (0,0,0,1)}) self.plot = [(i-7, .3*i*100) for i in range(7)] self.layout.add_widget(self.graph, rel_size=(.90, .3)) self.add_widget(self.layout.create())
def __init__(self, **kwargs): super(TradeScreen, self).__init__(**kwargs) self.current_symbol = current_stock_symbol self.layout = CustomLayout() back_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(back_img, on_release_func=lambda: back(self.manager), alignment='left')) self.cash_value = lm.createLabel(text= "$---.--", font_size= 50, rel_size=(1, .06)) self.layout.add_item(self.cash_value) self.layout.add_item(lm.createLabel(text='Cash', font_size=20, rel_size=(1, .05), color= DARK_GREEN)) self.buy_button = Button(text="BUY", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=self.buy_sell_button) self.sell_button = Button(text="SELL", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=self.buy_sell_button) self.layout.add_widget_row((.4, .1), self.buy_button, self.sell_button) self.symbol_search = SymbolSearch(text='Search', trade_screen=self) self.layout.add_item(lm.createSpace((1,.05))) self.layout.add_widget(self.symbol_search, rel_size=(.8, .06)) self.current_price_label = lm.createLabel(font_size= 50, rel_size= (1, .1)) self.current_price = 0 self.layout.add_item(self.current_price_label) self.more_info_button = Button(text="More Info", bold=True, font_size=12, background_normal='', background_color=DARK_GREEN, on_release=self.more_info, disabled=True) self.layout.add_widget(self.more_info_button, rel_size=(.2, .04)) # You own ## Shares self.num_shares = 0 self.num_shares_owned = lm.createLabel(rel_size= (1, .1)) self.layout.add_item(self.num_shares_owned) self.num_of_shares_label = lm.createLabel(text_rel_size=(.5, .1)) self.num_share_selection = CustomLayoutItem(ShareQuantityInput(trade_screen=self), rel_size=(.225, .06)) anchor = AnchorLayout(size_hint=(.5, .1), anchor_x='center') anchor.add_widget(self.num_share_selection.widget) anchor_item = CustomLayoutItem(anchor, rel_size=(.5, .07)) self.layout.add_item_row((1, .1), self.num_of_shares_label, anchor_item, alignment='center') # Estimated Value: $##.## self.estimated_value_label = lm.createLabel(rel_size= (1, .1), font_size=20) self.layout.add_item(self.estimated_value_label) self.confirm_button = Button(text="Confirm", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=self.confirm_trade) self.layout.add_widget(self.confirm_button, rel_size=(.7, .1)) self.add_widget(self.layout.create())
def __init__(self, **kwargs): super(ConfirmTradeScreen, self).__init__(**kwargs) self.layout = CustomLayout() back_img = lm.createImage(source='images/back.png', rel_size=lm.rel_square(rel_width=.1)) self.layout.add_item(CustomButton(back_img, on_release_func=lambda: back(self.manager), alignment='left')) self.label = lm.createLabel(font_size = 20, rel_size=(.9, .3)) self.layout.add_item(self.label) self.yes_button = Button(text="YES", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=self.trade_confirmed) self.no_button = Button(text="BACK", bold=True, font_size=40, background_normal='', background_color=DARK_GREEN, on_release=lambda btn: back(self.manager)) self.layout.add_widget_row((.3, .08), self.yes_button, self.no_button) self.add_widget(self.layout.create())