How to use swipeItem method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...1461 oirArgs["limit"] = 11462 items = self._lastScreenshot.findItemsByBitmap(bitmap, **oirArgs)1463 if len(items) == 0:1464 return False1465 return self.swipeItem(items[0], direction, distance, **dragArgs)1466 def swipeItem(self, viewItem, direction, distance=1.0, **dragArgs):1467 """1468 swipe starting from viewItem to given direction.1469 Parameters:1470 viewItem (ViewItem)1471 item from which swipe starts1472 direction, distance1473 refer to swipe documentation.1474 startPos (pair of floats (x,y)):1475 position of starting swipe, relative to the item.1476 (0.0, 0.0) is the top-left corner,1477 (1.0, 0.0) is the top-right corner,1478 (1.0, 1.0) is the lower-right corner.1479 Values < 0.0 and > 1.0 start swiping from coordinates1480 outside the item.1481 delayBeforeMoves, delayBetweenMoves, delayAfterMoves,1482 movePoints1483 refer to drag documentation.1484 Returns True on success, False if sending input failed.1485 """1486 if "startPos" in dragArgs:1487 posX, posY = dragArgs["startPos"]1488 del dragArgs["startPos"]1489 x1, y1, x2, y2 = viewItem.bbox()1490 swipeCoords = (x1 + (x2-x1) * posX,1491 y1 + (y2-y1) * posY)1492 else:1493 swipeCoords = viewItem.coords()1494 return self.swipe(swipeCoords, direction, distance, **dragArgs)1495 def swipeOcrText(self, text, direction, distance=1.0, **dragAndOcrArgs):1496 """1497 Find text from the latest screenshot using OCR, and swipe it.1498 Parameters:1499 text (string):1500 the text to be swiped.1501 direction, distance1502 refer to swipe documentation.1503 startPos1504 refer to swipeItem documentation.1505 delayBeforeMoves, delayBetweenMoves, delayAfterMoves,1506 movePoints1507 refer to drag documentation.1508 OCR engine specific arguments1509 refer to help(obj.ocrEngine())1510 Returns True on success, False otherwise.1511 """1512 assert self._lastScreenshot != None, "Screenshot required."1513 dragArgs, rest = _takeDragArgs(dragAndOcrArgs)1514 ocrArgs, _ = _takeOcrArgs(self._lastScreenshot, rest, thatsAll=True)1515 items = self._lastScreenshot.findItemsByOcr(text, **ocrArgs)1516 if len(items) == 0:1517 return False1518 return self.swipeItem(items[0], direction, distance, **dragArgs)1519 def tap(self, (x, y), long=False, hold=0.0, count=1, delayBetweenTaps=0.175, button=None):1520 """1521 Tap screen on coordinates (x, y).1522 Parameters:1523 coordinates (floats in range [0.0, 1.0] or integers):1524 floating point coordinates in range [0.0, 1.0] are1525 scaled to full screen width and height, others are1526 handled as absolute coordinate values.1527 count (integer, optional):1528 number of taps to the coordinates. The default is 1.1529 delayBetweenTaps (float, optional):1530 time (seconds) between taps when count > 1.1531 The default is 0.175 (175 ms).1532 long (boolean, optional):...

Full Screen

Full Screen

MainApp.py

Source:MainApp.py Github

copy

Full Screen

1#Imports that the team built2from Food import Food3from User import User4from DBHandler import DBHandler56#Imports from the kivy library7from kivy.uix.screenmanager import (ScreenManager, Screen, NoTransition,8SlideTransition, CardTransition, SwapTransition,9FadeTransition, WipeTransition, FallOutTransition, RiseInTransition) 10from kivy.uix import anchorlayout11from kivymd.uix.card import MDCardSwipe12from kivymd.uix.picker import MDDatePicker13from kivymd.uix.picker import MDThemePicker14from kivymd.uix.dialog import MDDialog15from kivymd.uix.button import MDRectangleFlatButton16from kivymd.uix.button import MDFlatButton17from kivy.lang import Builder18from kivymd.app import MDApp19from kivymd.theming import ThemableBehavior20from kivymd.uix.list import OneLineIconListItem, MDList21from kivymd.uix.list import OneLineListItem22from kivymd.uix.list import OneLineAvatarIconListItem23from kivymd.icon_definitions import md_icons24from kivymd.uix.list import IconRightWidget25from kivymd.uix.list import IconLeftWidget26from kivymd.uix.list import IRightBodyTouch27from kivymd.uix.selectioncontrol import MDCheckbox28from kivymd.uix.textfield import MDTextField 29from kivy.uix.screenmanager import Screen,ScreenManager30from kivy.core.window import Window31from kivy.uix.boxlayout import BoxLayout32from kivy.properties import StringProperty, ListProperty, ObjectProperty33#End imports from kivy library34#idk why this is saying it's an error, it runs fine with it there353637#Window size restrictions38Window.size = (400, 650)3940#SCREEN DEFINITIONS41class Registration(Screen): # Registration Window42 def register(self, username, password, email):43 query = f"INSERT INTO User VALUES('{username}', '{email}', PASSWORD('{password}'));"44 DB = DBHandler()45 if self.valid(username,DB):46 DB.exec(query)4748 def valid(self, username, db):49 users = db.exec(f"SELECT * FROM User WHERE username = '{username}'")50 if len(users) > 0:51 self.errorDialog()52 return(False)53 return(True)5455 def errorDialog(self):56 self.dialog = MDDialog(57 text = "ERROR: Username already registered"58 )59 self.dialog.open()6061class Login(Screen): # Login Window62 def login(self, username, password):63 db = DBHandler()6465 if self.valid(username, password):66 email = self.getEmail(username, db)67 user = User(username, email, password)68 App.user = user69 else:70 self.errorDialog()7172 def errorDialog(self):73 self.dialog = MDDialog(74 text = "ERROR: Invalid login information"75 )76 self.dialog.open()777879 def getEmail(self, username, db:DBHandler):80 query = f"SELECT email FROM User where username = '{username}'"81 email = db.exec(query)[0]82 return(email)8384 def valid(self, username, password):85 query = f"SELECT COUNT(*) FROM User WHERE username = '{username}' AND password = PASSWORD('{password}')"86 DB = DBHandler()87 count = DB.exec(query)88 if count[0][0]:89 return True90 return(False)9192class Recipes(Screen): # Recipe Window93 #class variable definitions9495 #There's stuff in this class that need to be taken out cause they're not used96 data = {97 # 'database-plus': 'Add all checked to Pantry',98 'delete': 'Delete all checked recipes',99 'plus':'Add recipe to Pantry',100 }101 102 bufferDate = None103 container = ObjectProperty()104 quantity = ObjectProperty()105 alreadyCheck = False106 alreadyCheckNav = False107108 RecipeList = [ #to be filled by database109 "", #empty item because the positioning puts it under the nav bar110 ]111 112 def on_enter(self):113 icons_item = { #This needs extra items at the bottom to fill out the nav bar - mid priority bug to be fixed later114 "food-apple": "Food",115 "pasta": "Recipes",116 "database": "Pantry",117 "brush": "Theme", #completely unesccesary but would be cool to customize colors of the app118 #see MDThemePicker https://kivymd.readthedocs.io/en/latest/components/pickers/index.html119 "logout": "log out",120 "a":"",121 "b":"",122 "c":"",123 "d":"",124 }125126 #pull items owned by a user from the database127 RecipeItems = App.db.exec(f"SELECT name FROM Recipe;")128 RecipeOtherThing = App.db.exec(f"SELECT * FROM Recipe;") #this will be used later129130 #fill the list with them131 for item in RecipeItems:132 self.RecipeList.append(item[0])133134 print(RecipeOtherThing[3][3])#debug135136 if self.alreadyCheckNav == False: #If the navbar is already full, don't fill it again137 for icon_name in icons_item.keys():138 self.ids.content_drawer.add_widget(139 ItemDrawer(icon=icon_name, text=icons_item[icon_name])140 )141 self.alreadyCheckNav = True142143 if self.alreadyCheck == False:144 for i in self.RecipeList: #prints all the items in user local list145 self.ids.container.add_widget(146 SwipeItem_Recipe(text = i)147 )148 self.alreadyCheck = True149150 def remove_item(self,instance): #callback function to remove widgets, used for deleting items from the list151 self.ids.container.remove_widget(instance)152153 def JSON_maker(self,food,date,quant):154 #debug155 print(food) #returns the food name, will need to change the variable name of this156 #debug157 print("date in JSON maker: " + str(date))158 159 if date != None:160 print(date) #debug161162 if date != None: #if the date is not empty then set the expires boolean to true163 exp_bool = 1164 else:165 exp_bool = 0 #otherwise set it to false166167 if date != None: #2 different queries have to be called based on whether a date was given or not168 App.db.exec(f"INSERT INTO Food(owner,name,expired,exp_date) VALUES('{App.user.username}', '{food}', '{exp_bool}', '{date}')")169 else:170 App.db.exec(f"INSERT INTO Food(owner,name,expired) VALUES('{App.user.username}', '{food}', '{exp_bool}')")171172 JSON = { #debug173 "Owner" : App.user.username,174 "Name" : food,175 "Expires": exp_bool,176 "Exp_date": date,177 "Quantity": quant,178 "Type": None179 }180181 print(JSON) #debug182183 def got_date(self, the_date): #gets date from the calender184 self.bufferDate = the_date185 return(self.bufferDate)186187 def show_date_picker(self): #opens up the calender188 date_dialog = MDDatePicker(callback=self.got_date)189 date_dialog.open()190191 def show_recipe(self,instance):#Opens dialog box and prompts for additional information needed for the add to pantry functionality192 193 self.bufferDate = None #reset bufferdate back to null when dialog box opens194 self.food_name = instance.text #this gets the title of the item clicked195 self.pantry_item_instance = instance196197 #So looks like variables need to use self. to be able to use elsewhere198 close_button = MDRectangleFlatButton(text = 'Close', on_release=self.close_dialog)199 self.dialog = MDDialog(200 title = "Recipe Info",201 size_hint=(0.8,1),202 type="custom",203 content_cls = dialog_content_recipe(),204 buttons=[close_button],205 )206 self.dialog.open()207 # open thingy that prompts for more info and then creates a food object which is then sent to the food handler208209210 def close_dialog(self,instance): #closes the dialog box211 self.dialog.dismiss()212213 def submit_dialog(self,instance):214 #quant = self.dialog.content_cls.ids.quantity.text215 216 if App.sm.get_screen("window2").bufferDate: #if a date was selected assign it to a nicer variable name217 date = App.sm.get_screen("window2").bufferDate218 else: #else let it be empty219 date = None220 221 if self.dialog.content_cls.ids.quantity.text: #If quantity was chosen assign it to a nicer variable name222 quant = self.dialog.content_cls.ids.quantity.text223 else: #else it defaults to 1224 quant = 1225226227228 self.JSON_maker(self.food_name,date,quant) #send collected info to be sent to the database229 #after submitting, remove the item and close the box230 self.remove_item(self.pantry_item_instance) #removes the item from the list when button is pressed231 self.dialog.dismiss()232233 def call_back(self,instance):#debug234 if (instance.icon == 'delete'):235 self.deletion()236 else:237 self.show_data(self)238239 def deletion(self):240 for delete in CheckedItemsList:241 self.alreadyCheck = False;242 self.RecipeList.remove(delete)243 self.ids.container.clear_widgets()244 if self.alreadyCheck == False:245 for i in self.RecipeList: #prints all the items in user local list246 self.ids.container.add_widget(247 SwipeItem(text = i)248 )249 self.alreadyCheck = True250 CheckedItemsList.clear()251 print(*self.RecipeList, sep='\n')252253 def show_data(self, obj):254 close_button = MDRectangleFlatButton(255 text = "Add",256 pos_hint = {"center_x": 0.5, "center_y": 0.4},257 on_press = self.close_dialog,258 on_release = self.add_to_list259 )260 self.alreadyCheck = False261262 x_button = MDFlatButton(263 text = "X",264 pos_hint = {"center_x": 1.0, "center_y": 3.5},265 on_press = self.close_dialog266 )267268 self.foodItem = MDTextField(269 hint_text = "Enter an item",270 helper_text = "e.g. apples, bananas, orange, etc.",271 helper_text_mode = "on_focus",272 # icon_right_color = app.theme_cls.primary_color,273 pos_hint = {"center_x": 0.5, "center_y": 0.5},274 size_hint_x = None,275 width = 250276 )277278 self.dialog = MDDialog(279 title = "Enter an item:",280 size_hint = (0.7, 1),281 buttons = [close_button, x_button]282 )283284 self.dialog.add_widget(self.foodItem)285286 self.dialog.open()287 self.alreadyCheck = True288289290 def add_to_list(self, obj):291 self.RecipeList.append(self.foodItem.text)292 self.ids.container.add_widget(293 SwipeItem(text = self.foodItem.text)294 )295296class Pantry(Screen): # Pantry Screen297 #class variable definitions298299 #There's stuff in this class that need to be taken out cause they're not used300 data = {301 # 'database-plus': 'Add all checked to Pantry',302 'delete': 'Delete all checked from Pantry',303 'plus':'Add item to Pantry',304 }305 306 bufferDate = None307 container = ObjectProperty()308 quantity = ObjectProperty()309 alreadyCheck = False310 alreadyCheckNav = False311312 PantryList = [ #to be filled by database313 "", #empty item because the positioning puts it under the nav bar314 ]315 316 def on_enter(self):317 icons_item = { #This needs extra items at the bottom to fill out the nav bar - mid priority bug to be fixed later318 "food-apple": "Food",319 "pasta": "Recipes",320 "database": "Pantry",321 "brush": "Theme", #completely unesccesary but would be cool to customize colors of the app322 #see MDThemePicker https://kivymd.readthedocs.io/en/latest/components/pickers/index.html323 "logout": "log out",324 "a":"",325 "b":"",326 "c":"",327 "d":"",328 }329330 #pull items owned by a user from the database331 PantryItems = App.db.exec(f"SELECT name FROM Food WHERE owner = '{App.user.username}' ")332333 #fill the list with them334 for item in PantryItems:335 self.PantryList.append(item[0])336337 print(PantryItems)#debug338339 if self.alreadyCheckNav == False: #If the navbar is already full, don't fill it again340 for icon_name in icons_item.keys():341 self.ids.content_drawer.add_widget(342 ItemDrawer(icon=icon_name, text=icons_item[icon_name])343 )344 self.alreadyCheckNav = True345346 if self.alreadyCheck == False:347 for i in self.PantryList: #prints all the items in user local list348 self.ids.container.add_widget(349 SwipeItem_Pantry(text = i)350 )351 self.alreadyCheck = True352353 def remove_item(self,instance): #callback function to remove widgets, used for deleting items from the list354 self.ids.container.remove_widget(instance)355356 def JSON_maker(self,food,date,quant):357 #debug358 print(food) #returns the food name, will need to change the variable name of this359 #debug360 print("date in JSON maker: " + str(date))361 362 if date != None:363 print(date) #debug364365 if date != None: #if the date is not empty then set the expires boolean to true366 exp_bool = 1367 else:368 exp_bool = 0 #otherwise set it to false369370 if date != None: #2 different queries have to be called based on whether a date was given or not371 App.db.exec(f"INSERT INTO Food(owner,name,expired,exp_date) VALUES('{App.user.username}', '{food}', '{exp_bool}', '{date}')")372 else:373 App.db.exec(f"INSERT INTO Food(owner,name,expired) VALUES('{App.user.username}', '{food}', '{exp_bool}')")374375 JSON = { #debug376 "Owner" : App.user.username,377 "Name" : food,378 "Expires": exp_bool,379 "Exp_date": date,380 "Quantity": quant,381 "Type": None382 }383384 print(JSON) #debug385386 def got_date(self, the_date): #gets date from the calender387 self.bufferDate = the_date388 return(self.bufferDate)389390 def show_date_picker(self): #opens up the calender391 date_dialog = MDDatePicker(callback=self.got_date)392 date_dialog.open()393394 def add_pantry_item(self,instance):#Opens dialog box and prompts for additional information needed for the add to pantry functionality395 396 self.bufferDate = None #reset bufferdate back to null when dialog box opens397 self.food_name = instance.text #this gets the title of the item clicked398 self.pantry_item_instance = instance399400 #So looks like variables need to use self. to be able to use elsewhere401 close_button = MDRectangleFlatButton(text = 'Close', on_release=self.close_dialog)402 submit_button = MDRectangleFlatButton(text = 'Submit', on_release=self.submit_dialog)403 self.dialog = MDDialog(404 title = "Add item to Pantry?",405 size_hint=(0.8,1),406 type="custom",407 content_cls = dialog_content(),408 buttons=[submit_button,close_button],409 )410 self.dialog.open()411 # open thingy that prompts for more info and then creates a food object which is then sent to the food handler412413414 def close_dialog(self,instance): #closes the dialog box415 self.dialog.dismiss()416417 def submit_dialog(self,instance):418 #quant = self.dialog.content_cls.ids.quantity.text419 420 if App.sm.get_screen("window2").bufferDate: #if a date was selected assign it to a nicer variable name421 date = App.sm.get_screen("window2").bufferDate422 else: #else let it be empty423 date = None424 425 if self.dialog.content_cls.ids.quantity.text: #If quantity was chosen assign it to a nicer variable name426 quant = self.dialog.content_cls.ids.quantity.text427 else: #else it defaults to 1428 quant = 1429430431432 self.JSON_maker(self.food_name,date,quant) #send collected info to be sent to the database433 #after submitting, remove the item and close the box434 self.remove_item(self.pantry_item_instance) #removes the item from the list when button is pressed435 self.dialog.dismiss()436437 def call_back(self,instance):#debug438 if (instance.icon == 'delete'):439 self.deletion()440 else:441 self.show_data(self)442443 def deletion(self):444 for delete in CheckedItemsList:445 self.alreadyCheck = False;446 self.PantryList.remove(delete)447 self.ids.container.clear_widgets()448 if self.alreadyCheck == False:449 for i in self.PantryList: #prints all the items in user local list450 self.ids.container.add_widget(451 SwipeItem(text = i)452 )453 self.alreadyCheck = True454 CheckedItemsList.clear()455 print(*self.PantryList, sep='\n')456457 def show_data(self, obj):458 close_button = MDRectangleFlatButton(459 text = "Add",460 pos_hint = {"center_x": 0.5, "center_y": 0.4},461 on_press = self.close_dialog,462 on_release = self.add_to_list463 )464 self.alreadyCheck = False465466 x_button = MDFlatButton(467 text = "X",468 pos_hint = {"center_x": 1.0, "center_y": 3.5},469 on_press = self.close_dialog470 )471472 self.foodItem = MDTextField(473 hint_text = "Enter an item",474 helper_text = "e.g. apples, bananas, orange, etc.",475 helper_text_mode = "on_focus",476 # icon_right_color = app.theme_cls.primary_color,477 pos_hint = {"center_x": 0.5, "center_y": 0.5},478 size_hint_x = None,479 width = 250480 )481482 self.dialog = MDDialog(483 title = "Enter an item:",484 size_hint = (0.7, 1),485 buttons = [close_button, x_button]486 )487488 self.dialog.add_widget(self.foodItem)489490 self.dialog.open()491 self.alreadyCheck = True492493494 def add_to_list(self, obj):495 self.PantryList.append(self.foodItem.text)496 self.ids.container.add_widget(497 SwipeItem(text = self.foodItem.text)498 )499500class Window1(Screen): # WELCOME WINDOW501 pass502503504class Window2(Screen): #Main List Window -- CHANGE NAME LATER505 #class variable definitions506 data = {507 'database-plus': 'Add all checked to Pantry',508 'delete': 'Delete all checked',509 'plus':'Add item to list',510 }511 512 bufferDate = None513 container = ObjectProperty()514 quantity = ObjectProperty()515 alreadyCheck = False516 alreadyCheckNav = False517518 localList = [519 "", #empty item because the positioning puts it under the nav bar520 "pizza",521 "Banana",522 "Lamb",523 "Chicky nuggies",524 "Gogurt",525 "Cheeze stick",526 "Cold pasta sauce",527 "Spam",528 "Paimon",529 "Shallot",530 "Carrot",531 "Way too many green onions",532 "Chili",533 "Paprika",534 "Flour",535 "Sugar",536 "Apples",537 "Sour patch kids"538 ]539 def on_enter(self):540 icons_item = { #This needs extra items at the bottom to fill out the nav bar - mid priority bug to be fixed later541 "food-apple": "Food",542 "pasta": "Recipes",543 "database": "Pantry",544 "brush": "Theme", #completely unesccesary but would be cool to customize colors of the app545 #see MDThemePicker https://kivymd.readthedocs.io/en/latest/components/pickers/index.html546 "logout": "log out",547 "a":"",548 "b":"",549 "c":"",550 "d":"",551 }552553 if self.alreadyCheckNav == False: #If the navbar is already full, don't fill it again554 for icon_name in icons_item.keys():555 self.ids.content_drawer.add_widget(556 ItemDrawer(icon=icon_name, text=icons_item[icon_name])557 )558 self.alreadyCheckNav = True559560 if self.alreadyCheck == False:561 for i in self.localList: #prints all the items in user local list562 self.ids.container.add_widget(563 SwipeItem(text = i)564 )565 self.alreadyCheck = True566567 def remove_item(self,instance): #callback function to remove widgets, used for deleting items from the list568 self.ids.container.remove_widget(instance)569570 def JSON_maker(self,food,date,quant):571 #debug572 print(food) #returns the food name, will need to change the variable name of this573 #debug574 print("date in JSON maker: " + str(date))575 576 if date != None:577 print(date) #debug578579 if date != None: #if the date is not empty then set the expires boolean to true580 exp_bool = 1581 else:582 exp_bool = 0 #otherwise set it to false583584 if date != None: #2 different queries have to be called based on whether a date was given or not585 App.db.exec(f"INSERT INTO Food(owner,name,expired,exp_date) VALUES('{App.user.username}', '{food}', '{exp_bool}', '{date}')")586 else:587 App.db.exec(f"INSERT INTO Food(owner,name,expired) VALUES('{App.user.username}', '{food}', '{exp_bool}')")588589 JSON = { #debug590 "Owner" : App.user.username,591 "Name" : food,592 "Expires": exp_bool,593 "Exp_date": date,594 "Quantity": quant,595 "Type": None596 }597598 print(JSON) #debug599600 def got_date(self, the_date): #gets date from the calender601 self.bufferDate = the_date602 return(self.bufferDate)603604 def show_date_picker(self): #opens up the calender605 date_dialog = MDDatePicker(callback=self.got_date)606 date_dialog.open()607608 def add_pantry_item(self,instance):#Opens dialog box and prompts for additional information needed for the add to pantry functionality609 610 self.bufferDate = None #reset bufferdate back to null when dialog box opens611 self.food_name = instance.text #this gets the title of the item clicked612 self.pantry_item_instance = instance613614 #So looks like variables need to use self. to be able to use elsewhere615 close_button = MDRectangleFlatButton(text = 'Close', on_release=self.close_dialog)616 submit_button = MDRectangleFlatButton(text = 'Submit', on_release=self.submit_dialog)617 self.dialog = MDDialog(618 title = "Add item to Pantry?",619 size_hint=(0.8,1),620 type="custom",621 content_cls = dialog_content(),622 buttons=[submit_button,close_button],623 )624 self.dialog.open()625 # open thingy that prompts for more info and then creates a food object which is then sent to the food handler626627628 def close_dialog(self,instance): #closes the dialog box629 self.dialog.dismiss()630631 def submit_dialog(self,instance):632 #quant = self.dialog.content_cls.ids.quantity.text633 634 if App.sm.get_screen("window2").bufferDate: #if a date was selected assign it to a nicer variable name635 date = App.sm.get_screen("window2").bufferDate636 else: #else let it be empty637 date = None638 639 if self.dialog.content_cls.ids.quantity.text: #If quantity was chosen assign it to a nicer variable name640 quant = self.dialog.content_cls.ids.quantity.text641 else: #else it defaults to 1642 quant = 1643644645646 self.JSON_maker(self.food_name,date,quant) #send collected info to be sent to the database647 #after submitting, remove the item and close the box648 self.remove_item(self.pantry_item_instance) #removes the item from the list when button is pressed649 self.dialog.dismiss()650651 def call_back(self,instance):#debug652 if (instance.icon == 'delete'):653 self.deletion()654 else:655 self.show_data(self)656657 def deletion(self):658 for delete in CheckedItemsList:659 self.alreadyCheck = False;660 self.localList.remove(delete)661 self.ids.container.clear_widgets()662 if self.alreadyCheck == False:663 for i in self.localList: #prints all the items in user local list664 self.ids.container.add_widget(665 SwipeItem(text = i)666 )667 self.alreadyCheck = True668 CheckedItemsList.clear()669 print(*self.localList, sep='\n')670671 def show_data(self, obj):672 close_button = MDRectangleFlatButton(673 text = "Add",674 pos_hint = {"center_x": 0.5, "center_y": 0.4},675 on_press = self.close_dialog,676 on_release = self.add_to_list677 )678 self.alreadyCheck = False679680 x_button = MDFlatButton(681 text = "X",682 pos_hint = {"center_x": 1.0, "center_y": 3.5},683 on_press = self.close_dialog684 )685686 self.foodItem = MDTextField(687 hint_text = "Enter an item",688 helper_text = "e.g. apples, bananas, orange, etc.",689 helper_text_mode = "on_focus",690 # icon_right_color = app.theme_cls.primary_color,691 pos_hint = {"center_x": 0.5, "center_y": 0.5},692 size_hint_x = None,693 width = 250694 )695696 self.dialog = MDDialog(697 title = "Enter an item:",698 size_hint = (0.7, 1),699 buttons = [close_button, x_button]700 )701702 self.dialog.add_widget(self.foodItem)703704 self.dialog.open()705 self.alreadyCheck = True706707708 def add_to_list(self, obj):709 self.localList.append(self.foodItem.text)710 self.ids.container.add_widget(711 SwipeItem(text = self.foodItem.text)712 )713714715#DIALOG BOX716class dialog_content(BoxLayout):717 quantity = ObjectProperty()718719class dialog_content_recipe(BoxLayout):720 pass721722723#MAIN LIST CLASSES724725# Contains a list of names of the checked items726CheckedItemsList = []727728#Item boxes for the standard list729class SwipeItem(MDCardSwipe):730 '''' Card with behavior '''731 text = StringProperty()732 icon = StringProperty('android')733734#Item boxes for the Pantry list735class SwipeItem_Pantry(MDCardSwipe):736 '''' Card with behavior '''737 text = StringProperty()738 icon = StringProperty('android')739740741#Item boxes for the recipe list742class SwipeItem_Recipe(MDCardSwipe): 743 '''' Card with behavior '''744 text = StringProperty()745 icon = StringProperty('android')746747748749class ListItemWithCheckbox(OneLineAvatarIconListItem):750 '''' list item '''751 icon = StringProperty('android')752753class RightCheckBox(IRightBodyTouch,MDCheckbox):754 '''' right container '''755756 def CheckedItems(self, food):757 """758 This will run whenever the Check Box is pushed, and will determine if the item is759 already checked or not. If it is, the program will remove the item from the760 CheckedItemsList. Otherwise, it will add it to the tail end of the list.761 """762 if food in CheckedItemsList:763 CheckedItemsList.remove(food)764 else:765 CheckedItemsList.append(food)766767768769#NAVIGATION DRAWER CLASSES770class ItemDrawer(OneLineIconListItem): # icons and names in the nav list771 icon = StringProperty()772 text_color = ListProperty((0, 0, 0, 1)) #colors gets set back to black after click?773774 def on_press(self): #This controls what screen the user goes to when they click on each option in the 775 print(self.icon)776 if self.icon == "pasta":777 self.parent.parent.parent.parent.parent.current = "recipes"778 elif self.icon == "database":779 self.parent.parent.parent.parent.parent.current = "pantry"780 elif self.icon == "food-apple":781 self.parent.parent.parent.parent.parent.current = "window2"782783784class DrawerList(ThemableBehavior, MDList):785 def set_color_item(self, instance_item):786 """Called when tap on a menu item."""787 # Set the color of the icon and text for the menu item.788 for item in self.children:789 if item.text_color == self.theme_cls.primary_color:790 item.text_color = self.theme_cls.text_color791 break792 instance_item.text_color = self.theme_cls.primary_color793794class ContentNavigationDrawer(BoxLayout):795 pass796797798799#MAIN APP800class App(MDApp):801 #initialize user802 user = User("PeterParker","spidyman@gmail.com","password")803 #initialize database804 db = DBHandler()805 #SCREEN MANAGER AND SCREENS806 sm = ScreenManager()807 sm.add_widget(Window1(name="window1"))808 sm.add_widget(Window2(name="window2"))809 sm.add_widget(Login(name="login"))810 sm.add_widget(Registration(name="registration"))811 sm.add_widget(Recipes(name="recipes"))812 sm.add_widget(Pantry(name="pantry"))813 814 def build(self):815 screen = Builder.load_file('MainAppScreens.kv') #changed the name here 816 return screen817 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful