Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def save_to_favourite(self):
- print('added')
- app = MDApp.get_running_app()
- self.image=app.root.get_screen('buyscreen').ids.product_image2.source
- self.name=app.root.get_screen('buyscreen').ids.product_name2.text
- self.price=app.root.get_screen('buyscreen').ids.product_price2.text
- self.desc=app.root.get_screen('buyscreen').ids.product_description2.text
- self.contact=app.root.get_screen('buyscreen').ids.product_contact2.text
- self.location=app.root.get_screen('buyscreen').ids.product_location2.text
- dict1 = {'1':{'name': self.name, 'price': self.price, "image": self.image,'description':self.desc,'contact':self.contact,'location':self.location}}
- with open(self.p, 'w') as f:
- # f.write(json.dumps(dict1, indent=4))
- json.dump(dict1, f, indent=4)
- from pprint import pprint
- dict2 = {'3':{'name': self.name, 'price': self.price, "image": self.image,'description':self.desc,'contact':self.contact,'location':self.location}}
- if self.p.exists():
- dict1.update(dict2)
- pprint(dict2)
- with open(self.p, 'w') as f:
- json.dump(dict1, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement