def __init__(self, **kwargs): super(ProgramPanel, self).__init__(**kwargs) self.cols = 1 g = GridLayout(cols=2) g.height = 60 g.size_hint_y = None title = HeadingItem() g.add_widget(title) self.my_title = title bg = GridLayout(cols=3) bg.padding = [8, 6] b = Button(text='1. program') b.bind(on_release=self.my_select_block_dialog) bg.add_widget(b) self.my_block_button = b self.my_set_select() b = Button(text='read') b.bind(on_release=self.my_read_block_dialog) bg.add_widget(b) b = Button(text='write') b.bind(on_release=self.my_write_block_dialog) bg.add_widget(b) g.add_widget(bg) self.add_widget(g) g = GridLayout(cols=2) g.height = 40 g.size_hint_y = None g.padding = [8, 6] self.current_path = '/coderoot/packages' self.my_path = TextInput(text=self.current_path, multiline=False, write_tab=False) g.add_widget(self.my_path) self.my_fname = TextInput(text='', multiline=False, write_tab=False) g.add_widget(self.my_fname) self.add_widget(g) self.my_file_chooser = MyFileChooser(path=self.current_path, size_hint=(1, 1), dirselect=True) self.add_widget(self.my_file_chooser) self.my_file_chooser.bind(selection=lambda *x: self.my_select(x[1:])) self.my_file_chooser.bind(path=lambda *x: self.my_set_path(x[1:])) self.stream = None self.popup = None self.writing = False
def user_screen(self): self.manager.get_screen( 'main').ids.btn_camera.color = get_color_from_hex('#FFFFFF') self.manager.get_screen( 'main').ids.btn_home.color = get_color_from_hex('#FFFFFF') self.manager.get_screen( 'main').ids.btn_user.color = get_color_from_hex('#2196F3') self.manager.get_screen('main').ids.master.clear_widgets() user_layout = GridLayout() user_layout.id = 'user_layout' user_layout.spacing = (0, 0.5) user_layout.padding = 40, 10, 40, 10 user_layout.cols = 1 user_layout.row_default_height = self.height * 0.25 user_layout.row_force_default = True lbl_user = Label() lbl_user.id = 'lbl_home' lbl_user.color = get_color_from_hex('#212121') lbl_user.text = 'User Layout' self.manager.get_screen('main').ids[user_layout.id] = \ WeakProxy(user_layout) self.manager.get_screen('main').ids[lbl_user.id] = \ WeakProxy(lbl_user) self.manager.get_screen('main').ids.master.\ add_widget(user_layout) self.manager.get_screen('main').ids.user_layout.\ add_widget(lbl_user)
def home_screen(self): self.manager.get_screen( 'main').ids.btn_camera.color = get_color_from_hex('#FFFFFF') self.manager.get_screen( 'main').ids.btn_home.color = get_color_from_hex('#2196F3') self.manager.get_screen( 'main').ids.btn_user.color = get_color_from_hex('#FFFFFF') self.manager.get_screen('main').ids.master.clear_widgets() home_layout = GridLayout() home_layout.id = 'home_layout' home_layout.spacing = (0, 0.5) home_layout.padding = 40, 10, 40, 10 home_layout.cols = 1 home_layout.row_default_height = self.height * 0.25 home_layout.row_force_default = True lbl_home = Label() lbl_home.id = 'lbl_home' lbl_home.color = get_color_from_hex('#212121') lbl_home.text = 'Home Layout' self.manager.get_screen('main').ids[home_layout.id] = \ WeakProxy(home_layout) self.manager.get_screen('main').ids[lbl_home.id] = \ WeakProxy(home_layout) self.manager.get_screen('main').ids.master.\ add_widget(home_layout) self.manager.get_screen('main').ids.lbl_home.\ add_widget(lbl_home)
def camera_screen(self): self.manager.get_screen( 'main').ids.btn_camera.color = get_color_from_hex('#2196F3') self.manager.get_screen( 'main').ids.btn_home.color = get_color_from_hex('#FFFFFF') self.manager.get_screen( 'main').ids.btn_user.color = get_color_from_hex('#FFFFFF') self.manager.get_screen('main').ids.master.clear_widgets() camera_layout = GridLayout() camera_layout.id = 'camera_layout' camera_layout.spacing = (0, 0.5) camera_layout.padding = 40, 10, 40, 10 camera_layout.cols = 1 camera_layout.row_default_height = self.height * 0.25 camera_layout.row_force_default = True lbl_camera = Label() lbl_camera.id = 'lbl_camera' lbl_camera.color = get_color_from_hex('#212121') lbl_camera.text = 'Camera Layout' self.manager.get_screen('main').ids[camera_layout.id] = \ WeakProxy(camera_layout) self.manager.get_screen('main').ids[lbl_camera.id] = \ WeakProxy(lbl_camera) self.manager.get_screen('main').ids.master.\ add_widget(camera_layout) self.manager.get_screen('main').ids.camera_layout.\ add_widget(lbl_camera)
def open_private(self, instance): self.popup = Popup(title="Private Lobby") self.popup.size = (40, 40) content = GridLayout() self.popup.content = content content.cols = 2 content.rows = 3 content.padding = 100 self.name_input = TextInput(multiline=False) self.name_label = Label(text="Name:") content.add_widget(self.name_label) content.add_widget(self.name_input) self.room_id_input = TextInput(multiline=False) self.room_label = Label(text="Room Code:") content.add_widget(self.room_label) content.add_widget(self.room_id_input) content.add_widget(Button(text="Back", on_press=self.popup.dismiss)) # send name and room id to server to join lobby content.add_widget( Button(text="Join Private Lobby", on_press=lambda event: send_msg( self.client_socket, Message(TAG='LOBBYREQUEST', name=self.name_input.text, roomid=self.room_id_input.text)))) self.popup.open()
def my_select_block_dialog(self, instance): button_list = [ "1. program", "2. config", "3. defaults", "5. server key", "6. server cert", "7. root cert", "8. cert chain", "9. publish chain", "10. wifi select", "12. cust", "21. accounts" ] grid = GridLayout() grid.cols = 2 grid.spacing = [6, 6] grid.padding = [6, 6] for button_text in button_list: b = Button(text=button_text) b.height = 60 b.size_hint_y = None b.bind(on_release=self.block_selected) grid.add_widget(b) self.popup = popup = Popup(title='select persistent block', content=grid) popup.size_hint = (None, None) popup.size = (0.90 * Window.width, 0.90 * Window.height) # all done, open the popup ! popup.open()
def on_enter(self): gen = Generator() edit_grid = GridLayout() edit_grid.cols = 4 edit_grid.rows = 4 edit_grid.padding = 10 for key in gen.lst: box = BoxLayout() box.orientation = 'vertical' box.padding = 10 label = Label() label.text = key label.size_hint = (1, .25) text_input = EditorText() text_input.multiline = True text_input.text = self.get_values(gen.lst[key]) text_input.id = key button = Button(text='Submit') button.size_hint = (1, .25) button.bind(on_press=text_input.update_item) box.add_widget(label) box.add_widget(text_input) box.add_widget(button) edit_grid.add_widget(box) button = Button() button.text = 'Done' button.size_hint = (1, .25) button.bind(on_press=self.load_art_tools_main) edit_grid.add_widget(button) self.add_widget(edit_grid)
def setup(self): self.cols = 1 self.rows = 2 self.turn_label = Label(text='[b]Turn:[/b] [color='+ self.player_color[self.game.turn] + ']' \ + self.player_name[self.game.turn] + '[/color]', markup=True) self.turn_label.font_size = 48 inner_layout = GridLayout() inner_layout.rows = 3 inner_layout.cols = 3 inner_layout.padding = (8, 8) for x in range(3): for y in range(3): self.button_matrix[x][y] = Button( text="" + str(self.game.board_matrix[x][y]), font_size=48, markup=True) if self.game.board_matrix[x][y] != "-": # Player 2 (AI) can have already placed his first move self.button_matrix[x][ y].text = '[b][color=' + self.player_color[ 2] + ']' + self.player_symbol[2] + '[/color][/b]' self.button_matrix[x][y].bind( on_press=partial(self.button_pressed, x, y)) inner_layout.add_widget(self.button_matrix[x][y]) self.add_widget(self.turn_label) inner_layout.size_hint = (2.5, 2) self.add_widget(inner_layout)
def __init__(self, **kwargs): super(PlaylistWidget, self).__init__(**kwargs) self.playlist = ClientManeger.server_songs.songs self.bar_width = 30 self.size_hint = (1, 0.71) self.scroll_type = ['bars'] self.bar_inactive_color = (5, 20, 10, 0.5) self.bar_color = (5, 10, 15, .9) self.do_scroll_x = False self.do_scroll_y = True grid = GridLayout() grid.height = 0 grid.size_hint_y = None grid.cols = 1 grid.padding = (5, 5) for song in self.playlist: widg = SongWidget(song) widg.size_hint_y = None grid.size_hint_x = 1.0 # increment grid height grid.height += widg.height grid.add_widget(widg) self.add_widget(grid)
def setup(self): self.cols = 1 self.rows = 2 title_label = Label (text='[b]Forza[/b] [color=ff3333]4[/color]', markup=True) title_label.font_size = 42 inner_layout = GridLayout() inner_layout.rows = 3 inner_layout.cols = 3 inner_layout.padding = (16, 16) single_button = Button(text = "[b]SinglePlayer[/b]", markup=True) single_button.font_size = 24 single_button.bind(on_press=partial (start_game, 1)) multi_button = Button(text = "[b]MultiPlayer[/b]", markup=True) multi_button.font_size = 24 multi_button.bind(on_press=partial (start_game, 2)) exit_button = Button(text = "[b]Exit[/b]", markup=True) exit_button.font_size = 24 exit_button.bind(on_press=close_app) self.add_widget(title_label) inner_layout.add_widget(Label()) inner_layout.add_widget(Label()) inner_layout.add_widget(Label()) inner_layout.add_widget(single_button) inner_layout.add_widget(multi_button) inner_layout.add_widget(exit_button) inner_layout.add_widget(Label()) inner_layout.add_widget(Label()) inner_layout.add_widget(Label()) self.add_widget(inner_layout)
def build(self): box = BoxLayout() box.orientation = 'vertical' navigation_bar = CupertinoNavigationBar() navigation_bar.size_hint_y = 0.15 title = CupertinoLabel() title.text = 'Symbols' title.bold = True title.pos_hint = {'center': (0.5, 0.5)} scrollview = CupertinoScrollView() scrollview.scroll_wheel_distance = 200 layout = GridLayout() layout.cols = 1 layout.spacing = 15 layout.padding = 2, 15 layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) navigation_bar.add_widget(title) scrollview.add_widget(layout) with open(root_path + 'symbols.json', 'r') as json: symbols = load(json) for s in symbols: cell = BoxLayout() cell.orientation = 'horizontal' cell.size_hint_y = None cell.height = 20 symbol = CupertinoSymbol() symbol.symbol = s symbol.color = 0, 0, 0, 1 symbol.size_hint_x = 0.2 name = CupertinoLabel() name.text = s name.font_size = 14 name.halign = 'left' name.bind(size=name.setter('text_size')) cell.add_widget(symbol) cell.add_widget(name) layout.add_widget(cell) box.add_widget(navigation_bar) box.add_widget(scrollview) return box
def my_read_block_dialog(self, instance): grid = GridLayout() grid.cols = 1 grid.spacing = [6, 6] grid.padding = [6, 6] my_path = os.path.join(self.my_path.text, self.my_fname.text) if os.path.isdir(my_path): my_path = os.path.join(my_path, self.my_default_fname) if os.path.isfile(my_path): warn = Label( text= "FILE ALREADY EXISTS, IF YOU SELECT DOWNLOAD\nTHE FILE WILL BE OVERWRITTEN", markup=True, halign="center") grid.add_widget(warn) pathinput = make_my_text_input(my_path, True) grid.add_widget(pathinput) self.pathinput = pathinput self.popup = popup = Popup(title='confirm persistent block download', content=grid) popup.size_hint = (None, None) popup.size = (0.95 * Window.width, 250) bg = GridLayout(cols=2) bg.spacing = [6, 6] b = Button(text='close') b.height = 60 b.size_hint_y = None b.bind(on_release=popup.dismiss) bg.add_widget(b) b = Button(text='download') b.height = 60 b.size_hint_y = None b.bind(on_release=self.read_selected) bg.add_widget(b) grid.add_widget(bg) pb = ProgressBar(value=0, max=1000) grid.add_widget(pb) popup.progress_bar = pb # all done, open the popup ! popup.open()
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, **kwargs): super(InputsScreen, self).__init__(**kwargs) scroll = ScrollView() scroll.size_hint = (1, 1) self.add_widget(scroll) layout = GridLayout() layout.cols = 3 layout.padding = '8dp' layout.spacing = '8dp' layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) scroll.add_widget(layout) self.layout = layout
def format_airtable_data(header): # Gridlayout to host menu options and URL buttons formated_data = GridLayout(cols=1, spacing=10, size_hint_y=None) formated_data.orientation = "vertical" formated_data.padding = 10 formated_data.row_default_height = 1 rows = 0 # needed to track the number of items inside the gridlayout # Converting airtable data into usable Kivy GUI labels and Buttons for item in tab_menus: if item["id"] == header: # Creating the Labels if str(item["menu"]) != "N/A": formated_data.add_widget(Label(text=item["menu"],size_hint=(.7,.5))) # Creating a menu option as a Label rows += 1 else: # For menu options that have yet to be given a name formated_data.add_widget(Label(text="Menu name pending",size_hint=(.7,.5))) rows += 1 # Creating the URL Buttons that belong bellow each Label for link in item["link"]: url_name = str(link).split('!')[0] url = str(link).split('!')[1] # Creaing the Button without refrences if url_name != "N/A": button = Button(text=url_name, size_hint=(None, None)) else: # For URL links with no assigned names button = Button(text="Unknown Link", size_hint=(None, None)) button.width = 250 button.height = 50 # Assign each Button a refrence to a created function with their respective URL links # This is equivalent to Kivy script: on_press: root.open_link('www.your_url_link.com') button.bind(on_press=lambda x:Resonance().open_link(url)) formated_data.add_widget(button) rows += 1 formated_data.add_widget(Label()) rows += 1 # Formating the gridlayout to fit the sum of items created # Necessary to indicate to Scrollview if scroll is needed # if grid size > window size allow scroll formated_data.height = rows * 50 return formated_data
def __init__(self, **kwargs): super().__init__(**kwargs) self.cols = 3 self.buttons = [None] * 81 for x in range(0, 9): subgrid = GridLayout() subgrid.cols = 3 subgrid.padding = [5, 5, 5, 5] for y in range(0, 9): button = Button(font_size="20") button.background_color = (1, 1, 1, 1) subgrid.add_widget(button) rownumber = 3 * (x // 3) + (y // 3) colnumber = 3 * (x % 3) + (y % 3) self.buttons[9 * rownumber + colnumber] = button self.add_widget(subgrid)
def exit(self): self.popup = ModalView(size_hint=(0.5, 0.4)) grd = GridLayout() grd.cols = 2 grd.padding = 120 flt = FloatLayout() lbl = Label(pos=(320, 340), text='Are you sure to exit game????', font_size=35) flt.add_widget(lbl) btn1 = Button(text='YES', font_size=50) btn1.bind(on_press=self.button_pressed) btn2 = Button(text='NO', font_size=50) btn2.bind(on_press=self.popup.dismiss) grd.add_widget(btn1) grd.add_widget(btn2) self.popup.add_widget(flt) self.popup.add_widget(grd) self.popup.open()
def my_write_block_dialog(self, instance): grid = GridLayout() grid.cols = 1 grid.spacing = [6, 6] grid.padding = [6, 6] my_path = os.path.join(self.my_path.text, self.my_fname.text) if os.path.isdir(my_path): my_path = os.path.join(my_path, self.my_default_fname) pathinput = make_my_text_input(my_path, True) grid.add_widget(pathinput) self.pathinput = pathinput self.popup = popup = Popup(title='confirm file upload', content=grid) popup.size_hint = (None, None) popup.size = (0.95 * Window.width, 250) bg = GridLayout(cols=2) bg.spacing = [6, 6] b = Button(text='close') b.height = 60 b.size_hint_y = None b.bind(on_release=popup.dismiss) bg.add_widget(b) b = Button(text='upload') b.height = 60 b.size_hint_y = None b.bind(on_release=self.write_selected) bg.add_widget(b) grid.add_widget(bg) pb = ProgressBar(value=0, max=1000) grid.add_widget(pb) popup.progress_bar = pb # all done, open the popup ! popup.open()
def setup(self): self.cols = 1 self.rows = 3 self.turn_label = Label(text='[b]Turn:[/b] [color='+ self.player_color[self.game.turn] + ']' \ + self.player_name[self.game.turn] + '[/color]', markup=True) self.turn_label.font_size = 48 inner_layout = GridLayout() inner_layout.rows = 6 inner_layout.cols = 7 inner_layout.padding = (8, 8) for row in range(6): for col in range(7): self.label_matrix[row][col] = Label(text=str(self.game.board_matrix[row][col]), font_size = 48, markup = True) if self.game.board_matrix[row][col] != "-": # Player 2 (AI) can have already placed his first move self.label_matrix[row][col].text = '[b][color=' + self.player_color[2] +']' + self.player_symbol[2] + '[/color][/b]' #self.button_matrix[x][y].bind(on_press=partial (self.button_pressed, x, y)) inner_layout.add_widget(self.label_matrix[row][col]) self.add_widget(self.turn_label) inner_layout.size_hint=(2.5, 2) self.add_widget(inner_layout) # Row of Button, one for each column button_row_layout = GridLayout() button_row_layout.rows = 1 button_row_layout.cols = 7 for col in range(7): button = Button(text="[b]O[/b]", font_size = 40, markup = True) button.bind(on_press=partial(self.button_pressed, col)) button_row_layout.add_widget(button) button_row_layout.size_hint=(0.5, 0.5) self.add_widget(button_row_layout)
def open_public(self, instance): self.popup = Popup(title="Public Lobby") content = GridLayout() self.popup.content = content content.cols = 2 content.rows = 2 content.padding = 100 content.add_widget(Label(text="Name:")) self.name_input = TextInput(multiline=False) content.add_widget(self.name_input) content.add_widget(Button(text="Back", on_press=self.popup.dismiss)) # send name to server for verification when clicked content.add_widget( Button( text="Join Public Lobby", on_press=lambda event: send_msg( self.client_socket, Message(TAG='LOBBYREQUEST', name=self.name_input.text)))) self.popup.open()
def build(self): box = BoxLayout() box.orientation = 'vertical' navigation_bar = CupertinoNavigationBar() navigation_bar.height = 60 title = CupertinoLabel() title.text = 'Showcase' title.bold = True title.pos_hint = {'center_x': 0.5, 'center_y': 0.5} scrollview = CupertinoScrollView() scrollview.size_hint_y = None scrollview.height = Window.height - navigation_bar.height layout = GridLayout() layout.cols = 1 layout.spacing = 15 layout.padding = 15 layout.size_hint_y = None layout.bind(minimum_height=layout.setter('height')) system_button = CupertinoSystemButton() system_button.text = 'Send' system_button.size_hint_y = None system_button.height = 20 symbol_button = CupertinoSymbolButton() symbol_button.symbol = 'info' symbol_button.color = 0.05, 0.5, 0.95, 1 symbol_button.size_hint_y = None symbol_button.size = 32, 32 button = CupertinoButton() button.text = 'Hello World' button.size_hint_y = None button.height = 50 segmented_controls = CupertinoSegmentedControls() segmented_controls.size_hint_y = None segmented_controls.height = 30 segmented_controls.add_tab('Segmented') segmented_controls.add_tab('Controls') switch = CupertinoSwitch() switch.size_hint = None, None switch.size = 70, 40 self.progress_bar = CupertinoProgressbar() self.progress_bar.value = 10 self.progress_bar.size_hint_y = None self.progress_bar.height = 5 stepper = CupertinoStepper() stepper.size_hint = None, None stepper.size = 100, 30 stepper.bind(on_plus=lambda widget: self.increment_progress(10), on_minus=lambda widget: self.increment_progress(-10)) ny_label = CupertinoLabel() ny_label.font_name = 'New York' ny_label.text = 'New York Font Label' ny_label.size_hint_y = None ny_label.height = 20 sf_label = CupertinoLabel() sf_label.font_name = 'San Francisco' sf_label.text = 'San Francisco Font Label' sf_label.size_hint_y = None sf_label.height = 20 alert_dialog_button = CupertinoButton() alert_dialog_button.text = 'Open Alert Dialog' alert_dialog_button.size_hint_y = None alert_dialog_button.height = 50 alert_dialog_button.on_release = self.open_alert_dialog action_sheet_button = CupertinoButton() action_sheet_button.text = 'Open Action Sheet' action_sheet_button.size_hint_y = None action_sheet_button.height = 50 action_sheet_button.on_release = self.open_action_sheet text_field = CupertinoTextField() text_field.hint_text = 'Text Field' text_field.size_hint_y = None text_field.height = 30 instructions = CupertinoLabel() instructions.text = 'Enter Text Below:' instructions.size_hint = None, None instructions.size = 120, 20 text_view = CupertinoTextView() text_view.size_hint_y = None text_view.height = 100 navigation_bar.add_widget(title) layout.add_widget(system_button) layout.add_widget(symbol_button) layout.add_widget(button) layout.add_widget(segmented_controls) layout.add_widget(switch) layout.add_widget(self.progress_bar) layout.add_widget(stepper) layout.add_widget(ny_label) layout.add_widget(sf_label) layout.add_widget(alert_dialog_button) layout.add_widget(action_sheet_button) layout.add_widget(text_field) layout.add_widget(instructions) layout.add_widget(text_view) scrollview.add_widget(layout) box.add_widget(navigation_bar) box.add_widget(scrollview) return box
def build(self): screen_manager = ScreenManager() self.loaded_values = [ 1, 0, 0, 0, 0, 0 ] # round num, cp, primary obj, 1st secondary, 2nd secondary, 3rd secondary self.update_values() self.theme_cls.primary_palette = "Gray" self.theme_cls.primary_hue = "800" # Game counters screen and backgrgound color self.counters = Screen(name="Counters") self.change_bg_color() screen_manager.add_widget(self.counters) # SCROLLVIEW self.scroll = ScrollView() self.counters.add_widget(self.scroll) # MENU self.menu_button = MDIconButton(icon='format-color-fill', on_release=self.menu_open) self.menu_button.pos_hint = {'center_x': .9, 'center_y': .1} self.menu_button.md_bg_color = (1, 1, 1, 1) items = [{ "text": "Ceramic White" }, { "text": "Loyal Angels Green" }, { "text": "Space Doggos Gray" }, { "text": "Codex Blue" }, { "text": "Vampire Angels Red" }, { "text": "Gray Nights" }, { "text": "Stubborn Fists Yellow" }] self.menu = MDDropdownMenu(caller=self.menu_button, items=items, callback=self.menu_callback, width_mult=5) self.counters.add_widget(self.menu_button) # MAIN GRID app_grid = GridLayout(cols=1, spacing=100, size_hint_y=None) app_grid.padding = [ Window.width / 40, Window.height / 20, Window.width / 40, Window.height / 4 ] # [left,top,right,bottom] app_grid.bind(minimum_height=app_grid.setter('height')) self.scroll.add_widget(app_grid) # ROUND COUNTER round_parent_grid = MDGridLayout() round_parent_grid.cols = 1 round_parent_grid.rows = 2 round_parent_grid.adaptive_height = True round_label = MDLabel(text='Round number:') round_label.halign = 'center' round_parent_grid.add_widget(round_label) app_grid.add_widget(round_parent_grid) grid_round = GridLayout() grid_round.cols = 3 increase_round = MDIconButton(icon="arrow-right-bold", on_press=self.increase_round) self.round_counter = MDLabel(text=str(self.loaded_values[0])) self.round_counter.halign = 'center' self.round_counter.valign = 'middle' decrease_round = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_round) grid_round.add_widget(decrease_round) grid_round.add_widget(self.round_counter) grid_round.add_widget(increase_round) round_parent_grid.add_widget(grid_round) # COMMAND POINTS cp_parent_grid = MDGridLayout() cp_parent_grid.cols = 1 cp_parent_grid.rows = 2 cp_parent_grid.adaptive_height = True cp_label = MDLabel(text='Command Points Left:') cp_label.halign = 'center' cp_parent_grid.add_widget(cp_label) app_grid.add_widget(cp_parent_grid) grid_cp = MDGridLayout() grid_cp.cols = 3 increase_cp = MDIconButton(icon="arrow-right-bold", on_press=self.increase_cp) self.cp_counter = MDLabel(text=str(self.loaded_values[1])) self.cp_counter.halign = 'center' self.cp_counter.valign = 'middle' decrease_cp = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_cp) grid_cp.add_widget(decrease_cp) grid_cp.add_widget(self.cp_counter) grid_cp.add_widget(increase_cp) cp_parent_grid.add_widget(grid_cp) # VP PRIMARY prim_parent_grid = MDGridLayout() prim_parent_grid.cols = 1 prim_parent_grid.rows = 2 prim_parent_grid.adaptive_height = True prim_label = MDLabel(text='Primary Objective Points:') prim_label.halign = 'center' prim_parent_grid.add_widget(prim_label) app_grid.add_widget(prim_parent_grid) grid_prim = MDGridLayout() grid_prim.cols = 3 increase_prim = MDIconButton(icon="arrow-right-bold", on_press=self.increase_prim) self.prim_counter = MDLabel(text=str(self.loaded_values[2])) self.prim_counter.halign = 'center' self.prim_counter.valign = 'middle' decrease_prim = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_prim) grid_prim.add_widget(decrease_prim) grid_prim.add_widget(self.prim_counter) grid_prim.add_widget(increase_prim) prim_parent_grid.add_widget(grid_prim) # VP SECONDARY 1 sec1_parent_grid = MDGridLayout() sec1_parent_grid.cols = 1 sec1_parent_grid.rows = 2 sec1_parent_grid.adaptive_height = True sec1_label = MDTextField() sec1_label.hint_text = '1st Secondary Objective Points:' sec1_label.multiline = False #sec1_label = MDLabel(text='1st Secondary Objective Points:') sec1_label.halign = 'center' sec1_parent_grid.add_widget(sec1_label) app_grid.add_widget(sec1_parent_grid) grid_sec1 = MDGridLayout() grid_sec1.cols = 3 increase_sec1 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec1) self.sec1_counter = MDLabel(text=str(self.loaded_values[3])) self.sec1_counter.halign = 'center' self.sec1_counter.valign = 'middle' decrease_sec1 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec1) grid_sec1.add_widget(decrease_sec1) grid_sec1.add_widget(self.sec1_counter) grid_sec1.add_widget(increase_sec1) sec1_parent_grid.add_widget(grid_sec1) # VP SECONDARY 2 sec2_parent_grid = MDGridLayout() sec2_parent_grid.cols = 1 sec2_parent_grid.rows = 2 sec2_parent_grid.adaptive_height = True sec2_label = MDTextField() sec2_label.hint_text = '2nd Secondary Objective Points:' sec2_label.multiline = False #sec2_label = MDLabel(text='2nd Secondary Objective Points:') sec2_label.halign = 'center' sec2_parent_grid.add_widget(sec2_label) app_grid.add_widget(sec2_parent_grid) grid_sec2 = MDGridLayout() grid_sec2.cols = 3 increase_sec2 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec2) self.sec2_counter = MDLabel(text=str(self.loaded_values[4])) self.sec2_counter.halign = 'center' self.sec2_counter.valign = 'middle' decrease_sec2 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec2) grid_sec2.add_widget(decrease_sec2) grid_sec2.add_widget(self.sec2_counter) grid_sec2.add_widget(increase_sec2) sec2_parent_grid.add_widget(grid_sec2) # VP SECONDARY 3 sec3_parent_grid = MDGridLayout() sec3_parent_grid.cols = 1 sec3_parent_grid.rows = 2 sec3_parent_grid.adaptive_height = True sec3_label = MDTextField() sec3_label.hint_text = '3rd Secondary Objective Points:' sec3_label.multiline = False #sec3_label = MDLabel(text='3rd Secondary Objective Points:') sec3_label.halign = 'center' sec3_parent_grid.add_widget(sec3_label) app_grid.add_widget(sec3_parent_grid) grid_sec3 = MDGridLayout() grid_sec3.cols = 3 increase_sec3 = MDIconButton(icon="arrow-right-bold", on_press=self.increase_sec3) self.sec3_counter = MDLabel(text=str(self.loaded_values[5])) self.sec3_counter.halign = 'center' self.sec3_counter.valign = 'middle' decrease_sec3 = MDIconButton(icon="arrow-left-bold", on_press=self.decrease_sec3) grid_sec3.add_widget(decrease_sec3) grid_sec3.add_widget(self.sec3_counter) grid_sec3.add_widget(increase_sec3) sec3_parent_grid.add_widget(grid_sec3) # Empty grid to create space empty_grid = MDGridLayout() app_grid.add_widget(empty_grid) # Bottom grid for Score and Reset buttons bottom_grid = MDGridLayout() bottom_grid.cols = 2 app_grid.add_widget(bottom_grid) # SCORE TOAST score_button = MDFillRoundFlatIconButton(icon='flag-plus-outline', text="Show score", on_press=self.sum_up) button_anchor = AnchorLayout() button_anchor.anchor_y = 'bottom' button_anchor.add_widget(score_button) bottom_grid.add_widget(button_anchor) # RESET reset_button = MDFillRoundFlatIconButton(icon='backup-restore', text="Reset", on_press=self.reset_values) reset_button_anchor = AnchorLayout() reset_button_anchor.anchor_y = 'bottom' reset_button_anchor.add_widget(reset_button) bottom_grid.add_widget(reset_button_anchor) return screen_manager
def render_builder(self,tab): self.MainBx=BoxLayout(orientation='vertical') self.MainBx.size_hint=( 1, 1) UpBx=BoxLayout() UpBx.padding=10 UpBx.spacing=10 UpBx.size_hint = (1,.99) btnBuild=Button(text='Build',size_hint=(1, 1)) btnBuild.bind(on_press=self.start_build) btnInstall=Button(text='Install',size_hint=(1,1)) btnInstall.bind(on_press=self.start_install) btnInstall.bind(on_release=self.install_prj) btnInstall.disabled=False BtnBx=BoxLayout() BtnBx.size_hint = (1,.1) BtnBx.add_widget(btnBuild) BtnBx.add_widget(btnInstall) self.MainBx.add_widget(UpBx) self.MainBx.add_widget(BtnBx) DxBox=BoxLayout(orientation='vertical') DxBox.padding=5 DxBox.spacing=5 ProojIntBx = GridLayout(cols=2) #init ProojIntBx.size_hint = (1, 0.3) vl=Label(text=u'Version') vl.text_size=(self.width, None) self.vt=TextInput() self.vt.multiline=False pnl=Label(text=u'Project Name') self.pnt=TextInput() self.pnt.multiline=False pkgl=Label(text=u'Base Package Name') self.pkgt=TextInput() self.pkgt.multiline=False ProojIntBx.add_widget(vl) ProojIntBx.add_widget(self.vt) ProojIntBx.add_widget(pnl) ProojIntBx.add_widget(self.pnt) ProojIntBx.add_widget(pkgl) ProojIntBx.add_widget(self.pkgt) FileBx=BoxLayout() #add file search and list permission FileBx.size_hint = (1, 0.95) self.prj_path=FileChooserListView(path=self.prj_load_path) self.prj_path.size_hint = (1, 1) FileBx.add_widget(self.prj_path) ActionOptBx = GridLayout(cols=4) #debug install .... ActionOptBx.padding=10 ActionOptBx.spacing=10 ActionOptBx.size_hint = (1, 0.1) DebugBox=BoxLayout() DebugBox.add_widget(Label(text='Debug')) self.chkDebug=CheckBox() DebugBox.add_widget(self.chkDebug) DebugBox.add_widget(Label(text='Release')) self.chkRelease=CheckBox() DebugBox.add_widget(self.chkRelease) ActionOptBx.add_widget(DebugBox) DxBox.add_widget(ProojIntBx) DxBox.add_widget(FileBx) DxBox.add_widget(ActionOptBx) #dxbox -> second in up box PermissionBx=BoxLayout(orientation='vertical') #treeviw pwrmission PermissionBx.padding=5 PermissionBx.spacing=5 PermissionBx.pos=(10, 0) #~ PermissionBx.size_hint = (1, 1) layouttv = GridLayout(cols=1, spacing=5, size_hint_y=None,pos=(0,10)) layouttv.bind(minimum_height=layouttv.setter('height')) for x in self.obj_builder.permissions_list: btn = ToggleButton(text=x, size_hint_y=None, height=40) btn.bind(state=self.add_remove_permission) layouttv.add_widget(btn) root = ScrollView(size_hint=(None, None), size=(400, 500)) root.size_hint = (1, .9) root.add_widget(layouttv) PermissionBx.add_widget(root) #reder all UpBx.add_widget(DxBox) UpBx.add_widget(PermissionBx) #add all in tab item tab.add_widget(self.MainBx)
def __init__(self, order, *args, **kwargs): super().__init__(*args, **kwargs) self.title = f"Order {str(order.order_number)}" self.order = order app = MDApp.get_running_app() scroll = ScrollView() layout = BoxLayout() layout.orientation = "vertical" b_layout = GridLayout() b_layout.cols = 3 b_layout.padding = 10 layout.add_widget(Label(text=f"Customer: {order.customer}")) layout.add_widget(Label(text=f"Email: {order.email}")) layout.add_widget(Label(text=f"Products: ")) for i in order.product: label = MDRoundFlatButton(text=i) label.pos_hint = {"center_x": .5, "center_y": .5} label.text_color = app.theme_cls.accent_color b_layout.add_widget(label) layout.add_widget(b_layout) layout.add_widget( Label(text=f"Material Cost: £{round(order.products_cost, 2)}")) layout.add_widget(Label(text=f"Customer Cost: {order.customer_price}")) layout.add_widget(Label(text=f"Markup %: {order.markup}")) layout.add_widget(Label(text=f"Order Date: {order.order_date}")) layout.add_widget( Label(text=f"Quoted Lead Time: {str(order.leadtime)}")) layout.add_widget(Label(text=f"Origin: {order.origin}")) """ PAYMENT """ payment_layout = BoxLayout() payment_layout.add_widget(Label(text=f"Payment: ")) self.payment_btn = MDRectangleFlatButton(text=self.order.payment) self.payment_menu = MDDropdownMenu(items=self.build_paymentEntrys(app), width_mult=4, caller=self.payment_btn, callback=self.payment_callback) self.payment_btn.on_release = self.payment_menu.open payment_layout.add_widget(self.payment_btn) layout.add_widget(payment_layout) """ STATUS """ status_layout = BoxLayout() status_layout.add_widget(Label(text=f"Status: ")) self.status_btn = MDRectangleFlatButton(text=self.order.status) self.status_menu = MDDropdownMenu(items=self.build_statusEntrys(app), width_mult=4, caller=self.status_btn, callback=self.status_callback) self.status_btn.on_release = self.status_menu.open status_layout.add_widget(self.status_btn) layout.add_widget(status_layout) """ DELIVERY """ delivery_layout = BoxLayout() delivery_layout.add_widget(Label(text="Delivery Method: ")) self.delivery_btn = MDRectangleFlatButton(text=self.order.delivery) self.delivery_menu = MDDropdownMenu( items=self.build_deliveryEntrys(app), width_mult=4, caller=self.delivery_btn, callback=self.delivery_callback) self.delivery_btn.on_release = self.delivery_menu.open delivery_layout.add_widget(self.delivery_btn) layout.add_widget(delivery_layout) buttonlayout = BoxLayout() buttonlayout.orientation = "horizontal" buttonlayout.add_widget( MDRectangleFlatButton(text="Return", on_release=self.dismiss)) buttonlayout.add_widget( MDRectangleFlatButton(text="Cancel Order", on_release=self.cancelOrder)) layout.add_widget(buttonlayout) scroll.add_widget(layout) self.content = scroll