from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
from kivymd.uix.screen import MDScreen
from kivy.uix.scrollview import ScrollView
from kivy.uix.image import AsyncImage
from kivymd.uix.textfield import MDTextField
from kivymd.uix.list import MDList,ThreeLineAvatarIconListItem,ThreeLineListItem,ThreeLineAvatarListItem, ImageLeftWidget
from kivymd.uix.button import MDRectangleFlatButton, MDIconButton
from func import walmart,wholefoods,target
import pandas as pd
import boto3
import numpy as np
import webbrowser
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
# it will open google window in your browser
# creating Demo Class(base class)
class BestPrice(MDApp):
def build(self):
self.screen = MDScreen()
self.icon=' Screenshot 2023-07-06 at 3.30.19 PM-overlay.png'
# defining label with all the parameters
l = MDLabel(text="BestPrice",pos_hint={
'center_x': 0.8, 'center_y': 0.8},font_style='H3',
)
# defining Text field with all the parameters
self.nameitem = MDTextField(hint_text="Enter Your item", pos_hint={'center_x': 0.4, 'center_y': 0.7},size_hint_x=None, width=300,helper_text='Candy, Computers, Tents, Refrigator, etc.')
sbtn=MDIconButton(
icon="search-web",
pos_hint={"center_x": 0.5, "center_y": 0.7},on_release=self.searchscrap
)
# adding widgets to screen
self.screen.add_widget(self.nameitem)
self.screen.add_widget(sbtn)
self.screen.add_widget(l)
# returning the screen
return self.screen
# defining a btnfun() for the button to
# call when clicked on it
def searchscrap(self, obj):
print(self.nameitem.text)
walmart(self.nameitem.text)
target(self.nameitem.text)
wholefoods(self.nameitem.text)
data = {
"": [None],
}
try:
df1 = pd.read_csv('walmart.csv')
except:
df1=pd.DataFrame(data)
df1=df1.dropna()
try:
df2 = pd.read_csv('wholefoods.csv')
except:
df2=pd.DataFrame(data)
df2=df2.dropna()
try:
df3 = pd.read_csv('target.csv')
except:
df3=pd.DataFrame(data)
df3=df3.dropna()
combined_df = pd.concat([df1, df2, df3], axis=0)
# Reset the index of the combined dataframe
combined_df.reset_index(drop=True, inplace=True)
import re
print(combined_df['Price'])
combined_df['Price'] = combined_df['Price'].astype(str)
combined_df['Price'] = combined_df['Price'].str.replace(',', '')
combined_df['Price'] = combined_df['Price'].apply(lambda x: float(re.findall(r'\d.*', x)[0]) if re.findall(r'\d.*', x) else None)
# try:
# combined_df['Price'] = pd.to_numeric(combined_df['Price'].str.replace('Now ', ''))
# except:
# pass
combined_df.sort_values(by='Price', inplace=True)
print(combined_df['Price'])
# Save the combined dataframe to a new CSV file
from io import StringIO
combined_df.to_csv('result.csv', index=False)
csv_buffer = StringIO()
combined_df.to_csv(csv_buffer)
bucket_name = 'foodsaverkivyapp'
key = 'result.csv'
s3 = boto3.client('s3', aws_access_key_id='AKIAREZ56TUXHUQASGOF',
aws_secret_access_key='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')
s3.put_object(Body=csv_buffer.getvalue(), Bucket=bucket_name, Key=key)
scroll = ScrollView(pos_hint={'x':0.55 })
self.combined_df=combined_df
list_view = MDList()
print(np.shape(combined_df))
for i in range(np.shape(combined_df)[0]):
url=combined_df['Url'][i]
items = ThreeLineAvatarIconListItem(text=combined_df['Title'][i],
secondary_text=f"${combined_df['Price'][i]}",
tertiary_text=f"{combined_df['Rating'][i]} Stars",pos_hint={'x':0.5 , 'y': 0.1})
items.url = url
#items.Imagelink=combined_df['Imagelink'][i]
image_widget = ImageLeftWidget(source=combined_df['Imagelink'][i])
# Add the image widget to the custom list item
items.add_widget(image_widget)
# Bind the on_release event to a callback function
items.bind(on_release=self.on_item_release)
list_view.add_widget(items)
scroll.add_widget(list_view)
# End List
self.screen.add_widget(scroll)
def on_item_release(self, instance):
# Access the custom URL assigned to the item
url = instance.url
# Open the URL using appropriate methods (e.g., webbrowser.open)
# For demonstration purposes, we'll just print the URL
webbrowser.open_new_tab(url)
if __name__ == "__main__":
BestPrice().run()
Versions
Describe the bug When running my app on xcode i am getting a invalid symlink at my python3 file
To Reproduce • install kivy-ios by development • toolchain build python3 kivy pillow numpy • toolchain pip install --no-deps kivymd • toolchain pip install pandas requests boto3 • toolchain create app appdir •remove libfreetype.a • open and then run xcode project
Expected behavior App to launch
Logs
Screenshots
Additional context