How to use print_records method in avocado

Best Python code snippet using avocado_python

Reward_project.py

Source:Reward_project.py Github

copy

Full Screen

1from csv import Dialect2from tkinter import *3from PIL import ImageTk,Image #Python Imaging Library and it adds image processing to Python4import sqlite35from openpyxl import load_workbook67root = Tk()8root.title("Recycle Rewards")9root.geometry("600x600")10root.config(bg='#E4DA98')11root.photo = ImageTk.PhotoImage(Image.open("images.png"))12#root.workbook = load_workbook(filename="rewards.xlsx")13#root.sheet = root.workbook.active1415# Database1617#Create a database and connect18conn = sqlite3.connect('recycle_rewards.db')1920# Create cursor21c = conn.cursor()2223# Create table2425c.execute(""" CREATE TABLE IF NOT EXISTS reward_details(Barcode text,26 Product_Name text, 27 Product_Type text, 28 Product_quantity integer, 29 Points integer, 30 Total_Rewards integer)""" )313233 #create save function34def save():35 #Create a database and connect36 conn = sqlite3.connect('recycle_rewards.db')37 # Create cursor38 c = conn.cursor()39 # insert into the table40 c.execute("INSERT INTO reward_details VALUES (:bar, :name, :type, :qty, :epoints, :trewards)",41 {42 'bar': bar.get(),43 'name': name.get(),44 'type': type.get(),45 'qty' : qty.get(),46 'epoints': epoints.get(),47 'trewards': trewards.get()48 })4950 # Commit Changes51 conn.commit()5253 # Close Connection54 conn.close()5556 #clear the textboxes57 bar.delete(0, END)58 name.delete(0, END)59 type.delete(0, END)60 qty.delete(0, END)61 epoints.delete(0, END)62 trewards.delete(0, END)63646566 # create reset function 67def reset():68 #clear the textboxes69 bar.delete(0, END)70 name.delete(0, END)71 type.delete(0, END)72 qty.delete(0, END)73 epoints.delete(0, END)74 trewards.delete(0, END)7576def search():7778 #Create a database and connect79 conn = sqlite3.connect('recycle_rewards.db')8081 # Create cursor82 c = conn.cursor()8384 # search the data85 c.execute("SELECT *, oid FROM reward_details")86 records = c.fetchall()87 #print(records)88 #print_records89 # fetch results90 print_records = ''91 for record in records:92 print_records += str(record[0]) + " " + str(record[1]) + " " + str(record[2]) + " " + str(record[3]) + " "+ str(record[4]) + " "+ str(record[5]) + "\n"93 with open("rewards.xlsx", mode='w') as file:94 file.write("Records " + print_records) 9596 search_label = Label(root, text=print_records)97 search_label.grid(row=9, column=0, columnspan=5, rowspan=6, sticky='NSEW')98 99 100101 # Commit Changes102 conn.commit()103104 # Close Connection105 conn.close()106107 return108109'''110111 # create records display function 112def display():113114 #Create a database and connect115 conn = sqlite3.connect('recycle_rewards.db')116117 # Create cursor118 c = conn.cursor()119120 # search the data121 c.execute("SELECT *, oid FROM reward_details")122 records = c.fetchall()123 #print(records)124 #print_records125 # fetch results126 print_records = ''127 with open('customer_rewards.csv', 'a') as f:128 w = csv.writer(f, dialect='excel')129 for record in records: 130 w.writerow(record) 131132133 search_label = Label(root, text=print_records)134 search_label.grid(row=9, column=0, columnspan=5, rowspan=6, sticky='NSEW')135 #print_records += str(record[0]) + " " + str(record[1]) + " " + str(record[2]) + " " + str(record[3]) + " "+ str(record[4]) + " "+ str(record[5]) + "\n"136 137 138139 # Commit Changes140 conn.commit()141142 # Close Connection143 conn.close()144145 return146'''147148# Create the graphical interface149150heading = Label(root, text='Recycle Rewards', fg='maroon', bg='#E4DA98',151 font=('Arial', 20, 'bold'))152barcode = Label(root, text='Product Barcode', fg='maroon', bg='#E4DA98', font=('NONE', 14))153bar = Entry(root)154product_name = Label(root, text='Product Name', fg='maroon', bg='#E4DA98', font=('NONE', 14))155name = Entry(root)156 157product_type = Label(root, text='Product Type', fg='maroon', bg='#E4DA98', font=('NONE', 14))158type = Entry(root)159 # insert(0, 'Enter product qty')160product_quantity = Label(root, text='Product Quantity', fg='maroon', bg='#E4DA98', font=('NONE', 14))161qty = Entry(root)162 # points.insert(0, 'Enter points')163points = Label(root, text='Points', fg='maroon', bg='#E4DA98', font=('NONE', 14))164epoints = Entry(root)165 # rewards.insert(0, 'Enter rewards')166rewards = Label(root, text='Total Rewards', fg='maroon', bg='#E4DA98', font=('NONE', 14))167trewards = Entry(root)168 169 # create buttons to save, reset and search170save_btn = Button(root, text='Save', bg='maroon', fg='#E4DA98', activebackground='red', height=1,171 width=8, bd=5, font=('NONE', 18), command=save)172reset_btn = Button(root, text='Reset', bg='maroon', fg='#E4DA98', activebackground='red',173 height=1, width=8, bd=5, font=('NONE', 18), command=reset)174search_btn = Button(root, text='Search', bg='maroon', fg='#E4DA98', activebackground='red',175 width=8, bd=5, font=('NONE', 18), command=search)176title1 = Label(root, text='Programmed by Jimmy,Bipin,Rajbeer&Neha', fg='maroon', bg="#E4DA98",177 font=('NONE', 12))178image_label = Label(image=root.photo)179180 # bind all events181heading.grid(row=0, column=0, columnspan=2, sticky='w')182183barcode.grid(row=1, column=0, sticky='w')184bar.grid(row=1, column=1, sticky='w')185186product_name.grid(row=2, column=0, sticky='w')187name.grid(row=2, column=1, sticky='w')188189product_type.grid(row=3, column=0, sticky='w')190type.grid(row=3, column=1, sticky='w')191192product_quantity.grid(row=4, column=0, sticky='w')193qty.grid(row=4, column=1, sticky='w')194195points.grid(row=5, column=0, sticky='w')196epoints.grid(row=5, column=1, sticky='w')197198rewards.grid(row=6, column=0, sticky='w')199trewards.grid(row=6, column=1, sticky='w')200201 202save_btn.grid(row=7, column=0, columnspan=2, sticky='ws')203reset_btn.grid(row=7, column=1, columnspan=2, sticky='es')204search_btn.grid(row=7, column=2, columnspan=3, sticky='ws')205206title1.grid(row=8, column=3, sticky='w')207208image_label.grid(row=1, column=3, rowspan=5)209210211 # binding button widgets events212#save_btn.bind('<Button-1>',save)213#reset_btn.bind('<Button-1>', reset)214#search_btn.bind('<Button-1>',search)215216# Commit Changes217conn.commit()218219# Close Connection220conn.close()221222root.mainloop()223224225226227228229230231 ...

