Beispiel #1
0
    def add_cards(self, instance_grid_card):
        """Adds MDCardPost objects to the screen Cards
        when the screen is open."""

        from kivymd.cards import MDCardPost

        def callback(instance, value):
            if value is None:
                toast("Delete post %s" % str(instance))
            elif isinstance(value, int):
                toast("Set like in %d stars" % value)
            elif isinstance(value, str):
                toast("Repost with %s " % value)
            elif isinstance(value, list):
                toast(value[1])

        if not self.cards_created:
            self.cards_created = True
            menu_items = [{
                "viewclass": "MDMenuItem",
                "text": "Example item %d" % i,
                "callback": self.callback_for_menu_items,
            } for i in range(2)]
            buttons = ["facebook", "vk", "twitter"]

            instance_grid_card.add_widget(
                MDCardPost(text_post="Card with text",
                           swipe=True,
                           callback=callback))
            instance_grid_card.add_widget(
                MDCardPost(
                    right_menu=menu_items,
                    swipe=True,
                    text_post="Card with a button to open the menu MDDropDown",
                    callback=callback,
                ))
            instance_grid_card.add_widget(
                MDCardPost(
                    likes_stars=True,
                    callback=callback,
                    swipe=True,
                    text_post="Card with asterisks for voting.",
                ))

            instance_grid_card.add_widget(
                MDCardPost(
                    source="./assets/kitten-1049129_1280.png",
                    tile_text="Little Baby",
                    tile_font_style="H5",
                    text_post="This is my favorite cat. He's only six months "
                    "old. He loves milk and steals sausages :) "
                    "And he likes to play in the garden.",
                    with_image=True,
                    swipe=True,
                    callback=callback,
                    buttons=buttons,
                ))
Beispiel #2
0
    def add_cards(self, instance_grid_card):
        from kivymd.cards import MDCardPost

        def callback(instance, value):
            if value is None:
                toast('Delete post %s' % str(instance))
            elif isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif isinstance(value, str):
                toast('Repost with %s ' % value)
            elif isinstance(value, list):
                toast(value[1])

        if not self.cards_created:
            self.cards_created = True
            menu_items = [{
                'viewclass': 'MDMenuItem',
                'text': 'Example item %d' % i,
                'callback': self.callback_for_menu_items
            } for i in range(2)]
            buttons = ['facebook', 'vk', 'twitter']

            instance_grid_card.add_widget(
                MDCardPost(text_post='Card with text',
                           swipe=True,
                           callback=callback))
            instance_grid_card.add_widget(
                MDCardPost(
                    right_menu=menu_items,
                    swipe=True,
                    text_post='Card with a button to open the menu MDDropDown',
                    callback=callback))
            instance_grid_card.add_widget(
                MDCardPost(likes_stars=True,
                           callback=callback,
                           swipe=True,
                           text_post='Card with asterisks for voting.'))

            instance_grid_card.add_widget(
                MDCardPost(
                    source="./assets/kitten-1049129_1280.png",
                    tile_text="Little Baby",
                    tile_font_style="Headline",
                    text_post="This is my favorite cat. He's only six months "
                    "old. He loves milk and steals sausages :) "
                    "And he likes to play in the garden.",
                    with_image=True,
                    swipe=True,
                    callback=callback,
                    buttons=buttons))
Beispiel #3
0
    def CreateCard(self):
        def callback(instance, value):
            if value and isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif value and isinstance(value, str):
                toast('Repost with %s ' % value)
            elif value and isinstance(value, list):
                toast(value[1])
            else:
                print(str(instance), str(value))
                instance_grid_card.remove_widget(MDCardPost())
                toast('Delete post %s' % str(instance))

        instance_grid_card = self.screen.ids.grid_card
        instance_grid_card.add_widget(
            MDCardPost(
                path_to_avatar='film.png',
                name_data=' ',
                swipe=True,
                text_post='Card with a button to open the menu MDDropDown',
                callback=callback,
                id='1',
                likes_stars=True))

        print('llllllll')
        global p, f

        l = 'Card with a button to open the menu MDDropDown'
        p.append(l)
        f = open('text.txt', 'w')
        for i in p:
            f.write(i + '\n')

        f.close()
