示例#1
0
	def __init__(self, master):
		self.master = master
		self.adminlogin_master = Toplevel(master)
		self.messages = McError()

		self.db=sqlite3.connect('mindclock.db')
		self.cursor=self.db.cursor()

		self.messages = McError()

		self.frame = Frame(self.adminlogin_master)
		self.username = Label(self.adminlogin_master, text="Username",font="papyrus").pack()
		self.username = Entry(self.adminlogin_master)
		self.username.pack()
		self.password = Label(self.adminlogin_master, text="Password",font="papyrus").pack()
		self.password = Entry(self.adminlogin_master, show="*")
		self.password.pack()

		self.login_button = Button(self.adminlogin_master,font="papyrus", text="Login", command=self.login,width=7)
		self.login_button.pack()
		self.login_button.config(fg='black', bd=4) 

		self.login_button = Button(self.adminlogin_master,font="papyrus", text="Cancel", command=self.cancel)
		self.login_button.pack()
		self.login_button.config(fg='black', bd=4) 
		
		self.frame.pack()

		self.adminlogin_master.protocol("WM_DELETE_WINDOW",self.cancel)
		self.adminlogin_master.bind('<Return>', self.login)
		self.adminlogin_master.geometry('500x400')
示例#2
0
    def __init__(self, master, userdata):
        self.master = master
        self.testcase_master = Toplevel(master)
        self.testcase_master.protocol("WM_DELETE_WINDOW", self.mainwin)
        self.userdata = userdata

        self.db = MindClockDb(self.testcase_master)

        self.messages = McError()

        self.keypress = False

        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Reproduction", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        self.canvas1 = Canvas(self.testcase_master, width=350, height=300)
        self.canvas1.pack()
        self.canvas1.create_oval(200, 200, 70, 70, fill='#6666ff')
        self.canvas1.create_text(134,
                                 134,
                                 text="R",
                                 fill="white",
                                 font=("tahoma", 30))
        self.canvas1.after(3000, self.clear)

        self.canvas = Canvas(self.testcase_master, width=350, height=300)
        self.canvas.pack()
        self.testcase_master.bind("<space>", self.show_ball)
        self.testcase_master.geometry('500x400')
示例#3
0
    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()
示例#4
0
	def __init__(self,obj_master=None):
		self.db = sqlite3.connect("mindclock.db")
		self.cursor = self.db.cursor()
		self.cursor.row_factory = sqlite3.Row
		# create tables
		self.init_db()
		self.messages = McError()
		self.window = obj_master
示例#5
0
class AdminLogin():
	def __init__(self, master):
		self.master = master
		self.adminlogin_master = Toplevel(master)
		self.messages = McError()

		self.db=sqlite3.connect('mindclock.db')
		self.cursor=self.db.cursor()

		self.messages = McError()

		self.frame = Frame(self.adminlogin_master)
		self.username = Label(self.adminlogin_master, text="Username",font="papyrus").pack()
		self.username = Entry(self.adminlogin_master)
		self.username.pack()
		self.password = Label(self.adminlogin_master, text="Password",font="papyrus").pack()
		self.password = Entry(self.adminlogin_master, show="*")
		self.password.pack()

		self.login_button = Button(self.adminlogin_master,font="papyrus", text="Login", command=self.login,width=7)
		self.login_button.pack()
		self.login_button.config(fg='black', bd=4) 

		self.login_button = Button(self.adminlogin_master,font="papyrus", text="Cancel", command=self.cancel)
		self.login_button.pack()
		self.login_button.config(fg='black', bd=4) 
		
		self.frame.pack()

		self.adminlogin_master.protocol("WM_DELETE_WINDOW",self.cancel)
		self.adminlogin_master.bind('<Return>', self.login)
		self.adminlogin_master.geometry('500x400')
		
	def cancel(self):
		self.adminlogin_master.destroy()
		self.master.deiconify()

	def login(self,event=None):
		# match username and password
		find_user = ('SELECT username,password FROM admins WHERE username = ? and password = ?')
		self.cursor.execute(find_user,[(self.username.get()),(self.password.get())])
		result = self.cursor.fetchone()
		if result:
			self.adminlogin_master.destroy()
			# call dashboard window
			dashboard = Dash_board(self.master)
		else :
			self.adminlogin_master.destroy()
			self.messages.error("Error", "Something went wrong!")
			self.master.deiconify()
示例#6
0
    def __init__(self, master):
        self.master = master
        self.userlogin_master = Toplevel(master)
        self.userlogin_master.title("User")
        self.frame = Frame(self.userlogin_master)
        self.messages = McError()

        self.db = sqlite3.connect("mindclock.db")
        self.cursor = self.db.cursor()

        self.userlabel = Label(self.userlogin_master,
                               text="User ID",
                               font="papyrus")
        self.username = Entry(self.userlogin_master)

        self.userlabel.pack()
        self.username.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Start",
                                   command=self.login,
                                   width=7)
        self.login_button.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Register",
                                   command=self.signup,
                                   width=7)
        self.login_button.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Cancel",
                                   command=self.cancel,
                                   width=7)
        self.login_button.pack()

        self.frame.pack()

        self.userlogin_master.protocol("WM_DELETE_WINDOW", self.cancel)
        self.userlogin_master.bind('<Return>', self.login)
        self.userlogin_master.geometry('500x400')
示例#7
0
	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)
示例#8
0
    def __init__(self, master, userdata):

        # logged in userdata
        self.userdata = userdata
        self.productioncounter = 0
        self.replicationcounter = 1

        self.production_master = Toplevel(master)
        self.production_master.protocol("WM_DELETE_WINDOW", sys.exit)
        self.production_master.title("Production")
        self.production_master.focus_set()

        self.messages = McError()

        self.db = MindClockDb(self.production_master)
        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Production", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        # self.production_master.attributes('-fullscreen', True)
        self.init_production()
示例#9
0
class UserLogin(Toplevel):
    def __init__(self, master):
        self.master = master
        self.userlogin_master = Toplevel(master)
        self.userlogin_master.title("User")
        self.frame = Frame(self.userlogin_master)
        self.messages = McError()

        self.db = sqlite3.connect("mindclock.db")
        self.cursor = self.db.cursor()

        self.userlabel = Label(self.userlogin_master,
                               text="User ID",
                               font="papyrus")
        self.username = Entry(self.userlogin_master)

        self.userlabel.pack()
        self.username.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Start",
                                   command=self.login,
                                   width=7)
        self.login_button.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Register",
                                   command=self.signup,
                                   width=7)
        self.login_button.pack()

        self.login_button = Button(self.userlogin_master,
                                   font="papyrus",
                                   text="Cancel",
                                   command=self.cancel,
                                   width=7)
        self.login_button.pack()

        self.frame.pack()

        self.userlogin_master.protocol("WM_DELETE_WINDOW", self.cancel)
        self.userlogin_master.bind('<Return>', self.login)
        self.userlogin_master.geometry('500x400')

    def cancel(self):
        self.userlogin_master.destroy()
        self.master.deiconify()

    def signup(self):
        self.userlogin_master.withdraw()
        self.signup = signupFrame(self.userlogin_master)

    def login(self, event=None):

        find_user = ('SELECT userid FROM users WHERE userid = ?')
        self.cursor.execute(find_user, [self.username.get()])
        value = self.username.get()
        result = self.cursor.fetchone()

        if result:
            self.userlogin_master.destroy()
            # call dashboard window
            #window = Production(self.master, x1=100, y1=100)
            self.userlogin_master = TestWindow(self.master, params=value)
        elif result != value and value != "":
            self.userlogin_master.withdraw()
            self.messages.error("Error", "Invalid User ID")
            self.username.delete(0, 'end')
            self.userlogin_master.deiconify()
        else:
            self.userlogin_master.withdraw()
            self.messages.error("Error", "Fields cannot be empty")
            self.userlogin_master.deiconify()
示例#10
0
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()
示例#11
0
class Reproduction():
    def __init__(self, master, userdata):
        self.master = master
        self.testcase_master = Toplevel(master)
        self.testcase_master.protocol("WM_DELETE_WINDOW", self.mainwin)
        self.userdata = userdata

        self.db = MindClockDb(self.testcase_master)

        self.messages = McError()

        self.keypress = False

        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Reproduction", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        self.canvas1 = Canvas(self.testcase_master, width=350, height=300)
        self.canvas1.pack()
        self.canvas1.create_oval(200, 200, 70, 70, fill='#6666ff')
        self.canvas1.create_text(134,
                                 134,
                                 text="R",
                                 fill="white",
                                 font=("tahoma", 30))
        self.canvas1.after(3000, self.clear)

        self.canvas = Canvas(self.testcase_master, width=350, height=300)
        self.canvas.pack()
        self.testcase_master.bind("<space>", self.show_ball)
        self.testcase_master.geometry('500x400')
        #self.now1 = datetime.datetime.now()

    def mainwin(self):
        self.master.deiconify()
        self.testcase_master.destroy()

    def show_ball(self, event=None):
        #self.start=float(self.now1.isoformat())
        if (self.keypress == False):
            self.start = time.time()
            self.keypress = True
        else:
            self.canvas.create_oval(200, 200, 70, 70, fill='#6666ff')
            self.canvas.create_text(134,
                                    134,
                                    text="R",
                                    fill="white",
                                    font=("tahoma", 30))
            self.canvas.pack()

        self.testcase_master.bind("<KeyRelease>", self.hide_ball)
        #self.now2 = datetime.datetime.now()

    def hide_ball(self, event=None):
        self.canvas.delete(ALL)
        #self.end=float(self.now2.isoformat())
        self.keypress = False
        self.end = time.time()
        print("start time", self.start)
        print("end time", self.end)
        self.getdiff = self.end - self.start
        print("Difference", self.getdiff)
        sql = "INSERT INTO operations(user_id, replicate, production_time, reproduction_time, result_time, type) VALUES('{}','{}','{}','{}','{}','{}')".format(
            self.userdata, 1, None, 3, self.getdiff, "Reproduction")

        if (self.db.insert(sql) == False):
            self.messages.error("Error", "Something went wrong!")

    def clear(self):
        self.canvas1.destroy()
