Esempio n. 1
0
    def build(self):
        screen = Screen()
        
        list_view = MDList()
        scroll = ScrollView()
        
        # item1 = OneLineListItem(text='item 1')
        # item2 = OneLineListItem(text='item 2')
                
        # list_view.add_widget(item1)
        # list_view.add_widget(item2)

        # scroll.add_widget(list_view)
        # screen.add_widget(scroll)
        
        
        # for loop
        for i in range(1, 21):
            # icon = IconLeftWidget(icon='android')
            image = ImageLeftWidget(source='facebook_icon.png')
            items = ThreeLineAvatarListItem(
                text=f'item {i}',
                secondary_text='Hello world',
                tertiary_text='third text'
            )
            items.add_widget(image)
            list_view.add_widget(items)
            
        scroll.add_widget(list_view)
        screen.add_widget(scroll)
        
        return screen
Esempio n. 2
0
 def initializeBookingPage(self):
     # self.parent.get_screen("kv_listbooking").ids.bookinglist.add_widget()
     doctor = usersDB.getAccountData(userlogged, 'type')
     results = usersDB.loadBooking(userlogged)
     if doctor == True:
         for appointments in results:
             if appointments[2] == userlogged:
                 primary_text = appointments[0]
                 secondary_text = str(appointments[1])
                 tertiary_text = appointments[3]
                 profile = ThreeLineAvatarListItem(
                     text=primary_text,
                     secondary_text=secondary_text,
                     tertiary_text=tertiary_text)
                 self.parent.get_screen(
                     "kv_listbooking").ids.bookinglist.add_widget(profile)
                 print("DEBUG: Added a appointment in doctor's list")
             else:
                 pass
     else:
         for appointments in results:
             if appointments[0] == userlogged:
                 primary_text = appointments[2]
                 secondary_text = str(appointments[1])
                 tertiary_text = appointments[3]
                 profile = ThreeLineAvatarListItem(
                     text=primary_text,
                     secondary_text=secondary_text,
                     tertiary_text=tertiary_text)
                 self.parent.get_screen(
                     "kv_listbooking").ids.bookinglist.add_widget(profile)
                 print("DEBUG: Added a appointment to user's pending list")
             else:
                 pass
Esempio n. 3
0
    def adding_to_list(self, db_key):
        app = MDApp.get_running_app()
        items = self.database[db_key]
        url = items["url"]
        ua = FakeUserAgentBOR()
        headers = {"User-Agent": ua.random_chrome_user_agent()}
        try:
            page = requests.get(url, headers=headers)
            soup = BeautifulSoup(page.text, 'lxml')
            title = items["title"]
            if title == "":
                title = soup.find(id="productTitle").text
                title = title.strip()
                requests.patch(
                    "https://test-4efa7.firebaseio.com/%s/tracking_items/%s.json?auth=%s"
                    % (app.local_id, db_key, app.id_token),
                    data=json.dumps({"title": title}))
            try:
                price = soup.find(id="priceblock_ourprice").text
            except:
                price = "Error fetching price!"

            item = ThreeLineAvatarListItem(
                theme_text_color="Custom",
                text=title,
                secondary_theme_text_color="Custom",
                secondary_text="Current Price: " + str(price),
                secondary_text_color=[0, 0, 1, 1],
                tertiary_theme_text_color="Custom",
                tertiary_text="Your Price:  ₹ " + str(items["user_price"]),
                tertiary_text_color=[0, 1, 0, 1],
                on_release=partial(MDApp.get_running_app().popup, db_key,
                                   title, price, url))
            if price == "Error fetching price!":
                item.secondary_text_color = [1, 0, 0, 1]

            img_link = items["img_link"]
            if img_link == "":
                img = soup.find(id="imgTagWrapperId")
                img_str = img.img.get('data-a-dynamic-image')
                img_dict = json.loads(img_str)
                img_link = list(img_dict.keys())[3]
                requests.patch(
                    "https://test-4efa7.firebaseio.com/%s/tracking_items/%s.json?auth=%s"
                    % (app.local_id, db_key, app.id_token),
                    data=json.dumps({"img_link": img_link}))

            item.add_widget(Image(source=img_link))

            app.root.ids["tracking_item_screen"].ids["md_list"].add_widget(
                item)
        except:
            pass