Full Screen

Full Screen

Home(Tkinter).py

Source:Home(Tkinter).py Github

copy

Full Screen

1from tkinter import *2import os3import os4import cv25import sqlite36#import faces7from PIL import ImageTk,Image8def training():9 os.system('python3 faces-train.py')10 tr = Label(screen, fg='red', text="Training Complete", font=("roboto", 8))11 tr.place(x=295,y=160)1213 1415def show_regis():16 '''17 screen2=Toplevel(screen)18 screen2.geometry("500x500")19 screen2.title("registered")20 conn = sqlite3.connect('Automated_attendance.db')21 c = conn.cursor()22 c.execute("SELECT * from student_details")23 records=c.fetchall()24 print(records)25 #print(type(records[0][0]))26 print_records= []27 for record in records:28 print_records += list(record) 2930 query_lebel = Label(screen2, text=records)31 query_lebel.grid(row="0",column="0")32 '''33 screen2 = Toplevel(screen)34 screen2.geometry("500x500")35 screen2.title("M.E.D.I.C.A.R.E-Users")36 conn = sqlite3.connect('Automated_attendance.db')37 c = conn.cursor()38 c.execute("SELECT * from student_details")39 records = c.fetchall()40 print(records)41 name_label = Label(screen2, text="Name ", font="Arial 12 bold italic")42 name_label.grid(row=0, column=0)4344 year_label = Label(screen2, text="Age", font="Arial 12 bold italic")45 year_label.grid(row=0, column=1)4647 branch_label = Label(screen2, text="D.O.B", font="Arial 12 bold italic")48 branch_label.grid(row=0, column=2)4950 course_label = Label(screen2, text="Address", font="Arial 12 bold italic")51 course_label.grid(row=0, column=3)52 row = 153 print_records=""54 for record in records:55 for i in range(4):56 print_records = str(record[i]) + " "57 query_lebel = Label(screen2, text=print_records, font="Arial 12 normal normal")58 query_lebel.grid(row=row, column=i)59 row += 16061 #query_lebel = Label(screen2, text=print_records,font = "Arial 12 normal normal")62 #query_lebel.grid(row="0",column="0")63 quit = Button(screen2, text="Quit", command=screen2.destroy, font="Arial 14 bold normal", pady="10")64 quit.grid(row=row, column=3)656667def recognition():68 os.system('python3 faces.py')697071def capture():72 #Capture user image73 74 Id= name.get()75 cam = cv2.VideoCapture(0)76 detector=cv2.CascadeClassifier('/home/nitish/Desktop/project/s_w/opencv-4.1.2/data/haarcascades/haarcascade_frontalface_alt2.xml')7778 79 os.mkdir("images/"+Id)80 sampleNum=081 while(sampleNum!=200):82 ret, img = cam.read()83 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)84 faces = detector.detectMultiScale(gray,scaleFactor=1.5, minNeighbors=5)85 for (x,y,w,h) in faces:86 cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)87 88 #incrementing sample number 89 sampleNum=sampleNum+190 #saving the captured face in the dataset folder91 #cv2.imwrite("images/user/."+Id+'.'+str(sampleNum)+".jpg",gray[y:y+h,x:x+w])92 cv2.imwrite("images/"+Id+"/"+Id+str(sampleNum)+".jpg",gray[y:y+h,x:x+w])9394 cv2.imshow('frame',img)9596 if cv2.waitKey(1) & sampleNum==200:97 break98 cam.release()99 cv2.destroyAllWindows()100101def data():102 #create database or connect to existing database103 conn = sqlite3.connect('Automated_attendance.db')104 c = conn.cursor()105106 c.execute("""CREATE TABLE IF NOT EXISTS student_details (107 name text,108 year text,109 branch text,110 course text,111 reg_no text,112 password text113 )""")114115 c.execute("Insert into student_details values(:name, :year, :branch, :course, :reg_no, :password)",116 {117 'name':name.get(),118 'year':year.get(),119 'branch':branch.get(),120 'course':course.get(),121 'reg_no':reg_no.get(),122 'password':password.get()123 })124125 c.execute("SELECT *,oid from student_details")126 records = c.fetchall()127 print(records)128129 conn.commit()130 conn.close()131 #register user to database 132133134 name.delete(0,END)135 year.delete(0,END)136 branch.delete(0,END)137 course.delete(0,END)138 reg_no.delete(0,END)139 password.delete(0,END)140141142def register():143 screen1=Toplevel(screen)144 screen1.geometry("500x500")145 screen1.title("M.E.D.I.C.A.R.E")146 screen1.config(bg="skyblue")147148 var = Label(screen1, fg="red", height="2", text="Sign Up !!!")149 var.place(x=180, y=20)150151 global name,year,branch,course,reg_no,password152 name=Entry(screen1,width="20")153 name.place(x=180,y=100)154155 year=Entry(screen1,width="20")156 year.place(x=180, y=130)157158159 branch=Entry(screen1,width="20")160 branch.place(x=180, y=160)161162 course = Entry(screen1,width="20")163 course.place(x=180, y=190)164165 reg_no=Entry(screen1,width="20")166 reg_no.place(x=180, y=220)167168 password = Entry(screen1,width=20)169 password.place(x=180, y=250)170171 name_label=Label(screen1,text ="Name:")172 name_label.place(x=100, y=100)173174 year_label=Label(screen1,text ="Age:")175 #year_label.grid(row=1,column=0)176 year_label.place(x=100, y=130)177178 branch_label=Label(screen1,text ="DOB:")179 branch_label.place(x=100, y=160)180181 course_label = Label(screen1,text="Address:")182 course_label.place(x=100, y=190)183184185 reg_label=Label(screen1,text ="Username:")186 reg_label.place(x=100, y=220)187 188 password_label=Label(screen1,text="Password:")189 password_label.place(x=100, y=250)190191 192 image=Button(screen1,text="Take Image",command=capture)193 image.place(x=180, y=300)194 var=StringVar(screen1,name="str")195 var = Label(screen1, fg="red", height="2", text="")196 var.place(x=80, y=390)197 regis=Button(screen1,text="Submit data",command=data)198 regis.place(x=180, y=360)199 quit = Button(screen1, text="Quit", command=screen1.destroy)200 quit.place(x=205, y=420)201202def Home():203 global screen204 screen=Tk()205 screen.geometry("400x400")206 screen.title("M.E.D.I.C.A.R.E")207 screen.config(bg="skyblue")208209 var = Label(screen,fg="red",height= "2",text="M.E.D.I.C.A.R.E")210211 var.place(x=140,y=20)212213 register_button=Button(text= "Sign Up", height= "2", command = register)214 register_button.place(x=60,y=100)215 train_button=Button(text="Train images[Registered Users]",height= "2", command=training)216 train_button.place(x=60, y=160)217 recognize_button=Button(text= "login", height= "2", command = recognition)218 recognize_button.place(x=60, y=220)219 show_registered=Button(text="Show Registered Users",height= "2",command=show_regis)220 show_registered.place(x=60, y=280)221 quit_button=Button(text="Quit",height= "2",command=screen.destroy)222 quit_button.place(x=60, y=340)223 224225226 screen.mainloop()227 ...