Beispiel #4
0
    def check_memory(self):
        self.ids.container.clear_widgets()
        con = sqlite3.connect(self.mainwid.DB_PATH)
        cursor = con.cursor()
        cursor.execute(
            'select ID, Dono, Marca, Defeito, Preco, Data_in, Data_out from products'
        )

        def callback_for_menu_items(text_item):
            data_id = text_item.split(' ')[1]
            print(len(text_item))
            self.mainwid.transition.direction = 'left'
            self.mainwid.goto_update(data_id)

        for i in cursor:

            menu_items = [{
                'viewclass': 'MDMenuItem',
                'text': 'Editar {}'.format(str(i[0])),
                'callback': callback_for_menu_items
            }]

            data_id = str(i[0])
            r1 = 'ID: ' + data_id + '\n'
            r2 = '[b]Dono:[/b] ' + i[1] + '      ' + '[b]Marca: [/b]' + i[
                2] + '      ' + '[b]Preco:[/b] R$' + str(i[4]) + '\n' '\n'
            r3 = '[b]Defeito:[/b] ' + i[3]

            self.ids.container.add_widget(
                MDCardPost(right_menu=menu_items,
                           name_data='Manutencao de celulares\n' + str(i[5]),
                           text_post=r1 + r2 + r3,
                           swipe=True,
                           path_to_avatar='myimage.png'))
Beispiel #5
0
    def CreateCard(self, instance, namefilm):
        def callback(instance, value):
            if value and isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif value and isinstance(value, str):
                toast('Repost with %s ' % value)
            elif value and isinstance(value, list):
                toast(value[1])
            else:
                toast('Удален фильм: %s' % str(namefilm))
                self.ids.grid_card.remove_widget(Card)
                self.DeleteCard(namefilm)

        instance_grid_card = self.ids.grid_card
        global l
        Card = MDCardPost(path_to_avatar='film.png',
                          name_data='Нужно посмотреть этот фильм: ',
                          swipe=True,
                          text_post=namefilm,
                          callback=callback)
        instance_grid_card.add_widget(Card)

        global files
        files.append(namefilm)
        f = open('text.txt', 'w')
        for i in files:
            f.write(i + '\n')
        f.close()
Beispiel #6
0
    def on_start(self):
        def callback_for_menu_items(text_item):
            toast(text_item)

        def callback(instance, value):
            if value and isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif value and isinstance(value, str):
                toast('Repost with %s ' % value)
            elif value and isinstance(value, list):
                toast(value[1])
            else:
                toast('Delete post %s' % str(instance))

        instance_grid_card = self.screen.ids.grid_card
        buttons = ['facebook', 'vk', 'twitter']
        menu_items = [
            {'viewclass': 'MDMenuItem',
             'text': 'Example item %d' % i,
             'callback': callback_for_menu_items}
            for i in range(2)
        ]

        if not self.cards_created:
            self.cards_created = True
            # loop database; load from tables
            db = pymysql.connect('localhost', 'root', 'kidflash', 'talanta')
            cursor = db.cursor()
            sql = "SELECT * FROM USERS"
            cursor.execute(sql)
            results = cursor.fetchall()
            names = []
            for result in results:
                names.append(result[1])

            for i in range(len(names)):
                instance_grid_card.add_widget(
                    MDCardPost(name_data=names[i], text_post="card with text",
                               swipe=True, callback=callback,card_size=(dp(300),dp(150))))
                instance_grid_card.add_widget(
                    MDCardPost(source="./assets/kitten-1049129_1280.jpg",
                               tile_text="Little Baby",
                               tile_font_style="H5",
                               text_post="",
                               with_image=True,card_size=(dp(300),dp(300)), callback=callback,
                               buttons=buttons))
Beispiel #7
0
    def get_ambulances(self, instance_grid_card):
        print(
            "AMBULANCES -------------------------------------------------------------"
        )
        """Adds MDCardPost objects to the screen Cards
        when the screen is open."""

        from kivymd.cards import MDCardPost

        def callback(instance, value):
            if value is None:
                toast('Delete post %s' % str(instance))
            elif isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif isinstance(value, str):
                toast('Repost with %s ' % value)
            elif isinstance(value, list):
                toast(value[1])

        menu_items = [{
            'viewclass': 'MDMenuItem',
            'text': 'Remove',
            'callback': self.callback_for_menu_items
        } for _ in range(1)]
        # Implement a method to check empty tables and change above!
        if (self.db != None):
            try:
                self.ambulances = self.db.get_info("Ambulance", "*")
            except Exception as ex:
                print(ex)
                return
            for _ in range(len(self.ambulances)):
                # 706F6F
                # FFAA00
                if (self.ambulances[_][4] == 0):
                    s = "assets/m_tab_ambulances_0.png"
                elif (self.ambulances[_][4] == 1):
                    s = "assets/m_tab_ambulances_1.png"
                else:
                    s = "assets/m_tab_ambulances_1.png"
                instance_grid_card.add_widget(
                    MDCardPost(
                        right_menu=menu_items,
                        swipe=True,
                        name_data=
                        f"{self.ambulances[_][2]}\nID:    {self.ambulances[_][0]}",
                        tile_font_style='H4',
                        path_to_avatar=s,
                        card_size=(Window.width, Window.height - 480),
                        text_post=
                        f"Producer:          {self.ambulances[_][1]}\nCapacity:     {self.ambulances[_][3]} persons",
                        callback=callback))
        else:
            pass  # Implement to add here a Label to say that the DB table is empty
        return
Beispiel #8
0
 def callback(instance, value):
     if value and isinstance(value, int):
         toast('Set like in %d stars' % value)
     elif value and isinstance(value, str):
         toast('Repost with %s ' % value)
     elif value and isinstance(value, list):
         toast(value[1])
     else:
         print(str(instance), str(value))
         instance_grid_card.remove_widget(MDCardPost())
         toast('Delete post %s' % str(instance))
Beispiel #9
0
    def get_patients(self, instance_grid_card):
        print(
            "PATIENTS ---------------------------------------------------------------"
        )
        """Adds MDCardPost objects to the screen Cards
        when the screen is open."""

        from kivymd.cards import MDCardPost

        def callback(instance, value):
            if value is None:
                toast('Delete post %s' % str(instance))
            elif isinstance(value, int):
                toast('Set like in %d stars' % value)
            elif isinstance(value, str):
                toast('Repost with %s ' % value)
            elif isinstance(value, list):
                toast(value[1])

        menu_items = [{
            'viewclass': 'MDMenuItem',
            'text': 'Remove',
            'callback': self.callback_for_menu_items
        } for _ in range(1)]
        # Implement a method to check empty tables and change above!
        if (self.db != None):
            try:
                self.patients = self.db.get_info("Patient", "*")
            except Exception as ex:
                print(ex)
                return
            for _ in range(len(self.patients)):
                if (self.patients[_][3] == "M"):
                    s = "assets/m_tab_pacients_m.png"
                elif (self.patients[_][3] == "F"):
                    s = "assets/m_tab_pacients_f.png"
                else:
                    s = "assets/m_tab_pacients_m.png"
                instance_grid_card.add_widget(
                    MDCardPost(
                        right_menu=menu_items,
                        swipe=True,
                        name_data=
                        f"{self.patients[_][2]} {self.patients[_][1]} ({self.patients[_][3]})\nID:    {self.patients[_][0]}",
                        tile_font_style='H4',
                        path_to_avatar=s,
                        card_size=(Window.width, Window.height - 480),
                        text_post=
                        f"Birthday:          {self.patients[_][4]}\nBlood Type:     {self.patients[_][5]}\nRH:                      {self.patients[_][6]}",
                        callback=callback))
        else:
            pass  # Implement to add here a Label to say that the DB table is empty
        return