def build(self): # App is built as a tabbed panel with three tabs: # Navigation, Status, and Media. These allow quick # access to the things you actually want to do in # a car without excessive UI navigation. tp = TabbedPanel() tp.do_default_tab = False tp.tab_pos = 'bottom_mid' tp.tab_width = Window.width / 3 nav = TabbedPanelHeader(text='Nav') status = TabbedPanelHeader(text='Status') media = TabbedPanelHeader(text='Media') tp.add_widget(nav) tp.add_widget(status) tp.add_widget(media) #nav.content = Label(text = 'Nav system goes here') #status.content = Label(text = 'Performance, health, and eco stats go here') #media.content = Label(text = 'Media player goes here') # Each tab's content is implemented in a tab above. nav.content = KVMaps() status.content = Performance() media.content = MusicPlayer() return tp
def __init__(self, **kwargs): super(ButtonApp, self).__init__(**kwargs) tmp_btn = HoverButton(text='BUTTON 1', size_hint=(None, None), size=(200, 60), color=(0, 1, 0, 1), font_size=dp(20), on_press=self.do_sum) tmp_btn2 = HoverButton(text='BUTTON 2', size_hint=(None, None), pos=(50, 100), size=(200, 60), color=(0, 1, 0, 1), font_size=dp(30), on_press=self.do_sum_2) self.fl = FloatLayout() self.bl = BoxLayout() self.bl.add_widget(tmp_btn) self.bl.add_widget(tmp_btn2) tabs = TabbedPanel() tabs.do_default_tab = False tab1 = HoverTabs(text='TAB 1') tab3 = HoverTabs(text='TAB 2', on_press=self.tab2_func) tab4 = HoverTabs(text='TAB 3') tab3.add_widget(self.bl) tabs.add_widget(tab1) tabs.add_widget(tab3) tabs.add_widget(tab4) tabs.default_tab = tab1 self.fl.add_widget(tabs)
def build(self): tab_panel= TabbedPanel() tab_panel.do_default_tab = False tab_panel.tab_width = 150 tab_panel.tab_height = 30 th_playlist = TabbedPanelHeader(text='Playlist Playout') th_playlist.content = Label(text='UI to create a playlist rundown') th_generic_live = TabbedPanelHeader(text='Generic Live Event') th_generic_live.content = Label(text='UI for running random live events') th_news = TabbedPanelHeader(text='News Broadcast') th_news.content = Label(text='UI for running a live news broadcast') th_worship = TabbedPanelHeader(text='Worship') th_worship.content= Label(text='UI for running praise & worships') th_football = TabbedPanelHeader(text='Football') th_football.content= Label(text='UI for running a football match') th_volleyball = TabbedPanelHeader(text='Volleyball') th_volleyball.content= Label(text='UI for running a volleyball match') tab_panel.add_widget(th_playlist) tab_panel.add_widget(th_generic_live) tab_panel.add_widget(th_news) tab_panel.add_widget(th_worship) tab_panel.add_widget(th_football) tab_panel.add_widget(th_volleyball) tab_panel.default_tab = th_playlist return tab_panel
def build(self): tab_panel = TabbedPanel() tab_panel.do_default_tab = False tab_panel.add_widget(self.make_server_tab()) tab_panel.add_widget(self.make_client_tab()) tab_panel.set_def_tab(tab_panel.tab_list[1]) return tab_panel
def generate_GUI(menus): app_gui = TabbedPanel() app_gui.clear_tabs() app_gui.orientation = "vertical" app_gui.do_default_tab = False app_gui.tab_width = 150 for menu_key, sub_menu in menus.items(): main_menu = TabbedPanelHeader(text=menu_key) scroll_pane = ScrollView() scroll_pane.scroll_type = ['bars', 'content'] scroll_pane.bar_pos_y = 'left' scroll_pane.bar_width = 6 scroll_pane.do_scroll_y = True scroll_pane.do_scroll_x = False scroll_pane.scroll_y = 1 menu_grid = GridLayout(cols=1, spacing=2, size_hint_y=None) menu_grid.orientation = "vertical" menu_grid.padding = 10 menu_grid.row_default_height = 1 menu_height = 0 print(">>>" + menu_key) for sub_menu_key, items in sub_menu.items(): menu_grid.add_widget( Label(text=" " + sub_menu_key, size_hint=(None, None), font_size=14, halign="left", valign="middle")) print("\t" + sub_menu_key) for option in items: if "Name" in option: print("\t\t" + option["Name"]) btn = Button(text=option["Name"], size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8)) btn.bind(on_press=lambda x: webbrowser.open(option["URL"])) else: print("\t\t" + "<EMPTY>") btn = Button(text="<EMPTY>", size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8)) btn.bind(on_press=lambda x: webbrowser.open(option["URL"])) btn.width = 250 btn.height = 50 menu_grid.add_widget(btn) menu_height += 80 menu_height += 51 menu_grid.height = menu_height scroll_pane.add_widget(menu_grid) main_menu.content = scroll_pane main_menu.orientation = "vertical" # Adding headers to main layout app_gui.add_widget(main_menu) return app_gui
def __init__(self, df, security_name, **kwargs): super(Application, self).__init__(**kwargs) self.orientation = 'vertical' tab_panel = TabbedPanel() tab_panel.do_default_tab = False tab_panel.background_color = (7 / 255, 0, 13 / 255, 1) tab_menu = TabbedPanelItem(text="Menu") tab_menu.background_color = (62 / 255, 142 / 255, 222 / 255, 1) tab_chart = TabbedPanelItem(text='Chart') tab_chart.background_color = (62 / 255, 142 / 255, 222 / 255, 1) tab_training = TabbedPanelItem(text='Training') tab_training.background_color = (62 / 255, 142 / 255, 222 / 255, 1) tab_validate = TabbedPanelItem(text='Validate') tab_validate.background_color = (62 / 255, 142 / 255, 222 / 255, 1) tab_future = TabbedPanelItem(text='Prediction') tab_future.background_color = (62 / 255, 142 / 255, 222 / 255, 1) tab_panel.add_widget(tab_menu) tab_panel.add_widget(tab_chart) tab_panel.add_widget(tab_training) tab_panel.add_widget(tab_validate) tab_panel.add_widget(tab_future) tab_menu.bind(on_press=lambda x: change_screen('menu')) chart_layout = FloatLayout() fig = plot_data(df, security_name.upper(), 30, 200) canvas = fig.canvas chart_layout.add_widget(canvas) tab_chart.add_widget(chart_layout) predict_frame = FloatLayout(opacity=1) predict_btn = Button(text='Run Prediction', background_color=(62 / 255, 142 / 255, 222 / 255, 1), font_size=20, pos_hint={ "center_x": 0.5, "bottom": 0 }, size_hint=(0.3, 0.075)) predict_btn.bind(on_press=lambda x: start_predict(df, security_name)) predict_frame.add_widget(predict_btn) chart_layout.add_widget(predict_frame) def start_predict(df, security_name): que = queue.Queue() par_modeling = partial(modeling, security_name=security_name) process = threading.Thread( target=lambda q, arg1: q.put(par_modeling(arg1)), args=(que, df), daemon=True) process.start() Clock.schedule_once( lambda *args: tab_panel.switch_to(tab_training)) train_fig = plt.figure(facecolor='#07000d') train_canvas = train_fig.canvas train_layout = FloatLayout() train_layout.add_widget(train_canvas) tab_training.add_widget(train_layout) if os.path.exists('training.csv'): os.remove('training.csv') def update_plot(fig): train_canvas = fig.canvas train_layout.clear_widgets() train_layout.add_widget(train_canvas) plt.close(fig) # for child in train_layout.children[:1]: # train_layout.remove_widget(child) # Clock.schedule_once(lambda *args: tab_panel.switch_to(tab_training)) def read_training(self): if os.path.exists('training.csv'): loss_df = None try: loss_df = pd.read_csv('training.csv') except Exception as e: print(e) pass if loss_df is not None: train_fig = plot_loss(loss_df) update_plot(train_fig) if not process.is_alive(): Clock.unschedule(read_training) val_fig, future_fig = que.get() val_canvas = val_fig.canvas val_layout = FloatLayout() val_layout.add_widget(val_canvas) tab_validate.add_widget(val_layout) future_canvas = future_fig.canvas future_layout = FloatLayout() future_layout.add_widget(future_canvas) tab_future.add_widget(future_layout) Clock.schedule_once( lambda *args: tab_panel.switch_to(tab_validate)) Clock.schedule_interval(read_training, 0.1) Clock.schedule_once(lambda *args: tab_panel.switch_to(tab_chart)) self.add_widget(tab_panel)
from kivy.app import App from kivy.core.window import Window from kivy.uix.anchorlayout import AnchorLayout from kivy.uix.label import Label from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem class kivy05(App): def build(self): return root # Tab panel root = TabbedPanel() root.do_default_tab = False # Tab1 tb_item1 = TabbedPanelItem(text='Tab1') lb1 = Label(text='Tab 1') tb_item1.add_widget(lb1) root.add_widget(tb_item1) # Tab2 tb_item2 = TabbedPanelItem(text='Tab2') lb2 = Label(text='Tab 2') tb_item2.add_widget(lb2) root.add_widget(tb_item2) root.default_tab = tb_item1 Window.size = (300, 150) ap = kivy05()
def build(cls) -> TabbedPanel: performance_layout = FloatLayout() posts_layout = FloatLayout() events_layout = FloatLayout() update_layout = FloatLayout() profile_layout = FloatLayout() def spinner() -> Spinner: spin = Spinner( # default value text='Choose a site:', # available values values=( 'Discord', 'Facebook', 'Instagram', 'Reddit', 'Slack', 'Tumblr', 'Twitter', 'YouTube', ), size_hint=(.15, .1), pos=(15, 985), background_color=(0.094, 0.803, 0.803), ) def show_selected_value(spnr: Spinner, text: str) -> None: print('The spinner', spnr, 'have text', text) spin.bind(text=show_selected_value) return spin performance_spinner = spinner() # performance_button = Button( # text='Show Stats', # font_size=14, # color=(0.094, 0.803, 0.803), # ) # performance_button.bind(on_press=callback) performance_layout.add_widget(performance_spinner) performance_layout.add_widget( Label( text='Follower Count: ', font_size='20sp', pos=(300, 850), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) performance_layout.add_widget( Label( text='Total Likes: ', font_size='20sp', pos=(300, 800), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) performance_stats = cls.performance(performance_spinner.values) performance_layout.add_widget( Label( text=str(performance_stats[0]), font_size='20sp', pos=(500, 850), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) performance_layout.add_widget( Label( text=str(performance_stats[1]), font_size='20sp', pos=(500, 800), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) post_spinner = spinner() # post_button = Button( # text='Submit', # font_size=14, # color=(0.094, 0.803, 0.803), # ) # # post_button.bind(on_press=callback) posts_layout.add_widget(post_spinner) posts_layout.add_widget( Label( text='Scheduled Posts: ', font_size='20sp', pos=(375, 675), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) post_types = Spinner( text='Post type', italic=True, values=( 'Text', 'Image', 'Video', 'Link', 'Announcement', ), size_hint=(.15, .1), pos=(315, 985), ) post_timing = Spinner( text='Choose a time:', italic=True, values=( 'Immediately', 'Schedule for', ), size_hint=(.15, .1), pos=(615, 985), ) posts_layout.add_widget(post_types) posts_layout.add_widget(post_timing) month = Spinner( text='Month', italic=True, values=( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ), size_hint=(.15, .1), pos=(915, 985), ) day = Spinner( text='Day', italic=True, values=( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', ), size_hint=(.15, .1), pos=(1215, 985), ) year = Spinner( text='Year', italic=True, values=( '2018', '2019', '2020', ), size_hint=(.15, .1), pos=(315, 850), ) hour = Spinner( text='Hour', italic=True, values=( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', ), size_hint=(.15, .1), pos=(615, 850), ) minute = Spinner( text='Minute', italic=True, values=( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', ), size_hint=(.15, .1), pos=(915, 850), ) posts_layout.add_widget(month) posts_layout.add_widget(day) posts_layout.add_widget(year) posts_layout.add_widget(hour) posts_layout.add_widget(minute) events_spinner = spinner() # events_button = Button( # text='Submit', # font_size=14, # color=(0.094, 0.803, 0.803), # ) # events_button.bind(on_press=callback) events_layout.add_widget(events_spinner) events_layout.add_widget( Label( text='React to: ', font_size='20sp', pos=(275, 900), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) events_layout.add_widget( Label( text='Hastag(s)', font_size='12sp', pos=(275, 850), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) hashtag_checkbox = CheckBox(pos=(450, 850), size_hint=(.15, .2), ) events_layout.add_widget(hashtag_checkbox) events_layout.add_widget( Label( text='Key word', font_size='12sp', pos=(275, 800), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) keyword_checkbox = CheckBox( pos=(450, 800), size_hint=(.15, .2), ) events_layout.add_widget( keyword_checkbox, ) events_layout.add_widget( Label( text='Mention/Tag', font_size='12sp', pos=(275, 750), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) mention_tag_checkbox = CheckBox( pos=(450, 750), size_hint=(.15, .2), ) events_layout.add_widget( mention_tag_checkbox, ) events_layout.add_widget( Label( text='Like', font_size='12sp', pos=(275, 700), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) like_checkbox = CheckBox( pos=(450, 700), size_hint=(.15, .2), ) events_layout.add_widget( like_checkbox, ) events_layout.add_widget( Label( text='Comment', font_size='12sp', pos=(275, 650), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) comment_checkbox = CheckBox( pos=(450, 650), size_hint=(.15, .2), ) events_layout.add_widget( comment_checkbox, ) events_layout.add_widget( Label( text='Retweet/Repost/Share', font_size='12sp', pos=(275, 600), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) retweet_repost_share_checkbox = CheckBox( pos=(450, 600), size_hint=(.15, .2), ) events_layout.add_widget( retweet_repost_share_checkbox, ) update_spinner = spinner() # update_button = Button( # text='Update', # font_size=14, # color=(0.094, 0.803, 0.803), # ) # update_button.bind(on_press=callback) update_layout.add_widget(update_spinner) update_layout.add_widget( Label( text='Search for: ', font_size='20sp', pos=(275, 950), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) search_input = TextInput( multiline=False, pos=(300, 970), size_hint=(.15, .04), ) update_layout.add_widget( search_input, ) update_layout.add_widget( Label( text='Replace with: ', font_size='20sp', pos=(575, 950), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) replace_input = TextInput( multiline=False, pos=(575, 970), size_hint=(.15, .04), ) update_layout.add_widget( replace_input, ) profile_layout.add_widget( Label( text='Username: '******'20sp', pos=(45, 970), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) profile_layout.add_widget( Label( text='TEMP USERNAME', font_size='15sp', pos=(275, 967), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) profile_layout.add_widget( Label( text='Change Password: '******'20sp', pos=(55, 900), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) profile_layout.add_widget( Label( text='Old Password: '******'12sp', pos=(50, 850), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) old_password_input = TextInput( multiline=False, pos=(300, 935), size_hint=(.1, .04), ) profile_layout.add_widget( old_password_input, ) profile_layout.add_widget( Label( text='New Password: '******'12sp', pos=(50, 795), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) new_password_input = TextInput( multiline=False, pos=(300, 885), size_hint=(.1, .04), ) profile_layout.add_widget( new_password_input, ) profile_layout.add_widget( Label( text='Confirm New Password: '******'12sp', pos=(50, 745), size_hint=(.15, .2), color=(0, 0, 0, 1), ), ) confirm_new_password_input = TextInput( multiline=False, pos=(300, 835), size_hint=(.1, .04), ) profile_layout.add_widget( confirm_new_password_input, ) tb_panel = TabbedPanel() tb_panel.do_default_tab = False tb_panel.background_color = (1, 1, 1, 1) tb_panel.border = [0, 0, 0, 0] tb_panel.background_image = 'path/to/background/image' # Create Performance tab performance_tab = TabbedPanelHeader(text='Performance') performance_tab.content = performance_layout tb_panel.add_widget(performance_tab) # Create Posts tab posts_tab = TabbedPanelHeader(text='Posts') posts_tab.content = posts_layout tb_panel.add_widget(posts_tab) # Create Events tab events_tab = TabbedPanelHeader(text='Events') events_tab.content = events_layout tb_panel.add_widget(events_tab) # Create Update tab update_tab = TabbedPanelHeader(text='Update') update_tab.content = update_layout tb_panel.add_widget(update_tab) # Create Profile tab profile_tab = TabbedPanelHeader(text='Profile') profile_tab.content = profile_layout tb_panel.add_widget(profile_tab) return tb_panel