示例#12
0
class Production:
    def __init__(self, master, userdata):

        # logged in userdata
        self.userdata = userdata
        self.productioncounter = 0
        self.replicationcounter = 1

        self.production_master = Toplevel(master)
        self.production_master.protocol("WM_DELETE_WINDOW", sys.exit)
        self.production_master.title("Production")
        self.production_master.focus_set()

        self.messages = McError()

        self.db = MindClockDb(self.production_master)
        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Production", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        # self.production_master.attributes('-fullscreen', True)
        self.init_production()

    def init_production(self):
        set = {'font': 'Times 70 bold'}
        self.get_production_intervals()

        self.production_timer = Label(self.production_master,
                                      text=self.time[self.productioncounter],
                                      **set)
        self.production_timer.pack(padx=200, pady=320)
        self.time1 = time.time()
        self.production_master.bind('<space>', self.get_production_event)

    def get_production_intervals(self):
        # self.time = []
        # self.event = []
        # self.data = self.db.select("SELECT ")
        data = self.db.select(
            "SELECT id, intervals, replicate, type FROM test_types WHERE type='Production'"
        )
        data = data.fetchone()
        intervals = dict(data)
        self.time = intervals['intervals'].split('-')
        self.replicate = intervals['replicate']

    def get_production_event(self, event):
        time.sleep(1)

        self.time1 = time.time() - self.time1
        print(self.time1)

        sql = "INSERT INTO operations(user_id, replicate, production_time, reproduction_time, result_time, type) VALUES('{}','{}','{}','{}','{}','{}')".format(
            self.userdata, self.replicationcounter,
            self.time[self.productioncounter], None, self.time1, "Production")

        if (self.db.insert(sql) == False):
            self.messages.error("Error", "Something went wrong!")

        self.time1 = time.time()

        self.productioncounter += 1
        print(self.replicationcounter)
        # check replication is
        if self.replicationcounter > self.replicate:
            sys.exit()

        # change text on key press
        try:
            self.production_timer.config(
                text=self.time[self.productioncounter])
        except IndexError as e:
            self.replicationcounter += 1
            self.productioncounter = 0
示例#13
0
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)
示例#14
0
class MindClockDb:
	def __init__(self,obj_master=None):
		self.db = sqlite3.connect("mindclock.db")
		self.cursor = self.db.cursor()
		self.cursor.row_factory = sqlite3.Row
		# create tables
		self.init_db()
		self.messages = McError()
		self.window = obj_master

	# init database structure
	def init_db(self):

		self.create_table("CREATE TABLE IF NOT EXISTS admins( id INTEGER PRIMARY KEY AUTOINCREMENT , username TEXT UNIQUE, password TEXT )")
		self.insert("INSERT OR IGNORE INTO admins(username, password) VALUES('admin','admin')")
		self.create_table("CREATE TABLE IF NOT EXISTS users( id INTEGER PRIMARY KEY AUTOINCREMENT , firstname TEXT  , lastname TEXT , age int , weight TEXT , height TEXT , gender TEXT , userid TEXT , bmi TEXT)")
		self.create_table("CREATE TABLE IF NOT EXISTS test_types( id INTEGER  PRIMARY KEY AUTOINCREMENT , intervals TEXT , replicate int , type TEXT)")
		# self.insert("INSERT OR IGNORE INTO test_types(intervals,replicate, type) VALUES('3-4-5-6',2, 'P')")
		# self.insert("INSERT OR IGNORE INTO test_types(intervals,replicate, type) VALUES('3-4-5-6',2, 'R')")
		self.create_table("CREATE TABLE IF NOT EXISTS operations( id INTEGER PRIMARY KEY AUTOINCREMENT , user_id int , replicate int , production_time real , reproduction_time real , result_time real , type char )")

		# self.create_admin()

	def create_table(self, sql):
		self.cursor.execute(sql)
	# Read
	def select(self, sql):
		try:
			return self.cursor.execute(sql)
		except sqlite3.OperationalError as e:
			print(e)

	def single_record(self):
		return self.cursor.fetchone()

	# Insert into table
	def insert(self, sql):
		try:
			self.cursor.execute(sql)
			self.db.commit()
			return True
		except sqlite3.IntegrityError: 
			self.window.withdraw()
			#message box showing the error
			self.messages.error("Error","Values already exist")
			self.window.deiconify()

		except sqlite3.OperationalError as e:
			print(e)

	def update(self, sql):

		try:
			self.cursor.execute(sql)
			self.db.commit()
			return True
		except sqlite3.OperationalError as e:
			print(e)

	def delete(self, sql):
		try:
			self.cursor.execute(sql)
			self.db.commit()
			return True
		except sqlite3.OperationalError as e:
			print(e)


	def __del__(self):
		self.cursor.close()
		self.db.close()
示例#15
0
    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)
示例#16
0
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()