Esempio n. 4
0
 def format_comment_preview(self, img_path: str, publication: Publication,
                            comment: Comment) -> BoxLayout:
     """
     set up a comment for preview (for profile page)
     """
     comment_preview = ThreeLineAvatarListItem(
         text=publication.title,
         secondary_text=publication.author,
         tertiary_text=f'"{comment.content[:20]}..."',
         ripple_scale=0,
         font_style='H6',
         secondary_font_style='Body2',
         secondary_theme_text_color='Primary')
     comment_preview.add_widget(ImageLeftWidget(source=img_path))
     return comment_preview
Esempio n. 5
0
    def on_start(self):
        for i in range(1,21):
            if i % 2 == 0:
                icon = IconLeftWidget(
                    icon="android"
                )

                item =  ThreeLineIconListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line"
                )
                item.add_widget(icon)

            else:
                image = ImageLeftWidget(
                    source="logoC.png"
                )

                item =  ThreeLineAvatarListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line"
                )
                item.add_widget(image)


            self.root.ids.container.add_widget(item)
Esempio n. 6
0
    def build(self):
        screen = Screen()
        self.theme_cls.primary_palette = "Green"

        list_view = MDList()

        scroll = ScrollView()
        scroll.add_widget(list_view)

        for i in range(1, 21):
            if i % 2 == 0:
                icon = IconLeftWidget(icon="android")

                item = ThreeLineIconListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line")
                item.add_widget(icon)

            else:
                image = ImageLeftWidget(source="logoC.png")

                item = ThreeLineAvatarListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line")
                item.add_widget(image)

            list_view.add_widget(item)

        screen.add_widget(scroll)

        return screen
Esempio n. 7
0
    def build(self):
        # screens
        screen1 = Screen(name="login")

        # l = GridLayout(cols=1)
        # label = MDLabel(text="fromage", halign='center', theme_text_color="Custom",
        #                 text_color=(0, 1, 0, 0.5), font_style='Caption',
        #                 pos_hint={'center_x': 0.5, 'center_y': 0.5})
        # icon_label = MDIcon(icon='language-python', halign='center',
        #                     pos_hint={'center_x': 0.5, 'center_y': 0.5})
        # l.add_widget(label)
        # l.add_widget(icon_label)
        # l.add_widget(MDFlatButton(text="fromage",
        # pos_hint={'center_x': 0.5, 'center_y': 0.5}))
        # l.add_widget(MDRectangleFlatButton(text='fromage',
        #                                   pos_hint={'center_x': 0.5, 'center_y': 0.5}))
        # username = MDTextField(text="enter id:", size_hint_x=None,
        #                        width=300, pos_hint={'center_x': 0.5, 'center_y': 0.5})

        button = MDRectangleFlatButton(text="show",
                                       pos_hint={
                                           'center_x': 0.5,
                                           'center_y': 0.4
                                       },
                                       on_release=self.show_data)
        self.username = Builder.load_string("""username_helper""")
        self.password = Builder.load_string("""password_helper""")

        screen1.add_widget(self.username)
        # screen1.add_widget(self.password)
        screen1.add_widget(button)

        self.sm.add_widget(screen1)

        # screen 2
        screen2 = Screen(name="list")
        scroll = ScrollView()
        list_view = MDList()

        items = [
            ThreeLineAvatarListItem(text="Item {}".format(i),
                                    secondary_text="Hello world",
                                    tertiary_text="text")
            for i in range(1, 21)
        ]
        for item in items:
            item.add_widget(ImageLeftWidget(source="fb.png"))
            list_view.add_widget(item)
        list_view.add_widget(
            MDRectangleFlatButton(text="show",
                                  pos_hint={
                                      'center_x': 0.5,
                                      'center_y': 0.4
                                  },
                                  on_release=self.change_dark))
        scroll.add_widget(list_view)
        screen2.add_widget(scroll)
        self.sm.add_widget(screen2)
        return self.sm
