class insert_interval(): def __init__(self, master, interval_no, type): self.master = master self.interval_master = Toplevel(master) self.messages = McError() self.interval_no = int(interval_no) self.type = type if (self.interval_no == 0): self.interval_master.destroy() self.master.deiconify() else: label_Interval = Label(self.interval_master, text="Interval ") self.entry_Interval = Entry(self.interval_master) label_Interval.grid(row=0, sticky=E) self.entry_Interval.grid(row=0, column=1) if (self.interval_no == 1): next_button = Button(self.interval_master, text="Finish", command=self.call) else: next_button = Button(self.interval_master, text="Next", command=self.call) next_button.grid(columnspan=2) self.interval_master.mainloop() def call(self): self.insert(self.type, self.interval_no, self.entry_Interval.get(), self.interval_master) def insert(self, type, interval_no, interval_time, interval_master): db = MindClockDb(self.master) if (type == "Production"): #sql="DELETE FROM production_interval" sql1 = "INSERT INTO production_interval(interval_no, interval) VALUES('{}','{}')".format( interval_no, interval_time) if (type == "Reproduction"): #sql="DELETE FROM reproduction_interval" sql1 = "INSERT INTO reproduction_interval(interval_no, interval) VALUES('{}','{}')".format( interval_no, interval_time) if (db.insert(sql1)): self.messages.success("Success", "Saved Successfully!") else: interval_master.withdraw() self.messages.error("Error", "Something went wrong!") interval_master.deiconify() self.interval_no = self.interval_no - 1 self.interval_master.destroy() self.__init__(self.master, self.interval_no, self.type)
class Dash_board(Toplevel): def __init__(self,master=None): self.master = master self.dashboard_master = Toplevel(master) self.dashboard_master.title("DASHBOARD") self.messages = McError() self.db = sqlite3.connect("mindclock.db") self.cursor = self.db.cursor() self.menubar = Menu(self.dashboard_master) self.filemenu = Menu(self.menubar, tearoff=0) self.filemenu.add_command(label="Generate Report", command=self.generate) self.menubar.add_cascade(label="File", menu=self.filemenu) self.label_Type = Label(self.dashboard_master, text="Test case type") self.label_Replication = Label(self.dashboard_master, text="Number of Replications") self.label_Intervals = Label(self.dashboard_master, text="Number of Intervals") self.type = StringVar() self.entry_Type_pro=Radiobutton(self.dashboard_master,variable=self.type,text="Production",value="Production") self.entry_Type_repro=Radiobutton(self.dashboard_master,variable=self.type,text="Reproduction",value="Reproduction") self.entry_Replication = Entry(self.dashboard_master) self.entry_Intervals =Entry(self.dashboard_master) self.label_Type.grid(row=0, sticky=E) self.label_Replication.grid(row=1,sticky=E) self.label_Intervals.grid(row=2,sticky=E) self.entry_Type_pro.grid(row=0, sticky=W+W+E, column=1) self.entry_Type_repro.grid(row=0, sticky=W+S, column=3) self.entry_Replication.grid(row=1, column=1) self.entry_Intervals.grid(row=2,column=1) self.save_button = Button(self.dashboard_master, text="Next", command=self.save) self.save_button.grid(columnspan=2) self.logout_button = Button(self.dashboard_master, text="Logout", command=self.logout) self.logout_button.grid(columnspan=2) self.dashboard_master.protocol("WM_DELETE_WINDOW",self.logout) self.dashboard_master.config(menu=self.menubar) def logout(self): self.master.deiconify() self.dashboard_master.destroy() def save(self): db = MindClockDb(self.dashboard_master) type = self.type.get() Replication=self.entry_Replication.get() Interval=self.entry_Intervals.get() sql = "INSERT INTO test_types(replicate, intervals, type) VALUES('{}','{}','{}')".format(Replication, Interval, type) sql1 = "DELETE FROM test_types WHERE type=('{}')".format(type) if(db.delete(sql1)): if(db.insert(sql)): self.messages.success("Success", "Saved Successfully!") else: dashboard_master.withdraw() self.messages.error("Error", "Something went wrong!") dashboard_master.deiconify() def generate(self): # sql="SELECT count(*) from users" # self.cursor.execute(sql) # result=self.cursor.fetchone() # result=result[0] usrftch=self.cursor.execute("SELECT DISTINCT user_id from operations") usr=self.cursor.fetchall() usr=list(sum(usr,())) print(len(usr)) print(usr) for x in usr : str = "Generated Report/"+x+".xlsx" report = xlsxwriter.Workbook(str) sql="select replicate,production_time,reproduction_time,result_time,type from operations where user_id=('{}')".format(x) mysel=self.cursor.execute(sql) item=self.cursor.fetchall() worksheet = report.add_worksheet(x) worksheet.write('A1', 'REPLICATION') worksheet.write('B1', 'PRODUCTION TIME') worksheet.write('C1', 'REPRODUCTION TIME') worksheet.write('D1', 'RESULT TIME') worksheet.write('E1', 'TYPE') for i, row in enumerate(item): for j, value in enumerate(row): worksheet.write(i+1, j, item[i][j]) report.close()
class signupFrame(): def __init__(self, master): self.master = master self.signup_master = Toplevel(master) self.frame = Frame(self.signup_master) self.messages = McError() self.label_Username = Label(self.signup_master, text="ID", font="papyrus") self.label_Firstname = Label(self.signup_master, text="First Name", font="papyrus") self.label_Lastname = Label(self.signup_master, text="Last name", font="papyrus") self.label_Age = Label(self.signup_master, text="Age", font="papyrus") self.label_Gender = Label(self.signup_master, text="Gender", font=("papyrus", 12)) self.label_Height = Label(self.signup_master, text="Height(cm)", font="papyrus") self.label_Weight = Label(self.signup_master, text="Weight", font="papyrus") #self.label_BMI = Label(self, text="BMI") self.label_password = Label(self.signup_master, text="password", font="papyrus") #self.label_confirm password = Label(self, text="confirm password") self.entry_Username = Entry(self.signup_master) self.entry_Firstname = Entry(self.signup_master) self.entry_Lastname = Entry(self.signup_master) self.entry_Age = Entry(self.signup_master) self.gender = StringVar() self.entry_Gender_male = Radiobutton(self.signup_master, variable=self.gender, text="Female", value="Female") self.entry_Gender_female = Radiobutton(self.signup_master, variable=self.gender, text="Male", value="Male") self.entry_Height = Entry(self.signup_master) self.entry_Weight = Entry(self.signup_master) #self.entry_BMI = Entry(self) # self.entry_password = Entry(self, show="*") #self.entry_confirm password = Entry(self, show="*") self.label_Username.grid(row=0, sticky=E) self.label_Firstname.grid(row=1, sticky=E) self.label_Lastname.grid(row=2, sticky=E) self.label_Age.grid(row=3, sticky=E) self.label_Gender.grid(row=4, sticky=E) self.label_Height.grid(row=5, sticky=E) self.label_Weight.grid(row=6, sticky=E) #self.label_BMI.grid(row=5, sticky=E) # self.label_password.grid(row=5, sticky=E) #self.label_confirm password.grid(row=7, sticky=E) self.entry_Username.grid(row=0, column=1) self.entry_Firstname.grid(row=1, column=1) self.entry_Lastname.grid(row=2, column=1) self.entry_Age.grid(row=3, column=1) self.entry_Gender_male.grid(row=4, sticky=W + W + E, column=1) self.entry_Gender_female.grid(row=4, sticky=W + S, column=3) self.entry_Height.grid(row=5, column=1) self.entry_Weight.grid(row=6, column=1) #self.entry_BMI.grid(row=5, column=1) # self.entry_password.grid(row=6, column=1) #self.entry_confirm password.grid(row=7, column=1) #self.checkbox = Checkbutton(self, text="welcome to mindclock") #self.checkbox.grid(columnspan=2) self.signbtn = Button(self.signup_master, text="signup", font="papyrus", command=self._signup_btn_clicked) self.signbtn.grid(columnspan=2) #self.login_button = Button(self.master, text="login", command=self.login_window) #self.login_button.pack() self.signup_master.geometry('500x400') # self.pack() self.signup_master.protocol("WM_DELETE_WINDOW", self.cancel) def BMI(self, weight, height): bmi = (float(weight)) * 10000 / (float(height) * float(height)) return bmi def _signup_btn_clicked(self): db = MindClockDb(self.signup_master) username = self.entry_Username.get() firstname = self.entry_Firstname.get() lastname = self.entry_Lastname.get() age = self.entry_Age.get() gender = self.gender.get() height = self.entry_Height.get() weight = self.entry_Weight.get() bmi = self.BMI(weight, height) sql = "INSERT INTO users(userid,firstname,lastname, age, weight, height, gender, bmi) VALUES('{}','{}','{}',{},'{}','{}','{}','{}')".format( username, firstname, lastname, age, weight, height, gender, bmi) if (db.insert(sql)): self.messages.success("Success", "Registered Successfully!") self.signup_master.destroy() self.master.deiconify() else: self.signup_master.withdraw() self.messages.error("Error", "Something went wrong!") self.signup_master.deiconify() def cancel(self): self.signup_master.destroy() self.master.deiconify() #BMI = self.entry_BMI.get() # password = self.entry_password.get() #confirm password = self.entry_confirm password.get() #if username == " password == "password": #tm.showinfo("Login info", "Welcome John") #else: #tm.showerror("Login error", "Incorrect username") # if __name__ == "__main__": # root = Tk() # lf = signupFrame(root) # root.mainloop()