def mainthing(button): global w1, w2, w3, d1, d2, d3 global type_file global name if type_file == 0: name = app.getEntry("File Name:") if type_file == 1: global name prename = app.getOptionBox( "File Name") #prename grabs everything including .csv name = prename[:-4] #this removes just .csv readfile() if button == "Plate": w1 = float(getdata()) if button == "Beginning": w2 = float(getdata()) if button == "Ending": w3 = float(getdata()) if button == "Porosity": por = "Porosity: " + str(porosity()) app.addLabel("output", por, colspan=3) if button == "Save & Quit": writefile() app.stop() type_file = 2 #won't read in file again return
def getscale(): while True: try: x = float(getdata()) return x except: x = 0 pass
def getsample(button): app.removeButton("Weigh") app.removeLabel("zero_w") tmp = float(getdata()) #"12.3752" app.addLabel("total_w", str(tmp) + " grams", colspan=2) #print "getting sample" app.addLabel("msg1", "Press 'Start' when you are ready to collect data.", colspan=2) app.addLabel("msg2", "Process will take 3 hours.", colspan=2) app.addButton("Start", gatherdata, colspan=2)
def getsample(button): app.removeButton("Weigh") app.removeLabel("zero_w") tmp = float(getdata()) #"12.3752" app.addLabel("total_w", str(tmp) + " grams", colspan=2) #print "getting sample" cap = cv2.VideoCapture(0) while (True): ret, frame = cap.read() # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Display the resulting frame cv2.imshow('frame', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything done, release the capture cap.release() cap1 = cv2.VideoCapture(1) while (True): ret1, frame1 = cap1.read() # Our operations on the frame come here gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY) # Display the resulting frame cv2.imshow('frame', frame1) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything done, release the capture cap1.release() cv2.destroyAllWindows() r = app.getRow() app.addLabel("prompt1", "Time limit (hours):", r, 0) app.addNumericEntry("Time_Limit", r, 1) r1 = app.getRow() app.addLabel("prompt2", "1 Picture every __ seconds:", r1, 0) app.addNumericEntry("S/S", r1, 1) app.addLabel("msg1", "Press 'Start' when you are ready to collect data.", colspan=2) app.addButton("Start", gatherdata, colspan=2)
def get_one_sample(): w1 = float(getdata()) d1 = input("Enter distance through laser:", ) return w1, d1
#save the data name = app.getEntry("File Name:") with open('data/Scale/'+name+'.csv', 'wb') as output: writer = csv.writer(output,delimiter=',') writer.writerow(["TIME","WEIGHT","POROSITY","WEIGHTCRIT","DISTANCE","POROSITYFINAL"]) for x in range(0,len(t)): writer.writerow([str(t[x]), str(numvec[x]), str(numvec2[x])]) #print success message app.addLabel("success","SUCCESS!",colspan=2) ##################################################### def weigh(button) global w1,w2,w3 if button=="Weigh Plate": w1=float(getdata()) if button=="Start Measurements": w2=float(getdata()) gatherdata("Start") ##################################################### def firstpress(button): global name global type_file if button =="Quit": app.stop if button=="New File": row=app.getRow() app.addLabelEntry("File Name:",row,0,colspan=2) app.addLabel(".csv",".csv",row,2) type_file=0