Esempio n. 8
0
 def display_teachers(self):
     first_line_text = "Nom : {}"
     second_line_text = "Prénoms : {}"
     third_line_text = "Matiere : {}"
     table_entries = dbmanager.get_all(dbmanager.DbTeacher)
     for entry in table_entries:
         item = ThreeLineAvatarListItem()
         item.text = first_line_text.format(entry.name)
         item.secondary_text = second_line_text.format(entry.surname)
         item.tertiary_text = third_line_text.format(entry.topic_name)
         item.secondary_theme_text_color = 'Primary'
         item.tertiary_theme_text_color = "Primary"
         # item.width = self.parent.width/2
         icon = ImageLeftWidget()
         icon.source = f"teacher_px.png"
         item.add_widget(icon)
         self.avatars_list.add_widget(widget=item)
Esempio n. 9
0
    def __init__(self, **kwargs):
        super(ItemList, self).__init__()

        #need left float layout
        left = MDFloatLayout()
        left_list = ThreeLineAvatarListItem(
            text=kwargs['name'],
            secondary_text='Expiration Date: ' + kwargs['exp_date'],
            tertiary_text='Extra Notes: ' + kwargs['extra_notes'] +
            ', Quantity: ' + kwargs['quantity'],
            pos_hint={"top": .5})
        left_image = Image(source='icons/foodbag.png',
                           pos_hint={
                               "top": .95,
                               "center_x": .08
                           },
                           size_hint=(.7, .7))
        left_list.add_widget(left_image)
        left.add_widget(left_list)

        self.add_widget(left)
Esempio n. 10
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        des_n_loc = MainMenuScreen()
        print(des_n_loc.show_data())
        description = des_n_loc.show_data()[0]
        location = des_n_loc.show_data()[1]

        json_data = f'https://jobs.github.com/positions.json?description={description}&location={location}'
        print(json_data)

        response = requests.get(url=json_data)
        response.raise_for_status()
        data = response.json()

        md_list = MDList()
        scroll = ScrollView()
        scroll.add_widget(md_list)

        for i in range(0, len(data)):

            company_logo = data[i]['company_logo']
            company = data[i]['company']
            title = data[i]['title']
            location = data[i]['location']

            icon_left_widget = IconLeftWidget(icon=f'language-{description}')

            list_item = ThreeLineAvatarListItem(
                text=company,
                secondary_text=title,
                tertiary_text=location,
            )

            list_item.add_widget(icon_left_widget)
            md_list.add_widget(list_item)

        self.add_widget(scroll)
Esempio n. 11
0
    def load_drivebay(self):
        #get the names of the drives in the system
        self.drives = win32api.GetLogicalDriveStrings()
        self.drives = self.drives.split('\000')[:-1]

        for i in self.drives:#iterate over no of drives
            self.disk_type = win32file.GetDriveType(i)#get the drive type

            if self.disk_type == 3:#If hard disk
                self.disk_usage = round(shutil.disk_usage(i)[2]/1024/1024/1024, 2)
                self.item = ThreeLineAvatarListItem(text=i,
                                                secondary_text = win32api.GetVolumeInformation(i)[0],
                                                tertiary_text = str(self.disk_usage) + "Gb is left")
                self.item2 = IconLeftWidget(icon = 'harddisk', pos=self.pos,size=self.size)
                self.item.add_widget(self.item2)
                self.item.bind(on_release = self.callback_function)
                self.ids.drivers.ids.drivebay.add_widget(self.item)

            elif self.disk_type == 2:# If pendrive or removable medium
                self.disk_usage = round(shutil.disk_usage(i)[2]/1024/1024/1024, 2)
                self.item = ThreeLineAvatarListItem(text=i,
                                                secondary_text = win32api.GetVolumeInformation(i)[0],
                                                tertiary_text = str(self.disk_usage) + "Gb is left")
                self.item2 = IconLeftWidget(icon = 'usb-flash-drive', pos=self.pos,size=self.size)
                self.item.add_widget(self.item2)
                self.item.bind(on_release = self.callback_function)
                self.ids.drivers.ids.drivebay.add_widget(self.item)

            elif self.disk_type == 3: #If cd drive
                self.disk_usage = round(shutil.disk_usage(i)[2]/1024/1024/1024, 2)
                self.item = ThreeLineAvatarListItem(text=i,
                                                secondary_text = win32api.GetVolumeInformation(i)[0],
                                                tertiary_text = str(self.disk_usage) + "Gb is left")
                self.item2 = IconLeftWidget(icon = 'album', pos=self.pos,size=self.size)
                self.item.add_widget(self.item2)
                self.item.bind(on_release = self.callback_function)
                self.ids.drivers.ids.drivebay.add_widget(self.item)

            elif self.disk_type == 0: #If drive is corrupt
                self.disk_usage = round(shutil.disk_usage(i)[2]/1024/1024/1024, 2)
                self.item = ThreeLineAvatarListItem(text=i,
                                                secondary_text = win32api.GetVolumeInformation(i)[0],
                                                tertiary_text = "Something is wrong with this drive")
                self.item2 = IconLeftWidget(icon = 'alert-circle', pos=self.pos,size=self.size)
                self.item.add_widget(self.item2)
                self.item.bind(on_release = self.callback_function)
                self.ids.drivers.ids.drivebay.add_widget(self.item)
