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 load_content(self): self.layout.clear_widgets() toolbar = MDToolbar(type="top") toolbar.left_action_items = [["arrow-left", self.go_back]] toolbar.right_action_items = [["plus", self.add_book]] title_label = MDLabel( text="Title: ", halign="left", valign="top", ) subtitle_label = MDLabel( text="Subtitle: ", halign="left", valign="top", ) price_label = MDLabel( text="Price: ", halign="left", valign="top", ) self.title_input = MDTextField() self.subtitle_input = MDTextField() self.price_input = MDTextField() self.layout.add_widget(toolbar) self.layout.add_widget(title_label) self.layout.add_widget(self.title_input) self.layout.add_widget(subtitle_label) self.layout.add_widget(self.subtitle_input) self.layout.add_widget(price_label) self.layout.add_widget(self.price_input)
def ui_layout(self): calibration_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint=(0.75, 0.45), pos_hint={ 'top': 0.75, 'center_x': 0.5 }) calibration_label = MDLabel(text='Calibrate Audio Input', font_style='H4', halign='center') calibration_label.theme_text_color = 'Custom' calibration_label.text_color = [1, 1, 1, 1] self.slider = Slider(size_hint=(0.75, None), pos_hint={'center_x': 0.5}) self.slider.bind(value=self.on_value_change) helper_box = BoxLayout(orientation='horizontal') left_label = MDLabel(text='Less Sensitive', font_style='Caption') left_label.theme_text_color = 'Custom' left_label.text_color = [1, 1, 1, 1] right_label = MDLabel(text='More Sensitive', font_style='Caption') right_label.theme_text_color = 'Custom' right_label.text_color = [1, 1, 1, 1] helper_box.add_widget(Widget()) helper_box.add_widget(left_label) helper_box.add_widget(Widget()) helper_box.add_widget(Widget()) helper_box.add_widget(Widget()) helper_box.add_widget(right_label) helper_box.add_widget(Widget()) calibration_card.add_widget(calibration_label) calibration_card.add_widget(Widget()) calibration_card.add_widget(Widget()) calibration_card.add_widget(self.slider) calibration_card.add_widget(helper_box) calibration_card.add_widget(Widget()) toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') toolbar = MDToolbar(title='Add Contact', anchor_title='center') toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color toolbar.left_action_items = [[ 'arrow-left', lambda x: self.change_screen('welcome') ]] toolbar_anchor.add_widget(toolbar) self.add_widget(calibration_card) self.add_widget(toolbar_anchor)
def __init__(self, **kwargs): super(RootWidget, self).__init__(**kwargs) self.anchor_x = 'right' self.anchor_y = 'top' mapview = MapView(zoom=11, lat=self.lat, lon=self.lon) self.add_widget(mapview) toolbar = MDToolbar( title="Map", background_palette="Primary", background_hue="500", elevation=10, ) toolbar.left_action_items = [["arrow-left", lambda x: x]] toolbar.right_action_items = [["magnify", lambda x: self.show_confirmation_dialog()]] self.add_widget(toolbar)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) app = MDApp.get_running_app() scroll = ScrollView() Mlist = MDList() layout = BoxLayout() layout.orientation = "vertical" toolbar = MDToolbar(title="Settings") toolbar.left_action_items = [["menu", lambda x: self.openNav()]] layout.add_widget(toolbar) scroll.add_widget(Mlist) layout.add_widget(scroll) self.add_widget(layout)
def ui_layout(self): self.clear_widgets() layout = BoxLayout(orientation='vertical') scroll = ScrollView(do_scroll_x=False, size_hint=(1, None), size=(Window.width, Window.height)) scroll_box = BoxLayout(orientation='vertical', size_hint_y=None, padding=(dp(12), dp(60)), spacing=dp(5)) scroll_box.bind(minimum_height=scroll_box.setter('height')) # Add more self.scrollbox.add_widget(MDLabel(text='')) to increase padding scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ', size_hint=(1, 5))) for contact in self.util.contact_list: contact_card = ContactCard(util=self.util, contact=contact ) scroll_box.add_widget(contact_card) scroll.add_widget(scroll_box) layout.add_widget(scroll) # Add floating action button to write messages add_contact_anchor = AnchorLayout(anchor_x='right', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) add_contact_btn = MDFloatingActionButton(icon='account-plus', size=[dp(56), dp(56)]) add_contact_btn.md_bg_color = App.get_running_app().theme_cls.primary_color add_contact_btn.theme_text_color = "Custom" add_contact_btn.text_color = [1, 1, 1, 1] add_contact_btn.bind(on_press=lambda x: self.change_screen('add_contact')) add_contact_anchor.add_widget(add_contact_btn) toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') toolbar = MDToolbar(title='Contacts', anchor_title='center') toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color toolbar.left_action_items = [['arrow-left', lambda x: self.change_screen('message')]] toolbar_anchor.add_widget(toolbar) self.add_widget(layout) self.add_widget(add_contact_anchor) self.add_widget(toolbar_anchor) self.do_layout()
def ui_layout(self): add_contact_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint=(0.75, 0.45), pos_hint={ 'top': 0.75, 'center_x': 0.5 }) add_contact_label = MDLabel(text='Enter In a User Name', font_style='H4', halign='center') add_contact_label.theme_text_color = 'Custom' add_contact_label.text_color = [1, 1, 1, 1] self.info_text = MDLabel(text='', halign='center') self.info_text.theme_text_color = 'Error' self.contact_input = MDTextFieldRound(size_hint=(0.75, None), pos_hint={'center_x': 0.5}) # Hides left icon self.contact_input.icon_left_dasabled = True # Moves widget out of the field of view self.contact_input.children[2].children[2].pos_hint = { 'center_x': 500, 'center_y': 500 } self.contact_input.icon_right = 'send' self.contact_input.children[2].children[0].bind( on_press=lambda x: self.check_name(self.contact_input.text)) add_contact_card.add_widget(add_contact_label) add_contact_card.add_widget(self.info_text) add_contact_card.add_widget(Widget()) add_contact_card.add_widget(Widget()) add_contact_card.add_widget(self.contact_input) toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') toolbar = MDToolbar(title='Add Contact', anchor_title='center') toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color toolbar.left_action_items = [[ 'arrow-left', lambda x: self.change_screen('contact') ]] toolbar_anchor.add_widget(toolbar) self.add_widget(add_contact_card) self.add_widget(toolbar_anchor)
def load_screen(self, book): """Loads all elements for the detailed info. Created as separate method because on every book we need to reload the information. """ self.book = book toolbar = MDToolbar(type="top") toolbar.left_action_items = [["arrow-left", self.go_back]] toolbar.right_action_items = [["delete", self.delete_item]] content = BookInfoContent(book) self.layout.add_widget(toolbar) self.layout.add_widget(content)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) app = MDApp.get_running_app() scroll = ScrollView() self.Mlist = MDList() self.build_list() layout = BoxLayout() layout.orientation = "vertical" toolbar = MDToolbar(title="Materials") toolbar.left_action_items = [ ["menu", lambda x: self.openNav()]] layout.add_widget(toolbar) scroll.add_widget(self.Mlist) layout.add_widget(scroll) self.action_popup = MaterialActionPopup(self.build_list) self.action = MDFloatingActionButton(icon="plus", pos_hint={"center_x":0.5}, on_release=self.action_popup.open) layout.add_widget(self.action) self.add_widget(layout)
def __init__(self): super(MyApp, self).__init__() self.boxlayout1 = MDBoxLayout(orientation="vertical") toolbar = MDToolbar(title="DEMO APP") toolbar.left_action_items = [["menu", "This is the navigation"]] toolbar.right_action_items = [[ "dots-vertical", lambda x: self.callback_1(x) ], ["clock"]] self.boxlayout1.add_widget(toolbar) self.boxlayout2 = MDBoxLayout() self.boxlayout1.add_widget(self.boxlayout2) from kivymd.uix.navigationrail import MDNavigationRail, MDNavigationRailItem self.navigationrail = MDNavigationRail( md_bg_color=get_color_from_hex("#ffffff"), # color_normal = get_color_from_hex("#718089"), #crash the app when clicking on an item, don't understand why... color_active=get_color_from_hex("#f3ab44"), visible="Persistent") self.item1 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Detection", icon='video-stabilization') self.item2 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Dashboard", icon='desktop-mac-dashboard') self.item3 = MDNavigationRailItem(navigation_rail=self.navigationrail, text="Settings", icon='cog-outline') self.navigationrail.add_widget(self.item1) self.navigationrail.add_widget(self.item2) self.navigationrail.add_widget(self.item3) self.boxlayout2.add_widget(self.navigationrail)
def ui_layout(self): self.clear_widgets() signin_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint=(0.75, 0.65), pos_hint={'top': 0.8, 'center_x': 0.5} ) sign_in_label = MDLabel(text='Sign in or Create an Account', font_style='H4', halign='center') sign_in_label.theme_text_color = 'Custom' sign_in_label.text_color = [1, 1, 1, 1] self.helper_label = MDLabel(text='', font_style='Caption', halign='center') self.helper_label.theme_text_color = 'Custom' self.helper_label.text_color = [1, 1, 1, 1] self.username_field = MDTextField() self.username_field.hint_text = "User Name" # Password self.password_field = MDTextField(password=True) self.password_field.hint_text = "Password" self.password_field.helper_text = "Password must be at least 8 characters" self.password_field.helper_text_mode = "on_focus" self.proceedButton = WelcomeButton(icon='account-alert', text=' Enter', size_hint=(None, None), size=(4 * dp(48), dp(48))) signin_card.add_widget(sign_in_label) if self.status == 'signed_in': sign_in_label.text = '%s already signed in!' % self.util.username signin_card.add_widget(self.helper_label) signin_card.add_widget(Widget()) signin_card.add_widget(Widget()) self.proceedButton.text = 'Logout' self.proceedButton.icon = 'logout' self.proceedButton.bind(on_press=lambda x: self.remove_user_data()) signin_card.add_widget(self.proceedButton) elif self.status == 'sign_in': sign_in_label.text = 'Sign In' self.proceedButton.bind(on_press=lambda x: self.auth_token()) signin_card.add_widget(self.helper_label) signin_card.add_widget(self.username_field) signin_card.add_widget(self.password_field) signin_card.add_widget(self.proceedButton) signin_card.add_widget(Widget()) elif self.status == 'create': sign_in_label.text = 'Create Account' signin_card.add_widget(self.helper_label) signin_card.add_widget(self.username_field) signin_card.add_widget(self.password_field) signin_card.add_widget(self.proceedButton) signin_card.add_widget(Widget()) self.proceedButton.bind(on_press=lambda x: self.create_account()) else: sign_in_button = WelcomeButton(icon='login', text='Sign-in') sign_in_button.bind(on_press=lambda x: self.up_date_layout('sign_in')) create_account_button = WelcomeButton(icon='creation', text='Sign-up') create_account_button.bind(on_press=lambda x: self.up_date_layout('create')) choice_box = BoxLayout(orientation='horizontal') choice_box.add_widget(Widget()) choice_box.add_widget(sign_in_button) choice_box.add_widget(Widget()) choice_box.add_widget(Widget()) choice_box.add_widget(create_account_button) choice_box.add_widget(Widget()) signin_card.add_widget(Widget()) signin_card.add_widget(Widget()) signin_card.add_widget(choice_box) signin_card.add_widget(Widget()) toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') toolbar = MDToolbar(title='Add Contact', anchor_title='center') toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color toolbar.left_action_items = [['arrow-left', lambda x: self.change_screen('welcome')]] toolbar_anchor.add_widget(toolbar) self.add_widget(signin_card) self.add_widget(toolbar_anchor) self.do_layout()
def __init__(self, **kwargs): super(box, self).__init__(**kwargs) global bt1, bt2, bt3, main_box_self main_box = BoxLayout() main_box.orientation = 'vertical' main_box_self = main_box self.anim_type = 'slide_above_simple' #################################################################### self.menu1 = BoxLayout(orientation='vertical', spacing=0.2) self.im1 = Image(source='image_2.jpg', color=(1, 1, 1, .5)) self.im1.size_hint = [ self.menu1.size_hint[0] * 0.3, self.menu1.size_hint[1] * 0.3 ] # self.im1.pos = (self.height*1, self.width*1) gd_menu = GridLayout(cols=1, spacing=0.1) menu_btn = Button(text='change wallpaper', background_color=(0, 0, 0, 0.2), color=(1, 1, 1, 1), size_hint_y=None) menu_btn.bind(on_release=lambda x: self.toggle_nav_drawer()) menu_btn.bind(on_release=(self.gonext)) menu_btn.bind( on_release=partial(change_image1.file_manager_open, self)) gd_menu.add_widget(menu_btn) self.menu1.add_widget(self.im1) self.menu1.add_widget(gd_menu) # self.menu1.add_widget(gd_menu.menu_btn) # self.add_widget(self.menu1) ######################################################## tb = MDToolbar(title='menu', background_palette='Primary') tb.md_bg_color = [0, 0, 0, 0] tb.left_action_items = [['menu', lambda x: self.toggle_nav_drawer()]] main_box.add_widget(tb) gridlayout = GridLayout(cols=1, size_hint_y=None, spacing=2) gridlayout.bind(minimum_height=gridlayout.setter('height')) index = 0 main_lyt = main_box dirpath = os.getcwd() for dirpath, dir_name, filename in os.walk(r'/storage/emulated/0/'): if (os.path.basename(dirpath) == 'Download' or os.path.basename(dirpath) == 'audios'): for fn in glob(dirpath + '/*.mp3'): btn = tbtn(id='song_btn', song_index=index) btn_inst.append(btn) songlist[index] = [fn, btn] # print(ID3(fn).text) file2 = File(str(fn)) # song_length = float(file2.info.pprint().split(',')[-1:][0][:-8]) # print(float(song_length)) try: pic_name = fn.split('/')[-1:][0][:-4] artwork = file2.tags['APIC:'].data with open(pic_name + '.jpg', 'wb') as img: img.write(artwork) cover_album.append(pic_name + '.jpg') except: rand_val = random.randint(0, 9) cover_album.append(m_image[rand_val]) btn.bind(on_press=partial(song_btn, index, main_lyt)) index = index + 1 gridlayout.add_widget(btn) for i in range(index): img = Image( id='tn', source=cover_album[index - 1 - i], # img = Image(id='tn',source='icon.png', size=(btn_inst[index - 1 - i].height * 0.8, btn_inst[index - 1 - i].height * 0.8), pos=(btn_inst[index - 1 - i].width - main_box.width * 0.8, (btn_inst[index - 1 - i].size[1] * i) + (main_box.width * 0.5)), allow_stretch=False) btn_inst[index - 1 - i].add_widget(img) lbl = Label( text=str(songlist[index - 1 - i][0].split('/')[-1:][0]), text_size=(btn_inst[index - 1 - i].width * 7.5, None), halign='left', valign='middle', max_lines=1, shorten=True, shorten_from='right', color=(1, 1, 1, 1), pos=(img.pos[0] * 30, (btn_inst[index - 1 - i].size[1] * i) + (main_box.width))) btn_inst[index - 1 - i].add_widget(lbl) scrollview = ScrollView() scrollview.add_widget(gridlayout) main_box.add_widget(scrollview) with self.menu1.canvas.before: Color(1, 1, 1, .8) self.menu1.rect1 = Rectangle(pos=self.menu1.pos, size=self.menu1.size) self.menu1.rect1.source = 'menu_image.jpg' with main_box.canvas.before: main_box.rect = Rectangle(pos=main_box.pos, size=np.array(Window.size)) main_box.rect.source = 'image_1.jpg' # def update_rect1(instance, value): instance.rect1.pos = instance.pos instance.rect1.size = instance.size def update_rect(instance, value): instance.rect.pos = instance.pos instance.rect.size = instance.size self.menu1.bind(pos=update_rect1, size=update_rect1) main_box.bind(pos=update_rect, size=update_rect) self.add_widget(main_box)
def ui_layout(self, contact): self.contact = contact self.clear_widgets() layout = BoxLayout(orientation='vertical') scroll = ScrollView(do_scroll_x=False, size_hint=(1, None), size=(Window.width, Window.height)) scroll_box = BoxLayout(orientation='vertical', size_hint_y=None, padding=(dp(12), dp(60)), spacing=dp(5)) scroll_box.bind(minimum_height=scroll_box.setter('height')) # Add more self.scrollbox.add_widget(MDLabel(text='')) to increase padding scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ', size_hint=(1, 5))) if contact != '' and contact in self.util.user_data[ 'message_dict'].keys(): for message in self.util.user_data['message_dict'][contact]: if self.util.username != message['sender']: pos_hint = {'center_x': 0.3} md_bg_color = [0.698, 0.875, 0.859, 1] text_color = [0, 0, 0, 1] else: pos_hint = {'center_x': 0.7} md_bg_color = [1, 1, 1, 0.6] text_color = [0, 0, 0, 1] message_label = MDLabel(text=message['message'], font_style='Caption', size_hint=(1, None)) if '_' not in message_label.text: self.util.morse.read(words=str(message_label.text)) message_label.text = self.util.morse.morse message_card = ConversationBubble(util=self.util, size=message_label.size, message=message_label, pos_hint=pos_hint, md_bg_color=md_bg_color, text_color=text_color) scroll_box.add_widget(message_card) # This is disgusting but its late and I'm running out of time # keeps the text off of the text input scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll_box.add_widget(MDLabel(text=' ')) scroll.add_widget(scroll_box) layout.add_widget(scroll) self.text_input = MDTextFieldRound() # Hides left icon self.text_input.icon_left_dasabled = True # Moves widget out of the field of view self.text_input.children[2].children[2].pos_hint = { 'center_x': 500, 'center_y': 500 } self.text_input.icon_right = 'send' self.text_input.children[2].children[0].bind( on_press=lambda x: self.send_message(self.text_input.text)) self.long_press_btn = LongpressButton(text_input_cb=self.text_input_cb, size=(dp(50), dp(1)), size_hint=(3, None)) input_box_horz = BoxLayout(orientation='horizontal') input_box_horz.add_widget(MDLabel(text='', size_hint=(0.05, None))) input_box_horz.add_widget(self.long_press_btn) input_box_horz.add_widget(MDLabel(text='', size_hint=(0.05, None))) text_input_anchor = AnchorLayout(anchor_x='center', anchor_y='bottom', padding=dp(65)) text_input_anchor.add_widget(self.text_input) tap_input_anchor = AnchorLayout(anchor_x='center', anchor_y='bottom', size_hint=(1, 0.1), padding=dp(15)) tap_input_anchor.add_widget(input_box_horz) toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') toolbar = MDToolbar(title=contact, anchor_title='center') toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color toolbar.left_action_items = [[ 'arrow-left', lambda x: self.return_screen() ]] toolbar_anchor.add_widget(toolbar) self.add_widget(layout) self.add_widget(text_input_anchor) self.add_widget(tap_input_anchor) self.add_widget(toolbar_anchor) self.do_layout() scroll.scroll_y = 0