def no_sessions_grid(self, msg, layout): new_card_layout = MDFloatLayout() # for centering excCard = MDCard( spacing=15, radius=[80], orientation="vertical", size_hint=(0.87, 0.7), padding=[ 11, 16, 0, 25 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", elevation=1) workout_name = MDLabel(text=msg, halign='center', font_style="Subtitle2", size_hint=(1, 0.1), theme_text_color="Custom", text_color=self.app.text_color) excCard.add_widget(workout_name) new_card_layout.add_widget(excCard) try: if self.ids.sets_grid == layout: dict_of_row_height = {0: 250} layout.rows_minimum = dict_of_row_height except: pass layout.clear_widgets() layout.add_widget(new_card_layout)
def account_changer(self, caller): self.popup_card = MDCard( size=(400, 400), size_hint=(None, None), md_bg_color=(0.1, 0.1, 0.1, 1), radius=(20, 20, 20, 20), ) self.layout = ModalView( size=(500, 500), size_hint=(None, None), background_color=(0, 0, 0, .9), background='atlas://data/images/defaulttheme/action_item') self.layout.add_widget(self.popup_card) #Create an object that holds the main ui using the template User_details self.user_details = User_Details() #set the current logged in user's username and password self.user_details.ids.user_name.text = current_user self.user_details.ids.password.text = current_password #bind the save function to the save button from the ui self.user_details.ids.save.bind( on_press=partial(user_menu_operations.saver, self, 1)) self.popup_card.add_widget(self.user_details) #dispay the popup self.layout.open()
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = 'vertical' # Main screen layout screen_layout = MDGridLayout() screen_layout.cols = 2 screen_layout.md_bg_color = [0, 1, 1, 1] # AC region self.timer = 0 # AC Card new_layout = MDFloatLayout() self.ac_card1 = AcCard((0.75, 0.75)) self.ac_card1.on_press = self.ac_touch_down self.ac_card1.on_release = self.ac_touch_up new_layout.add_widget(self.ac_card1) screen_layout.add_widget(new_layout) self.content = AcPopup() self.content.ac_card.on_release = partial(self.ac_touch_up, popup=True) self.ac_popup = Popup(title='AC settings', size_hint=(.75, .75)) self.ac_popup.content = self.content self.ac_popup.background_color = [i / 255 for i in [137, 205, 211]] + [1] #--------------------------------------------------------------# # Light setup new_layout = MDFloatLayout() self.light_card = MDCard( orientation='horizontal', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) self.light_card.md_bg_color = app.dark_color light_image = Image( source='static/light1.png', size_hint=(1, 1), ) self.light_card.on_press = self.light_change self.light_card.add_widget(light_image) new_layout.add_widget(self.light_card) screen_layout.add_widget(new_layout) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) screen_layout.add_widget(Button(text='TODO')) self.add_widget(screen_layout)
def __init__(self, **kwargs): super(SwipeHover, self).__init__(**kwargs) self.image_container = MDCard(radius=[ self.radius, ]) self.image = GridLayout(cols=2, rows=2) for index, text in enumerate(["pressed", "hover", "text", "normal"]): new = FitImage(source=f"images/{text}{self.source}.png", radius=[0, 0, 0, 0]) new.radius[index] = self.radius self.image.add_widget(new) self.image.children[0], self.image.children[1] = ( self.image.children[1], self.image.children[0], ) self.image_container.add_widget(self.image) self.image1 = FitImage( source=f"images/{theme_image[config_data['theme']][1]}.png", radius=[0], size_hint=(0, 0), pos_hint={ "center_x": 0.5, "center_y": -0.5 }, ) self.image2 = FitImage( source=f"images/{theme_image[config_data['theme']][3]}.png", radius=[0], size_hint=(0, 0), pos_hint={ "center_x": 0.5, "center_y": -0.5 }, ) self.text = MLabel( text=self.title, font_size=0, padding=[0, dp(40)], color=color(f"images/{theme_image[config_data['theme']][2]}.png") [:3] + [0], ) self.select = MDCheckbox( size_hint=(0, 0), pos_hint={ "center_x": 0.5, "center_y": -0.5 }, group="group", ) self.select.update_color() self.select.update_primary_color(self, self.text.color[:3] + [1]) self.select.bind(on_press=lambda a: self.parent.parent.parent.parent. parent.parent.theme(a)) self.add_widget(self.image_container) self.add_widget(self.text) self.add_widget(self.select)
def open_create_mode(self, instance): self.popup_card = MDCard( size=(200, 200), size_hint=(None, None), md_bg_color=(0.1, 0.1, 0.1, 1), radius=(20, 20, 20, 20), ) self.layout = ModalView( size=(500, 500), size_hint=(None, None), background_color=(0, 0, 0, .9), background='atlas://data/images/defaulttheme/action_item') self.layout.add_widget(self.popup_card) self.details = Details() self.details.remove_widget(self.details.ids.delete) items = [{ 'text': 'Dark Red' }, { 'text': 'Orange' }, { 'text': 'Yellow' }, { 'text': 'Green' }, { 'text': 'peach' }, { 'text': 'Blue-Green' }, { 'text': 'Purple' }, { 'text': 'Light-Purple' }, { 'text': 'Pink' }] self.details.menu = MDDropdownMenu(caller=self.details.ids.color, position="auto", width_mult=4, items=items) #bind a function that changes the text of the texfield when the user selects a color self.details.menu.bind(on_release=partial(Operations.set_color, self)) self.popup_card.add_widget(self.details) self.layout.open() anim1 = Animation( opacity=1, duration=.2, ) anim2 = Animation(size=(500, 500), duration=.2) anim1.start(self.popup_card) anim2.start(self.popup_card) #Bind the save sticky note function to the save button of the ui self.details.ids.save.bind( on_press=partial(Operations.save_changes, self, 2))
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_add_remove_stock_screen(self): for widget in self.add_remove_stock_widgets: self.root.ids.add_remove_stock_list.remove_widget(widget) self.add_remove_stock_widgets = [] keys = sorted(self.storage.keys()) stock_types = [] for key in self.storage: item = self.storage.get(key) if item['stock_type'] not in stock_types: stock_types.append(item['stock_type']) stock_types.sort() for stock_type in stock_types: widget = Subtitle_Widget(stock_type) self.root.ids.add_remove_stock_list.add_widget(widget) self.add_remove_stock_widgets.append(widget) for key in keys: item = self.storage.get(key) if item['stock_type'] == stock_type: name = item['name'] widget = Add_Remove_Stock_Card(name) self.root.ids.add_remove_stock_list.add_widget(widget) self.add_remove_stock_widgets.append(widget) widget = MDCard(size_hint_y=None, height='50dp') self.root.ids.add_remove_stock_list.add_widget(widget) self.add_remove_stock_widgets.append(widget)
def close_cotis_Dialog(self, btn): if btn.text == "OK": new_card = MDCard(orientation="vertical", padding="15dp", size_hint=(None, None), size=("180dp", "220dp"), pos_hint={ "center_x": 0.80, "center_y": 0.31 }) new_card.add_widget( MDFloatingActionButton( icon="alert", user_font_size="14sp", theme_text_color="Custom", text_color=get_color_from_hex("#ffffff"), md_bg_color=get_color_from_hex("#faaf00"), elevation_normal=0)) new_card.add_widget( MDLabel(text=self.motifs_cotis.text, pos_hint={ "x": 0.30, "y": 0.75 }, font_size='18sp')) new_card.add_widget( MDRoundFlatIconButton(icon="currency-eur", text=self.argent_cotis.text, pos_hint={ "center_x": 0.5, "center_y": 0.5 }, font_size='17sp', margin="30dp")) new_card.add_widget( MDIconButton(icon="trash-can", theme_text_color="Custom", font_size="18sp", text_color=get_color_from_hex("#071f38"), pos_hint={ "center_x": 0.5, "center_y": 0.3 })) self.INTERFACE.ids.Cotisation.add_widget(new_card) self.dialog.dismiss()
def __init__(self, stack_height=10): super(AudioIndicatorStack, self).__init__() self.orientation = 'vertical' self.padding = dp(2) self.spacing = dp(2) self.rect_array = [] self.stack_height = stack_height self.color_tuple = [ App.get_running_app().theme_cls.primary_color, [0, 0, 0, 0] ] # Builds a stack of rectangle box layouts for i in range(self.stack_height): rect = MDCard(size_hint=(1, 1)) rect.md_bg_color = App.get_running_app().theme_cls.primary_color self.rect_array.append(rect) self.add_widget(rect)
class LoginScreen(MDScreen): def request(self, *args): email = self.input_email.text senha = self.input_senha.text def on_success(req, res): print(str(res)) def on_error(*args): print(str(args)) def on_redirect(*args): print(f'redirect: {str(args)}') self.req = UrlRequest("http://127.0.0.1:5000/", on_success=on_success, on_error=on_error, verify=False, on_redirect=on_redirect, req_body=dumps({ 'email': email, 'senha': senha }), req_headers={'Content-Type': 'application/json'}) def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) self.card = MDCard() self.card.text = "Valida" self.box = BoxLayout() self.box.orientation = 'vertical' self.card.add_widget(self.box) self.button_login = MDRaisedButton(text="Login") self.input_senha = MDTextField(password=True) self.button_login.bind(on_press=self.request) self.card.padding = "20dp" self.input_email = MDTextField() self.input_email.hint_text = "E-mail" self.input_senha.hint_text = "Senha" self.box.add_widget(self.input_email) self.box.add_widget(self.input_senha) self.box.add_widget(self.button_login) self.add_widget(self.card)
def start_downloading(self): user_input = self.root.get_screen('main').ids.url_input.text # video = YouTube(user_input) # print(type(video)) if user_input != '' and re.search(r'^(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$', user_input): self.root.current = 'progress' screen_id = self.root.get_screen('progress').ids.video_list for num in range(1): main_layout = MDFloatLayout() flip_card = MDCard(size_hint=(.9, .9), pos_hint={'center_x':.5, 'center_y': .5}) box_1 = MDBoxLayout(orientation='vertical',) box_2 = MDBoxLayout(orientation='vertical', ) box_3 = MDBoxLayout(orientation='vertical', padding=20) img = AsyncImage(source=video.thumbnail_url, size_hint=(.9, .9), pos_hint={'center_x': .5, 'center_y': .5}) box_3.add_widget(img) box_3.add_widget( MDLabel( text=video.title, halign='center', font_style='Body2' ) ) box_2.add_widget(box_3) box_2.add_widget(MDRaisedButton(text='Download', pos_hint={'center_x': .5, 'center_y': .5}, size_hint=(.6, .1), on_release = self.quality_check,)) box_1.add_widget(box_2) advertisement_box = MDBoxLayout(orientation='vertical', size_hint=(1, .2)) advertisement_box.add_widget(MDLabel(text='Advertisement', halign='center')) advertisement_box.add_widget(MDProgressBar(pos_hint={"center_x": .5, })) box_1.add_widget(advertisement_box) flip_card.add_widget(box_1) main_layout.add_widget(flip_card) screen_id.add_widget(main_layout) else: self.show_message('Invalid URL!')
def create_widgets(self, title, image_source, price): item_card = MDCard(size=(300, 240), border_radius=20, radius=[ 20, ], elevation=10) #item_card.md_bg_color = [1, 0.54, 0, .3] card_layout = RelativeLayout() image = AsyncImage(source=image_source, size_hint=(.5, .5), pos_hint={ "center_x": .3, "center_y": .5 }) item_title = MDLabel(text=title, halign="center", theme_text_color="ContrastParentBackground", font_style="H5", pos_hint={ "center_x": .7, "center_y": .7 }) item_price = MDLabel(text=price, halign="center", theme_text_color="Secondary", pos_hint={ "center_x": .7, "center_y": .6 }) order = MDRaisedButton(text="Order", size_hint=(.5, None), pos_hint={ "center_x": .68, "center_y": .15 }) card_layout.add_widget(image) card_layout.add_widget(item_title) card_layout.add_widget(item_price) card_layout.add_widget(order) item_card.add_widget(card_layout) self.list_menu.add_widget(item_card)
def new_user(self, caller): self.popup_card = MDCard( size=(400, 400), size_hint=(None, None), md_bg_color=(0.1, 0.1, 0.1, 1), radius=(20, 20, 20, 20), ) self.layout = ModalView( size=(500, 500), size_hint=(None, None), background_color=(0, 0, 0, .9), background='atlas://data/images/defaulttheme/action_item') self.layout.add_widget(self.popup_card) self.user_details = User_Details() self.user_details.ids.save.bind( on_press=partial(user_menu_operations.saver, self, 2)) self.popup_card.add_widget(self.user_details) self.layout.open()
def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) self.card = MDCard() self.card.text = "Valida" self.box = BoxLayout() self.box.orientation = 'vertical' self.card.add_widget(self.box) self.button_login = MDRaisedButton(text="Login") self.input_senha = MDTextField(password=True) self.button_login.bind(on_press=self.request) self.card.padding = "20dp" self.input_email = MDTextField() self.input_email.hint_text = "E-mail" self.input_senha.hint_text = "Senha" self.box.add_widget(self.input_email) self.box.add_widget(self.input_senha) self.box.add_widget(self.button_login) self.add_widget(self.card)
def qabsecimi(self): self.nm = '' self.root.current = 'qabsecimi' self.siyahi = {'eight.jpg30': '#101', 'eleven.jpg50': '#102', 'fifteen.jpg50': '#103', 'five.jpg30': '#104', 'four.jpg50': '#105', 'fourteen.jpg10': '#106', 'nine.jpg50': '#107', 'nineteen.jpg50': '#108', 'seven.jpg50': '#109', 'six.jpg30': '#110', 'sixteen.jpg30': '#111', 'ten.jpg30': "#112", 'thirteen.jpg50': "#113", 'three.jpg50': "#114", 'twelve.jpg30': "#115", 'twenty.jpg30': "#116", 'twentyeight.jpg20': "#117", 'twentyfive.jpg50': "#118", 'twentyfour.jpg30': "#119", 'twentynine.jpg30': "#120", 'twentyone.jpg30': "#121", 'twentyseven.jpg50': "#122", 'twentysix.jpg50': "#123", 'twentythree.jpg20': "#124", 'twentytwo.jpg50': "#125", 'two.jpg10': "#126" } for qab in self.siyahi.keys(): a, b = os.path.splitext(qab) self.label = MDLabel(text=f'{b[4:]} ML Kod-{self.siyahi[f"{qab}"]}', halign='center', size_hint_y=.1) self.image = Image(source=f'{a}.jpg', size_hint_y=.9) self.card = MDCard(orientation='vertical', on_release=self.yaz) self.card.add_widget(self.label ) self.card.add_widget( self.image ) self.screen.get_screen('qabsecimi').ids.crsl1.add_widget(self.card)
def card(content, title=None, background_color=None, size=(0.7, 0.5)): """Вывод диалоговых окон с кастомным контентом.""" if not background_color: background_color = [1.0, 1.0, 1.0, 1] card = MDCard(size_hint=(1, 1), padding=5) # , background_color=background_color) if title: box = BoxLayout(orientation="vertical", padding=dp(8)) box.add_widget( MDLabel( text=title, theme_text_color="Secondary", font_style="Title", size_hint_y=None, height=dp(36), )) box.add_widget(MDSeparator(height=dp(1))) box.add_widget(content) card.add_widget(box) else: card.add_widget(content) dialog = ModalView(size_hint=size, background_color=[0, 0, 0, 0.2]) dialog.add_widget(card) # dialog.open() return dialog
def __init__(self, init_threshold=10, stack_count=30, **kwargs): super().__init__(**kwargs) self.orientation = 'vertical' self.stack_count = stack_count self.pause_color = [1, 1, 0] self.beep_color = [1, 0, 0] # Builds a stack of rectangle box layouts self.cell_array = [MDCard() for _ in range(self.stack_count)] for cell in self.cell_array: self.add_widget(cell) self.threshold = init_threshold self.set_threshold(init_threshold) self.set_level(0)
def get_playlist(self, title, listId): image = AsyncImage(source=playlist_images[listId], size_hint=(1, 1), pos_hint={'top': 0.9}, allow_stretch=True) card = MDCard(orientation='vertical', border_radius=15, radius=[0, 0, 15, 15], pos_hint={ "center_x": 0.5, "center_y": 0.5 }, size_hint=(None, None), size=(self.win_size * 0.3, self.win_size * 0.3)) card.add_widget(image) self.root.ids.trend_grid.add_widget( MDTextButton(text=title, pos_hint={'center_x': 0.5}, on_press=lambda x: self.show_top(title, listId))) self.root.ids.trend_grid.add_widget(card) self.root.ids.trend_grid.add_widget(MDLabel(text='')) self.root.ids.trend_grid.add_widget(MDLabel(text='')) self.root.ids.trend_grid.add_widget(MDLabel(text='')) self.root.ids.trend_grid.add_widget(MDLabel(text=''))
def ui_layout(self): start_game_button_anchor = AnchorLayout( anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)]) self.start_game_button.md_bg_color = App.get_running_app( ).theme_cls.primary_color self.start_game_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.start_game_button.bind(on_press=lambda x: self.start_game()) start_game_button_anchor.add_widget(self.start_game_button) game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={ 'top': 0.85, 'center_x': 0.5 }) rules = """Snakes and ladders is a game to play with your friends. Navigate your piece from start to finish, avoid the snakes, and take shortcuts going up the ladders. How to play: Each player starts from base. Both players alternatively roll the dice and move the respective pawns. If your pawn lands at the bottom of a ladder, you can move up to the top of the ladder. If your pawn lands on the head of a snake, you must slide down to the bottom of the snake. The first player to get to the last tile numbered '100' is the winner.""" game_label = MDLabel(text=rules, font_style='Body1', halign='center', size_hint=(1, 0.5)) game_label.theme_text_color = 'Custom' game_label.text_color = [1, 1, 1, 1] game_card.add_widget(game_label) game_card.md_bg_color = App.get_running_app().theme_cls.accent_color game_card.elevation = 15 self.add_widget(game_card) self.add_widget(start_game_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def ui_layout(self): start_game_button_anchor = AnchorLayout( anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)]) self.start_game_button.md_bg_color = App.get_running_app( ).theme_cls.primary_color self.start_game_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.start_game_button.bind(on_press=lambda x: self.start_game()) start_game_button_anchor.add_widget(self.start_game_button) game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={ 'top': 0.85, 'center_x': 0.5 }) rules = """You probably already know how to play Tic-Tac-Toe. It's a really simple game, right? That's what most people think. But if you really wrap your brain around it, you'll discover that Tic-Tac-Toe isn't quite as simple as you think! 1. The game is played on a grid that's 3 squares by 3 squares. 2. You are X, your friend (or the computer in this case) is O. Players take turns putting their marks in empty squares. 3. The first player to get 3 of her marks in a row (up, down, across, or diagonally) is the winner. 4. When all 9 squares are full, the game is over. If no player has 3 marks in a row, the game ends in a tie.""" game_label = MDLabel(text=rules, font_style='Body1', halign='center', size_hint=(1, 0.5)) game_label.theme_text_color = 'Custom' game_label.text_color = [1, 1, 1, 1] game_card.add_widget(game_label) game_card.md_bg_color = App.get_running_app().theme_cls.accent_color game_card.elevation = 15 self.add_widget(game_card) self.add_widget(start_game_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def ui_layout(self): start_game_button_anchor = AnchorLayout( anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)]) self.start_game_button.md_bg_color = App.get_running_app( ).theme_cls.primary_color self.start_game_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.start_game_button.bind(on_press=lambda x: self.start_game()) start_game_button_anchor.add_widget(self.start_game_button) game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={ 'top': 0.85, 'center_x': 0.5 }) rules = """Catch em all is a game where you have to catch the ever escaping target. With a limited amount you need to catch the target as fast as you can.. How to play: A random target appears all over the screen Click on it before it disappears and moves to another target Collect the target 10 times before the timer runs out to finish the game. Clicking on any obstacle or any area outside the ground gives a penalty of 4 seconds""" game_label = MDLabel(text=rules, font_style='Body1', halign='center', size_hint=(1, 0.5)) game_label.theme_text_color = 'Custom' game_label.text_color = [1, 1, 1, 1] game_card.add_widget(game_label) game_card.md_bg_color = App.get_running_app().theme_cls.accent_color game_card.elevation = 15 self.add_widget(game_card) self.add_widget(start_game_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def show_more(self, nap): self.ids.box.clear_widgets() cnx = mysql.connector.connect(user='******', password='******', database='landbroker') cursor = cnx.cursor() query = ( "SELECT id, reside, size, amount, mode_whole, mode_part, ownership, map_scan, distance FROM landbroker_sell WHERE is_active=True " ) cursor.execute(query) for (id, reside, size, amount, mode_whole, mode_part, ownership, map_scan, distance) in cursor: ''' card = MDCardPost(source="./black.jpg",tile_text=title, text_post="Date:"+str(date_as_is)+"\nAbout:"+about+"\nNotes:"+notes,card_size=(300,300) , with_image=True,callback=self.callback(value=self.isinstance.title_text), swipe=True) self.ids.box.add_widget(card,len(self.children)) ''' if mode_part is 1: mode = 'True' else: mode = 'False' a = str(id) layout = MDCard(orientation='horizontal', size_hint=(1, None), height=240, elevation=8) layout.add_widget( AsyncImage(source="http://127.0.0.1:8000/media/" + map_scan, keep_ratio=False, allow_stretch=True, size_hint=(.7, 1))) layout1 = GridLayout(cols=1, padding=5) layout1.add_widget(MDLabel(text='Land ID:' + a)) layout1.add_widget(MDLabel(text='Location: ' + reside)) layout1.add_widget(MDLabel(text='Size: ' + size)) layout1.add_widget(MDLabel(text='Amount: ' + amount)) layout1.add_widget(MDLabel(text='Ownership: ' + ownership)) layout1.add_widget(MDLabel(text='Distance: ' + distance)) layout1.add_widget(MDLabel(text='Selling in Parts: ' + mode)) layout1.add_widget( MDRaisedButton(text='Express Interest', md_bg_color=(.7, .2, .2, 1), increment_width=100, on_press=self.printer)) layout.add_widget(layout1) #print(a +'\n'+ b + '\n'+p) self.ids.box.add_widget(layout, len(self.children)) cursor.close() cnx.close()
def ui_layout(self): start_game_button_anchor = AnchorLayout( anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)]) self.start_game_button.md_bg_color = App.get_running_app( ).theme_cls.primary_color self.start_game_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.start_game_button.bind(on_press=lambda x: self.start_game()) start_game_button_anchor.add_widget(self.start_game_button) game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={ 'top': 0.85, 'center_x': 0.5 }) rules = """Hit the blocks popping up before they disappear! Hit the blocks a specific number of times to win the game! Keep in mind, you just have limited chances to hit the blocks. So buckle up for some exciting fun! """ game_label = MDLabel(text=rules, font_style='Body1', halign='center', size_hint=(1, 0.5)) game_label.theme_text_color = 'Custom' game_label.text_color = [1, 1, 1, 1] game_card.add_widget(game_label) game_card.md_bg_color = App.get_running_app().theme_cls.accent_color game_card.elevation = 15 self.add_widget(game_card) self.add_widget(start_game_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def on_start(self): for crop in sorted(Feedforward.labels): card = MDCard(orientation='vertical', size_hint=(None, None), size=(self.root.width, 300)) imgr = Image(source="images/" + str(crop) + str(".jpg"), size_hint_y=0.8, allow_stretch="True", keep_ratio="False") lbl = MDLabel(text=str(crop), size_hint_y=0.2, halign='center', valign='center') card.add_widget(imgr) card.add_widget(lbl) self.root.ids.md_list.add_widget(card)
def build(self): # AC Card self.ac_card = AcCard((0.5, 0.5)) self.add_widget(self.ac_card) # all the features for ac features_layout = MDGridLayout() features_layout.cols = 2 # Temp incease, decrease new_box_layout = MDFloatLayout() dec_button = Buttonn('temp-', colors['cold_color']) new_box_layout.add_widget(dec_button) dec_button.on_press = partial(self.ac_features_send, dec_button) features_layout.add_widget(new_box_layout) new_box_layout = MDFloatLayout() inc_button = MDCard( orientation='vertical', padding='10dp', pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.75, 0.75), ) inc_button.md_bg_color = ['warm_color'] inc_button.add_widget(MDLabel(text='Temp+')) inc_button.id = 'temp+' inc_button.on_press = partial(self.ac_features_send, inc_button) new_box_layout.add_widget(inc_button) features_layout.add_widget(new_box_layout) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) features_layout.add_widget(btn(text='TODO')) self.add_widget(features_layout)
def ui_layout(self): start_game_button_anchor = AnchorLayout(anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.start_game_button = MDFloatingActionButton(icon='play', size=[dp(56), dp(56)]) self.start_game_button.md_bg_color = App.get_running_app().theme_cls.primary_color self.start_game_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.start_game_button.bind(on_press=lambda x: self.start_game()) start_game_button_anchor.add_widget(self.start_game_button) game_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={'top': 0.85, 'center_x': 0.5}) rules = """The objective of Battleship is to try and sink all of the other player's before they sink all of your ships. All of the other player's ships are somewhere on his/her board. Player's take turns guessing out the coordinates of the enemy ships. If it's a hit the cell turns RED. If its a miss the cell turns BLUE. The first played to guess and hit all the ships completely wins!""" game_label = MDLabel(text=rules, font_style='Body1', halign='center', size_hint=(1, 0.5)) game_label.theme_text_color = 'Custom' game_label.text_color = [1, 1, 1, 1] game_card.add_widget(game_label) game_card.md_bg_color = App.get_running_app().theme_cls.accent_color game_card.elevation = 15 self.add_widget(game_card) self.add_widget(start_game_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def ui_layout(self): record_button_anchor = AnchorLayout( anchor_x='center', anchor_y='bottom', padding=[dp(25), dp(25), dp(25), dp(25)]) self.record_button = MDFloatingActionButton(icon='record', size=[dp(56), dp(56)]) self.record_button.md_bg_color = App.get_running_app( ).theme_cls.primary_color self.record_button.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.record_button.bind(on_press=lambda x: self.decode_audio()) record_button_anchor.add_widget(self.record_button) self.decode_input = MDTextFieldRound(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(0.85, 0.5)) self.decode_input.icon_left_dasabled = True # Moves widget out of the field of view self.decode_input.children[2].children[2].pos_hint = { 'center_x': 500, 'center_y': 500 } # This binds the right icon to record the input self.decode_input.icon_right = 'database-export' self.decode_input.children[2].children[0].bind( on_press=lambda x: self.clear_text()) decode_card = MDCard(padding=dp(24), spacing=dp(24), orientation='vertical', size_hint_x=0.85, size_hint_y=0.7, pos_hint={ 'top': 0.85, 'center_x': 0.5 }) decode_label = MDLabel(text='Decode Morse Code Audio', font_style='Body1', halign='center', size_hint=(1, 0.5)) decode_label.theme_text_color = 'Custom' decode_label.text_color = [1, 1, 1, 1] decode_card.add_widget(decode_label) decode_text = 'Hit record or enter Morse Code below to start decoding' self.decode_output_label = MDLabel(text=decode_text, font_style='Body1', halign='center', size_hint=(1, 0.5)) self.decode_output_label.theme_text_color = 'Custom' self.decode_output_label.text_color = [1, 1, 1, 1] if platform not in ['ios', 'android']: self.audio_indicator = AudioIndicator( stack_width=self.amr.bits_per_frame) else: self.audio_indicator = AudioIndicator(stack_width=40) self.audio_indicator.size_hint = (1, 2) decode_card.add_widget(self.audio_indicator) decode_card.add_widget(self.decode_output_label) decode_card.add_widget(self.decode_input) decode_card.md_bg_color = App.get_running_app().theme_cls.accent_color decode_card.elevation = 15 self.add_widget(decode_card) self.add_widget(record_button_anchor) # Nav Bar self.nav_bar = MyNavigationLayout() self.nav_bar_anchor = AnchorLayout(anchor_x='center', anchor_y='top') self.nav_bar_anchor.add_widget(self.nav_bar) self.add_widget(self.nav_bar_anchor)
def create_card(self, session, num_of_session, total_session_num, session_workout_name, session_date): new_card_layout = MDFloatLayout() # for centering excCard = MDCard( spacing=5, radius=[80], orientation="vertical", size_hint=(0.87, 0.97), padding=[ 25, 16, 15, 25 ], # [padding_left, padding_top,padding_right, padding_bottom]. pos_hint={ "center_y": 0.5, "center_x": 0.5 }, background="resources/card_back.png", elevation=1) # help_layout = self.create_top_card_layout(num_of_exc, num_of_exc_total, exc) # excCard.add_widget(help_layout) excnum = str(num_of_session + 1) + " of " + str(total_session_num) exc_num = MDLabel(text=" " + excnum, font_style="Caption", theme_text_color="Secondary", pos_hint={ "center_y": 0.85, "center_x": 0.17 }) # help_layout.add_widget(exc_num) # excCard.add_widget(help_layout) name_layout_y_size = 1.5 if len(session_workout_name) > 9: name_layout_y_size = 3 name_layout = MDGridLayout(rows=1, cols=3, size_hint_y=name_layout_y_size) workout = session_workout_name workout_name = MDLabel(text=workout, font_style="H5", theme_text_color="Custom", text_color=self.app.text_color, size_hint_x=1.5) workout_date = MDLabel(text=str(session_date), font_style="Caption", theme_text_color="Custom", text_color=self.app.text_color) name_layout.add_widget(workout_name) name_layout.add_widget(workout_date) name_layout.add_widget(exc_num) excCard.add_widget(name_layout) seperate = MDSeparator(height="1dp", color=self.app.text_color) excCard.add_widget(seperate) # session = ["3 X 8", "3 X 8", "3 X 8", "3 X 8"] for num_of_set, set in enumerate(session): set_label, set_number, reps_label = self.create_set_label( set, num_of_set) exc_layout = MDGridLayout(rows=1, cols=2) units_layout = MDGridLayout(rows=1, cols=2, size_hint_y=1.5) exc_layout.add_widget(set_label) exc_layout.add_widget(set_number) units_layout.add_widget(MDLabel(text="", size_hint_x=0.9)) units_layout.add_widget(reps_label) excCard.add_widget(exc_layout) excCard.add_widget(units_layout) new_card_layout.add_widget(excCard) return new_card_layout
def song_details(self, i): self.s_manager = self.root.ids.screen_manager self.change_screen('SongDetailsScreen') self.details_screen = self.root.ids.SongDetailsScreen self.details_screen.clear_widgets() self.song_name = self.search_data[i]['title'].replace( """, "'").replace("&", "&").replace("'", "'") self.song_id = self.search_data[i]['id'] try: self.artist_name = self.search_data[i]['more_info'][ 'primary_artists'].replace(""", "'").replace( "&", "&").replace("'", "'") self.album = self.search_data[i]['album'].replace( """, "'").replace("&", "&").replace("'", "'") except: self.artist_name = self.search_data[i]['subtitle'] self.image_url = self.search_data[i]['image'].replace( '50x50', '500x500').replace('150x150', '500x500') self.image_path = os.path.join(self.data_path, self.song_id + '.jpg') self.fetch_thread = threading.Thread(target=self.fetch_details) self.fetch_thread.start() self.details_screen.add_widget( MDIconButton(icon='chevron-left', pos_hint={ "center_x": 0.05, "center_y": 0.95 }, on_press=lambda x: self.back_screen())) song_image = AsyncImage(source=self.image_url, pos_hint={ "center_x": 0.5, "center_y": 0.5 }, allow_stretch=True) card = MDCard(orientation='vertical', pos_hint={ "center_x": 0.5, "center_y": 0.65 }, size_hint=(None, None), size=(self.win_size * 0.9, self.win_size * 0.9)) card.add_widget(song_image) self.details_screen.add_widget(card) self.details_screen.add_widget( MDLabel(text=self.song_name, halign='center', theme_text_color='Custom', text_color=self.theme_cls.primary_color, font_style='H4', bold=True, pos_hint={"top": 0.84})) self.details_screen.add_widget( MDLabel(text=self.artist_name, halign='center', theme_text_color='Secondary', font_style='H6', pos_hint={"top": 0.8})) self.spinner = MDSpinner(size_hint=(None, None), size=("50", "50"), pos_hint={ 'center_x': 0.5, "center_y": 0.15 }, active=True) #self.details_screen.add_widget(MDLabel(text=self.album, halign='center', theme_text_color='Hint', font_style='H6', pos_hint={"top":0.9})) self.heart_icon = MDIconButton(icon='heart-outline', user_font_size="30sp", theme_text_color='Secondary', pos_hint={ "center_x": 0.1, "center_y": 0.15 }, on_press=lambda x: self.add_fav()) self.details_screen.add_widget(self.heart_icon) self.play_progress = MDProgressBar(pos_hint={ 'center_x': 0.5, 'center_y': 0.25 }, size_hint_x=0.9, value=0, color=self.theme_cls.primary_color) self.details_screen.add_widget(self.play_progress) self.tap_target_view = MDTapTargetView( widget=self.heart_icon, title_text="Add to Favorites", description_text="Feature currently under development", widget_position="left_bottom", ) self.details_screen.add_widget( MDIconButton(icon="chevron-double-left", pos_hint={ "center_x": .3, "center_y": .15 }, user_font_size="50sp", on_release=lambda x: self.rewind())) self.details_screen.add_widget( MDIconButton(icon="chevron-double-right", pos_hint={ "center_x": .7, "center_y": .15 }, user_font_size="50sp", on_release=lambda x: self.forward())) self.play_btn = MDFloatingActionButton( icon='play', pos_hint={ 'center_x': 0.5, "center_y": 0.15 }, user_font_size="50sp", md_bg_color=(1, 1, 1, 1), elevation_normal=10, on_press=lambda x: self.play_song_online()) self.details_screen.add_widget(self.play_btn) self.details_screen.add_widget( MDIconButton(icon='arrow-collapse-down', user_font_size="30sp", theme_text_color='Secondary', pos_hint={ 'center_x': 0.9, "center_y": 0.15 }, on_press=lambda x: self.download_bar())) try: self.dia.dismiss() except: pass
def play_song(self, i): try: self.stop() except: pass link = self.down_path_list[i][0] if self.root.ids.screen_manager.current != 'PlayScreen': self.change_screen("PlayScreen") self.prepare(link) if link.endswith('.m4a'): self.audio = MP4(link) self.play_song_name = self.audio.get('\xa9nam', ['Unknown'])[0] #print(audio['\xa9alb']) self.play_art_name = self.audio.get('\xa9ART', ['Unknown'])[0] #print(audio['\xa9day']) #print(audio['\xa9gen']) try: self.img_data = self.audio["covr"][0] except: with open('cover.jpg', 'rb') as f: self.img_data = f.read() elif link.endswith('.mp3'): self.audio = MP3(link, ID3=EasyID3) self.audio_tags = ID3(link) self.play_song_name = self.audio.get('title', ['Unknown'])[0] self.play_art_name = self.audio.get('artist', ['Unknown'])[0] try: self.img_data = self.audio_tags.get("APIC:").data except: with open('cover.jpg', 'rb') as f: self.img_data = f.read() else: with open('cover.jpg', 'rb') as f: self.img_data = f.read() self.play_song_name = 'Unknown' self.play_art_name = 'Unknown' play_image_data = io.BytesIO(self.img_data) img = CoreImage(play_image_data, ext="jpg").texture song_image = Image(allow_stretch=True) song_image.texture = img self.root.ids.PlayScreen.clear_widgets() self.root.ids.PlayScreen.add_widget( MDIconButton(icon='chevron-left', pos_hint={ "center_x": 0.05, "center_y": 0.95 }, on_press=lambda x: self.back_screen())) card = MDCard(orientation='vertical', pos_hint={ "center_x": 0.5, "center_y": 0.65 }, size_hint=(None, None), size=(self.win_size * 0.9, self.win_size * 0.9)) card.add_widget(song_image) self.root.ids.PlayScreen.add_widget(card) self.root.ids.PlayScreen.add_widget( MDLabel(text=self.play_song_name, halign='center', theme_text_color='Custom', text_color=self.theme_cls.primary_color, font_style='H4', bold=True, pos_hint={"top": 0.84})) self.root.ids.PlayScreen.add_widget( MDLabel(text=self.play_art_name, halign='center', theme_text_color='Secondary', font_style='H6', pos_hint={"top": 0.8})) self.play_progress = MDProgressBar(pos_hint={ 'center_x': 0.5, 'center_y': 0.25 }, size_hint_x=0.9, value=0, color=self.theme_cls.primary_color) self.root.ids.PlayScreen.add_widget(self.play_progress) self.root.ids.PlayScreen.add_widget( MDIconButton(icon="chevron-double-left", pos_hint={ "center_x": .15, "center_y": .15 }, user_font_size="40sp", on_release=lambda x: self.rewind())) self.root.ids.PlayScreen.add_widget( MDIconButton(icon="chevron-double-right", pos_hint={ "center_x": .85, "center_y": .15 }, user_font_size="40sp", on_release=lambda x: self.forward())) self.next_button = MDIconButton( icon="skip-next", pos_hint={ "center_x": .65, "center_y": .15 }, user_font_size="55sp", on_release=lambda x: self.play_song(i + 1)) self.root.ids.PlayScreen.add_widget(self.next_button) self.previous_button = (MDIconButton( icon="skip-previous", pos_hint={ "center_x": .35, "center_y": .15 }, user_font_size="55sp", on_release=lambda x: self.play_song(i - 1))) self.root.ids.PlayScreen.add_widget(self.previous_button) self.play_btn = MDFloatingActionButton( icon='play', pos_hint={ 'center_x': 0.5, "center_y": 0.15 }, user_font_size="50sp", md_bg_color=(1, 1, 1, 1), elevation_normal=10, on_press=lambda x: self.play_song_offline(i)) self.root.ids.PlayScreen.add_widget(self.play_btn) self.length_stamp = MDLabel(text=self.convert_sec( self.sound.getDuration()), halign='right', theme_text_color='Secondary', padding_x='20dp', pos_hint={"top": 0.725}) self.root.ids.PlayScreen.add_widget(self.length_stamp) self.play_stamp = (MDLabel(text=self.convert_sec( self.sound.getCurrentPosition()), halign='left', theme_text_color='Secondary', padding_x='20dp', pos_hint={"top": 0.725})) self.root.ids.PlayScreen.add_widget(self.play_stamp) self.play_song_offline(i)