def generate(self): #nút thực hiện global front_addr,back_addr if front_addr=='' or back_addr=='': #kiểm tra có chèn ảnh hay chưa QMessageBox.about(self, "Couldn't generate", "Image is not inserted!") else: form.form("temp_front.jpg","temp_back.jpg") #gọi hàm from print("done")
def generate(self): global front_addr, back_addr if front_addr == '' or back_addr == '': QMessageBox.about(self, "Couldn't generate", "Image is not inserted!") else: form.form("temp_front.jpg", "temp_back.jpg") print("done")
def initialise(self, node_token): node_data = node_token.get_node_data() table = node_data.get('table', '') table = table.encode('ascii') # This seems to be needed but I'm not sure why # but without it the listings are incorrect. # TODO investigate a little self.table = table rtable = r[table] self.extra_data = {'table':table} title_field = rtable.title_field fields = [] for field in rtable.ordered_fields: if field.category <> "field": continue extra_info = {} if field.description: extra_info['description'] = field.description if field.type == "Text" and field.length > 500: fields.append(textarea(field.name, css = "large", **extra_info)) else: fields.append(input(field.name, **extra_info)) main = form(*fields, table = table, form_type = 'input', volatile = True) # add this to the available forms self._available_forms['main'] = main
def __init__(self, node_name = None): super(AutoForm, self).__init__(node_name) rtable = r[self.table] self.extra_data = {'table':self.table} title_field = rtable.title_field fields = [] for field in rtable.ordered_fields: if field.category <> "field": continue extra_info = {} if field.description: extra_info['description'] = field.description if field.type == "Text" and field.length > 500: fields.append(textarea(field.name, css = "large", **extra_info)) else: fields.append(input(field.name, **extra_info)) main = form(*fields, table = self.table, volatile = True) # add this to the available forms self._available_forms['main'] = main self._non_result_forms['main'] = main
def get(self, the_key): user = access.wall(self) if user: if (user.nickname() in settings.admins): import form record = datastore.Get(the_key) self.response.out.write(form.form(record)) else: self.redirect('/')
def capture(n): cap = cv2.VideoCapture(0) print(bot.format('ENTER \"q\" TO CAPTURE AND SAVE')) speech.speech('ENTER \"q\" TO CAPTURE AND SAVE') while True: return_value, image = cap.read() gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('image', gray) if cv2.waitKey(1) & 0xFF == ord('q'): cv2.imwrite('pic_' + n + '.jpg', image) break cap.release() cv2.destroyAllWindows() imgplot = plt.imshow(mpimg.imread('pic_' + n + '.jpg')) plt.show() print(bot.format('PHOTO SAVED SUCCESSFULLY...........')) speech.speech('PHOTO SAVED SUCCESSFULLY...........') form.form(n)
def handlePost(self,request): room = request.args['room'][0] try: status = request.args['status'][0] except: status = 0 if room in curEvent.roomList: tmessage=request.args['tmessage'][0] request.write(form.form(curEvent.schoolName, curEvent.roomList, status=status, current_room=room)) for client in XMLSocket.clients: client.sendStatus(room, status, tmessage) else: request.write(form.roomNotFound) try: tmessage = request.args['tmessage'][0] except: tmessage = '' curEvent.roomStatus.append((room,status,tmessage, time.time()))
def record_form(self, record): """Create a HTML form for this record""" pos = record.find("/") add = False if pos <= 0 or pos == len(record) - 1: if pos > 0: record = record[:pos] if record not in self.records: return '<h1>Unknown record "' + record + '"</h1>' rec = self.records[record](self.general) add = True else: table = record[:pos] key = record[pos + 1:] if table not in self.records: return '<h1>Unknown record "' + table + '"</h1>' records = getattr(self.general, self.records[table].path) if key not in records: return '<h1>Unknown ' + table + ' "' + key + '"</h1>' rec = records[key] return form.form(rec, ("Add " if add else "Edit ") + rec.get_name())
def create(self, view_ids, model, res_id=False, domain=None, view_type='form', window=None, context=None, mode=None, name=False,help={}, limit=100, auto_refresh=False, auto_search=True, search_view=None): if context is None: context = {} context.update(rpc.session.context) if view_type=='form': mode = (mode or 'form,tree').split(',') win = form.form(model, res_id, domain, view_type=mode, view_ids = (view_ids or []), window=window, context=context, name=name, help=help, limit=limit, auto_refresh=auto_refresh, auto_search=auto_search, search_view=search_view) spool = service.LocalService('spool') spool.publish('gui.window', win, {}) if res_id: win.screen.set_tooltips() elif view_type=='tree': if view_ids and view_ids[0]: view_base = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.ui.view', 'read', [view_ids[0]], ['model', 'type'], context)[0] model = view_base['model'] view = rpc.session.rpc_exec_auth('/object', 'execute', view_base['model'], 'fields_view_get', view_ids[0], view_base['type'],context) else: view = rpc.session.rpc_exec_auth('/object', 'execute', model, 'fields_view_get', False, view_type, context) win = tree.tree(view, model, res_id, domain, context,help=help, window=window, name=name) spool = service.LocalService('spool') spool.publish('gui.window', win, {}) else: import logging log = logging.getLogger('view') log.error('unknown view type: '+view_type) del log
def create(self, view_ids, model, res_id=False, domain=None, view_type='form', window=None, context=None, mode=None, name=False,help={}, limit=100, auto_refresh=False, auto_search=True, search_view=None): if context is None: context = {} context.update(rpc.session.context) if view_type=='form': mode = (mode or 'form,tree').split(',') win = form.form(model, res_id, domain, view_type=mode, view_ids = (view_ids or []), window=window, context=context, name=name, help=help, limit=limit, auto_refresh=auto_refresh, auto_search=auto_search, search_view=search_view) spool = service.LocalService('spool') spool.publish('gui.window', win, {}) elif view_type=='tree': if view_ids and view_ids[0]: view_base = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.ui.view', 'read', [view_ids[0]], ['model', 'type'], context)[0] model = view_base['model'] view = rpc.session.rpc_exec_auth('/object', 'execute', view_base['model'], 'fields_view_get', view_ids[0], view_base['type'],context) else: view = rpc.session.rpc_exec_auth('/object', 'execute', model, 'fields_view_get', False, view_type, context) win = tree.tree(view, model, res_id, domain, context,help=help, window=window, name=name) spool = service.LocalService('spool') spool.publish('gui.window', win, {}) else: import logging log = logging.getLogger('view') log.error('unknown view type: '+view_type) del log
def display(userID, formID): f = form(userID, formID) return
def renderHome(self,request): request.write(form.form(curEvent.schoolName, curEvent.roomList, status="1"))
mySocket.listen(5) # Accept connections, read incoming data, and call # parse and process methods (in a loop) while True: print('Waiting for connections') (recvSocket, address) = mySocket.accept() print('HTTP request received (going to parse and process):') request = recvSocket.recv(2048).decode('utf-8') print(request) (theApp, rest) = self.select(request) (method, parsedRequest) = theApp.parse(request) (returnCode, htmlAnswer) = theApp.process(parsedRequest, method, rest) print('Answering back...') recvSocket.send( bytes( "HTTP/1.1 " + returnCode + " \r\n\r\n" + htmlAnswer + "\r\n", 'utf-8')) recvSocket.close() if __name__ == "__main__": form = form.form() redirect = redirect.redirect() testWebApp = webApp("localhost", 1234, { 'root': form, 'redirect': redirect })
def __init__(self): title.title() form.form() instruction.instruction()
def create(userID, formID): done = False f = form(userID, formID) while(not done): qChoice, question, answer, choice, order = 0, None, None, None, None while(qChoice not in range(1, len(questionTypes)+2)): print("\nSelect a question type to create (Enter Anything Else to Quit): ") for i in range(1, len(questionTypes)+1): print(str(i)+". "+str(questionTypes[i-1])) print('7. Quit') try: qChoice = int(input()) except: qChoice = 7 if(qChoice in {1,2}): question = input(questionTypes[qChoice-1]+" Question: ") if(f.isTest and choice == 1): answer = input(questionTypes[qChoice-1]+" Answer: ") elif(qChoice == 3): question = input(questionTypes[qChoice-1]+" Question: ") if(f.isTest): answer = bool(input(questionTypes[qChoice-1]+" Answer: ")) elif(qChoice == 4): doneChoice, count, choice = False, 1, [] while(not doneChoice): choice.append(input(questionTypes[qChoice-1]+" Choice #"+str(count)+" (Input DONE when finished): ")) if(choice[count-1].upper() == "DONE"): doneChoice = True del choice[-1] else: count += 1 if(f.isTest): answerChoice = False while(not answerChoice): for i in range(1, len(choice)+1): print(str(i)+". "+str(choice[i-1])) aChoice = int(input("Select correct Answer: ")) if(aChoice in range(1, len(choice)+1)): answer = choice[aChoice-1] answerChoice = True elif(qChoice == 5): doneMatch, count, t1, t2 = False, 1, [], [] print("Input Matchers first, then Matchees") while(not doneMatch): t1.append(input(questionTypes[qChoice-1]+" Matcher #"+str(count)+" (Input DONE when finished): ")) if(t1[count-1].upper() == "DONE"): doneMatch = True del t1[-1] else: count += 1 for i in range(0, len(t1)): if(f.isTest): t2.append(input(questionTypes[qChoice-1]+" Matchee #"+str(count)+" for "+t1[i]+": ")) else: t2.append(input(questionTypes[qChoice-1]+" Matchee #"+str(count)+": ")) if(f.isTest): answer = tuple(tuple(t1), tuple(t2)) order = tuple(tuple(shuffle(t1)), tuple(shuffle(t2))) elif(qChoice == 6): doneRank, count, r = False, 1, [] while(not doneRank): if(f.isTest): r.append(input(questionTypes[qChoice-1]+" Rank #"+str(count)+" (Input DONE when finished): ")) else: r.append(input(questionTypes[qChoice-1]+" Rankee #"+str(count)+" (Input DONE when finished): ")) if(r[count-1].upper() == "DONE"): doneRank = True del r[-1] else: count += 1 if(f.isTest): answer = tuple(r) order = tuple(shuffle(r)) else: done = True if(not done): qID = f.addQuestion(questionTypes[qChoice-1], question, choice, order) if(f.isTest): f.addAnswer(qID, answer, order) display(userID, f.formID)
def input_new_url_form(self): self.app.new_url_form = form(self.app)
def GET(self) : # Get images in imagefolder imgdir = cycleFolder() distractordir = "images/distractors" MARK_DISTRACTORS = True # Set up web page form survey_form = form.form() survey_form.question("age", [('0to10','Under 10 years old'),('10to20','Between 10 and 19'),('20to30','Between 20 and 29'), ('30to40','Between 30 and 39'), ('over40', 'Over 40')], "How old are you?") survey_form.question("gender", [('male','Male'),('female','Female'),('other', 'Other')], "What is your gender?") survey_form.question("nb_devices", [(0,'None'),(1,'One'),(2,'More than one')], "How many cameras do you own?") survey_form.question("smartphone_p", [('yes','Yes'),('no','No')], "Do you own a smart-phone?") survey_form.question("nb_years", [("0to5","Less than 5 years ago"),("5to10",'Between 5 and 10 years'),("10plus", "More than 10 years ago"),("NA","I don't have a camera")], "How many years approximately is it since you had your first digital camera?") survey_form.question("nb_images_day", [("0to20","Less than 20"),("20to100",'Between 20 and 100 photos'), ("over100", "More than 100")], "How many images approximately do you take on average every month?") survey_form.question("nb_images_library", [("0to1000","Less than 1000"),("1000to5000",'Between 1000 and 5000 photos'),("over5000",'Over 5000 photos')], "How many images approximately does your photo library have?") survey_form.question("verify", [('yes', 'Yes'),('no', 'No')], "Did you provide false answers in the previous questions?") # Set up page text sections = page_object() sections.page_title = "Slideshow Survey" sections.keys = ["intro1", "intro2", "intro3", "step1", "step2", "done"] # Title for each step sections.title = { "intro1" : "Slideshow Survey", "intro2" : "Description of the task", "intro3" : "Personal questions", "step1" : "Step1: Select photos", "step2" : "Step2: Sequence photos", "done" : "Finished", } def step1_select() : d = "unassigned" print(imgdir) if imgdir == "images/baby" : d = """This is Josh. You want to make a slideshow about him. Imagine that he is your son/younger brother etc. Select any images that you would like to include in the slideshow by clicking on them (a red border will appear). There is no restriction on the number of images that you can select. Then explain in the textbox why you selected these particular images.""" elif imgdir == "images/girl" : d = """This is Jess. You want to make a slideshow about her. Imagine that she is your daughter/sister etc. Select any images that you would like to include in the slideshow by clicking on them (a red border will appear). There is no restriction on the number of images that you can select. Then explain in the textbox why you selected these particular images.""" elif imgdir == "images/female" : d = """This is Jill. You want to make a slideshow about her. Imagine that she is your best friend/girlfriend/ sister/daughter etc. Select any images that you would like to include in the slideshow by clicking on them (a red border will appear). There is no restriction on the number of images that you can select. Then explain in the textbox why you selected these particular images.""" elif imgdir == "images/male" : d = """This is Jack. You want to make a slideshow about him. Imagine that he is your best friend/boyfriend/ brother/son etc. Select any images that you would like to include in the slideshow by clicking on them (a red border will appear). There is no restriction on the number of images that you can select. Then explain in the textbox why you selected these particular images.""" elif imgdir == "images/couple" : d = """This is Jack and Jill. You want to make a slideshow about them. Imagine that they are your best friends. Select any images that you would like to include in the slideshow by clicking on them. Selected images will have a red border around them (a red border will appear). There is no restriction on the number of images that you can select. Then explain in the textbox why you selected these particular images.""" print(d) return d # Description for each step sections.desc = { "intro1" : """<p>Welcome to ADSC's slideshow creation survey! This is an experiment conducted by the PhotoWork group.</p> <p>You will be shown 60 photos of a person and you will be asked to create a slideshow about him/her. You will have to select any number of photos that you like and you will have to arrange them into a slideshow, about this particular person.<br/><br/> We expect you to spend 10 to 15 minutes for this task. If the quality of your work is adequate, you will be awarded 0.2$ from the Microworkers crowdsourcing platform. If you are really committed and the quality of your work is very good, you will get a BONUS of 0.2$ (total 0.4$).</p> <p>Click NEXT for a thorough description of the task.</p>""", "intro2" : """<img src="/static/description.jpg" />""", "intro3" : """<p>Before you will continue to the test, we would like to know some more things about you, which is necessary for our survey. Please take some time to answer the following questions (it's totally anonymous).</p>""", "step1" : "<p>%s</p><img src='/static/%s.jpg' />" % (step1_select(), imgdir), "step2" : """<p><span class='underline'>This is the most important part of the work!</span><br/><br/>These are the images that you have selected in Step1. <span class='underline'>Drag the photos and arrange them into a sequence</span> (slideshow) that you think is good for describing the person depicted. Then explain in the textbox why you selected this particular sequence of photos.<br/><br/> We expect you to spend 5 minutes in this task. <br/><br/><span class='underline'>The quality of your work in this stage will determine your paiment and your bonus! All results will be individually analysed. Good quality of work and committeed workers will get a bonus of up to 0.2$ (total 0.4$).</span></p>""", "done" : """<p>Thank you for your participation in our slideshow survey!</p>""", } # Collect images reals = [("/static/%s/%s" % (imgdir, i), "/static/%s/large/%s" % (imgdir, i), "real") for i in os.listdir("static/%s/" % imgdir) if i[-4:].lower() == ".jpg"] distract_class = "distract" if MARK_DISTRACTORS == True else "real" distractors = [("/static/%s/%s" % (distractordir, i), "/static/%s/large/%s" % (distractordir, i), distract_class) for i in os.listdir("static/%s/" % distractordir) if i[-4:].lower() == ".jpg"] imgs = reals + distractors # Shuffle images to avoid bias random.shuffle(imgs) return self.render.survey(imgs, sections, survey_form)
global cap cameraLocation = '/dev/video0' #cameraLocation = 'rtsp://192.168.1.103/live1.sdp' cap = cv2.VideoCapture(0) #cap = cv2.VideoCapture(cameraLocation) # Variables text_info = 'Test of subtitle' def text_box(): global text_info while (True): test = easygui.enterbox(text_info, "Title", "Score 1 - 10") t1 = form() #t1 = threading.Thread(target=text_box, args=[]) t1.start() while (True): # Capture frame-by-frame ret, frame = cap.read() # Our operations on the frame come here gray = frame # cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Write text font = cv2.FONT_HERSHEY_COMPLEX cv2.putText(gray, t1.getText(), (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH) / 4), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT) - 30)), font, 1,
import tkinter as tk import time from form import form from arrays import arrays XSIZE = 5 YSIZE = 5 app = form(master=tk.Tk(), xsize=XSIZE, ysize=YSIZE) ar = arrays(XSIZE, YSIZE) ar.now.loc[1:3, 2] = 1 app.draw_enviroment() while True: time.sleep(.01) ar.do_tick() app.update_enviroment(ar.now)