Esempio n. 12
0
    def loadDoctors(self):

        # Creates a delete list for marker/list widgets
        global delete_list
        delete_list = []

        # Loads all doctors and calculate their distance through Harverstine formula
        results = usersDB.getDoctors()
        list_of_doctors = {}
        for doctor in results:
            location = usersDB.getAccountData(doctor, 'location')
            list_of_doctors[doctor] = location
        sorted_list = self.calculateHaversine(list_of_doctors)
        print("DEBUG: List has been sorted.\n", sorted_list)

        # Appends the sorted doctor list to the list view screen
        for doctors in sorted_list:
            distance = ""
            doctor_email = doctors[0]
            if (doctors[1] > 999):
                distance = str(round((doctors[1] / 1000), 1)) + "K KM"
            elif (doctors[1] <= 999):
                distance = (str(doctors[1]) + " KM")
            primary_text = usersDB.getAccountData(
                doctor_email, 'fname') + " " + usersDB.getAccountData(
                    doctor_email, 'lname')
            secondary_text = usersDB.getAccountData(doctor_email, 'profession')
            profile = ThreeLineAvatarListItem(
                text=primary_text,
                secondary_text=secondary_text,
                tertiary_text=distance,
                on_release=lambda doctor_email: self.loadDoctorBooking(
                    doctor_email))
            exist = True
            try:
                image = open("profiles/" + doctor_email + ".jpg")
                image.close()
            except IOError:
                exist = False
            if exist == True:
                picture = ImageLeftWidget(source="profiles/" + doctor_email +
                                          ".jpg")
            else:
                picture = ImageLeftWidget(source="profiles/default.png")
            profile.add_widget(picture)
            self.parent.get_screen(
                "kv_doctorlistview").ids.doctor_list.add_widget(profile)
            print("DEBUG: Added a doctor to list")

        # Creates a marker for the user's location in map view screen, appends to delete list for later
        user_location = usersDB.getAccountData(userlogged, 'location')
        user_marker = MapMarkerPopup(lat=user_location[0],
                                     lon=user_location[1],
                                     source="icons/you.png")
        self.parent.get_screen(
            "kv_doctormapview").ids.automaticmapview.add_widget(user_marker)
        delete_list.append(user_marker)

        # Creates map marker for all doctors in map view screen, appends to the delete list for later
        for doctor in results:
            location = usersDB.getAccountData(doctor, 'location')
            marker = MapMarkerPopup(lat=location[0],
                                    lon=location[1],
                                    source='icons/marker.png')
            existinMap = True
            try:
                imagemap = open("profiles/" + doctor_email + ".jpg")
                imagemap.close()
            except IOError:
                existinMap = False
            if existinMap == True:
                marker.add_widget(
                    Button(background_normal="profiles/" + doctor + ".jpg"))
            else:
                marker.add_widget(
                    Button(background_normal="profiles/default.png"))
            self.parent.get_screen(
                "kv_doctormapview").ids.automaticmapview.add_widget(marker)
            delete_list.append(marker)
            print("DEBUG: Added a doctor to map")
        print("DEBUG: Successfully loaded doctors to list/map view.")