Full Screen

Full Screen

search_student_stats.py

Source:search_student_stats.py Github

copy

Full Screen

1from tkinter import *2# from playsound import playsound3import os4from datetime import datetime;5import mysql.connector;6from PIL import ImageTk,Image7from tkinter import messagebox8import mysql.connector;9root=Tk()10root.title("Scanning database..")11#elements for the dropdownbox12clicked=StringVar()13clicked.set("Final")14options={15 "Final",16 "Third",17 "Second"18}19#Defining function for clearing input of the field20def clear_input():21 name_box.delete(0,END)22 roll_no_box.delete(0,END)23 return24#Defining function for Database operation25def verify():26 year=clicked.get()27 if year=="Final":28 roll_no = roll_no_box.get()29 mydb = mysql.connector.connect(host="localhost", user="root", passwd="AdityaRP23", database="practice")30 cursor = mydb.cursor()31 sql = "SELECT STATS FROM Attendance WHERE roll_no=%(rollno)s;"32 mydata = {33 'rollno': roll_no34 }35 cursor.execute(sql, mydata)36 var1 = cursor.fetchall()37 print_records = ''38 for recod in var1:39 print_records += recod[0]40 if print_records=="Absent":41 query_lab = Label(root, text=print_records, font=("Candara", 12, "bold"),fg="red")42 query_lab.grid(row=5, column=0, columnspan=2)43 else:44 query_lab = Label(root, text=print_records,font=("Candara",12,"bold"))45 query_lab.grid(row=5, column=0, columnspan=2)46 mydb.commit()47 elif year=="Third":48 roll_no = roll_no_box.get()49 mydb = mysql.connector.connect(host="localhost", user="root", passwd="AdityaRP23", database="practice")50 cursor = mydb.cursor()51 sql = "SELECT STATS FROM Attendance_third WHERE roll_no=%(rollno)s;"52 mydata = {53 'rollno': roll_no54 }55 cursor.execute(sql, mydata)56 var1 = cursor.fetchall()57 print_records = ''58 for recod in var1:59 print_records += recod[0]60 if print_records=="Absent":61 query_lab = Label(root, text=print_records, font=("Candara", 12, "bold"),fg="red")62 query_lab.grid(row=5, column=0, columnspan=2)63 else:64 query_lab = Label(root, text=print_records,font=("Candara",12,"bold"))65 query_lab.grid(row=5, column=0, columnspan=2)66 mydb.commit()67 else:68 roll_no = roll_no_box.get()69 mydb = mysql.connector.connect(host="localhost", user="root", passwd="AdityaRP23", database="practice")70 cursor = mydb.cursor()71 sql = "SELECT STATS FROM Attendance_second WHERE roll_no=%(rollno)s;"72 mydata = {73 'rollno': roll_no74 }75 cursor.execute(sql, mydata)76 var1 = cursor.fetchall()77 print_records = ''78 for recod in var1:79 print_records += recod[0]80 if print_records=="Absent":81 query_lab = Label(root, text=print_records, font=("Candara", 12, "bold"),fg="red")82 query_lab.grid(row=5, column=0, columnspan=2)83 else:84 query_lab = Label(root, text=print_records,font=("Candara",12,"bold"))85 query_lab.grid(row=5, column=0, columnspan=2)86 mydb.commit()87 return88#Creating a label for Id89name_label = Label(root, text="Name",font=("Candara",12,"bold"),fg="#00008B")90name_label.grid(row=1,column=0,padx=10,pady=10)91#creating a label for Password92roll_no_label=Label(root,text="Roll No",font=("Candara",12,"bold"),fg="#00008B")93roll_no_label.grid(row=2,column=0,padx=10,pady=10)94#Entry Field for id95name_box=Entry(root,width=20,font=("Courier new",12,"bold"),fg="#000000")96name_box.grid(row=1,column=1,padx=10,pady=10)97#creating a Enrty field for Password98roll_no_box=Entry(root,width=20,font=("Courier new",12,"bold"),fg="#000000")99roll_no_box.grid(row=2,column=1,padx=10,pady=10)100#Label for Subject101sub_label=Label(root, text="Year",font=("Candara",12,"bold"),fg="#00008B")102sub_label.grid(row=3,column=0,padx=10,pady=10)103#Creating entry field for subject104#sub_entry=Entry(manual_frame,width=20)105#sub_entry.grid(row=3,column=1,padx=10,pady=10)106popupMenu = OptionMenu(root, clicked, *options)107popupMenu.grid(row=3,column=1,padx=10,pady=10,sticky=N+E+W+S)108#Creating submit and clear buttons109submit_btn = Button(root, text="Submit",font=("Candara",12,"bold"), command=verify)110reset_button = Button(root, text="Clear",font=("Candara",12,"bold"), command=clear_input)111#Setting up grids for submit and reset buttons112submit_btn.grid(row=4, column=1,padx=10,pady=10,ipadx=75)113reset_button.grid(row=4, column=0,padx=10,pady=10,ipadx=20)...

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 avocado 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