def from_dict(job_dict): job_dict.setdefault("connector", []) job_dict["connector"] = [Form.from_dict(con_form_dict) for con_form_dict in job_dict["connector"]] job_dict.setdefault("framework", []) job_dict["framework"] = [Form.from_dict(framework_form_dict) for framework_form_dict in job_dict["framework"]] if not "connection_id" in job_dict: job_dict["connection_id"] = job_dict["connection-id"] if not "connector_id" in job_dict: job_dict["connector_id"] = job_dict["connector-id"] if not "creation_user" in job_dict: job_dict["creation_user"] = job_dict.setdefault("creation-user", "hue") if not "creation_date" in job_dict: job_dict["creation_date"] = job_dict.setdefault("creation-date", 0) if not "update_user" in job_dict: job_dict["update_user"] = job_dict.setdefault("update-user", "hue") if not "update_date" in job_dict: job_dict["update_date"] = job_dict.setdefault("update-date", 0) return Job(**force_dict_to_strings(job_dict))
def __init__(self): self.lock = Lock() text = '' self.root = Tk() root = self.root #root.title('Youtube Downloader by Shkirmantsev') root.title(self.title) labels = [ 'video_url for download:', 'quality_mode or press enter', 'Saving_directory', 'Saving_file_name', 'video_file_to_convert' ] Form.__init__(self, labels, parent=root) self.mutex = _thread.allocate_lock() threadsv = Value('i', 0) self.threads = threadsv.value #print("self content on start: ",self.content) self.content['quality_mode or press enter'].delete(0, END) self.content['quality_mode or press enter'].insert(0, 1) #print("content is: ", self.content) # import functions for items in main_array: exec("from {0} import {1} as {1}".format(items[1], items[0])) #assert "." not in items[0], "Houston we've got a problem with hakers" if ("import" in items[0]) or ("." in items[0]): raise Exception("Houston we've got a problem with hakers") func = eval("{0}".format(items[0])) setattr(FtpForm, "{0}".format(items[0]), func) root.mainloop()
def from_dict(connection_dict): connection_dict.setdefault('connector', []) connection_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in connection_dict['connector'] ] connection_dict.setdefault('framework', []) connection_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in connection_dict['framework'] ] if not 'connector_id' in connection_dict: connection_dict['connector_id'] = connection_dict.setdefault( 'connector-id', -1) if not 'creation_user' in connection_dict: connection_dict['creation_user'] = connection_dict.setdefault( 'creation-user', 'hue') if not 'creation_date' in connection_dict: connection_dict['creation_date'] = connection_dict.setdefault( 'creation-date', 0) if not 'update_user' in connection_dict: connection_dict['update_user'] = connection_dict.setdefault( 'update-user', 'hue') if not 'update_date' in connection_dict: connection_dict['update_date'] = connection_dict.setdefault( 'update-date', 0) return Connection(**connection_dict)
def submit(): print("submit") form = None if request.method == 'POST': form = Form(request.form) if (len(form.errors) == 0): port_availability = validator.check_port_availability(form.ports) if (False not in port_availability): try: validator.send_email(form.snum, form.ports, form.password) form.success = True form.success_msg = 'The selected ports %s and %s were available! Email sent to [email protected].' % ( form.ports[0], form.ports[1]) except Exception as e: print(e) form.errors.append("Email Authentication Unsuccessful.") else: invalid = list( itertools.compress(form.ports, [not i for i in port_availability])) if (len(invalid) == 1): out = "Port %s is not available" % invalid[0] else: out = "Ports %s are not available." % ', '.join( str(i) for i in form.ports) form.errors.append(out) # Prepare response response = make_response(render_template('index.html', form=form)) return response
def from_dict(job_dict): job_dict.setdefault('connector', []) job_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in job_dict['connector'] ] job_dict.setdefault('framework', []) job_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in job_dict['framework'] ] if not 'connection_id' in job_dict: job_dict['connection_id'] = job_dict['connection-id'] if not 'connector_id' in job_dict: job_dict['connector_id'] = job_dict['connector-id'] if not 'creation_user' in job_dict: job_dict['creation_user'] = job_dict.setdefault('creation-user', 'hue') if not 'creation_date' in job_dict: job_dict['creation_date'] = job_dict.setdefault('creation-date', 0) if not 'update_user' in job_dict: job_dict['update_user'] = job_dict.setdefault('update-user', 'hue') if not 'update_date' in job_dict: job_dict['update_date'] = job_dict.setdefault('update-date', 0) return Job(**job_dict)
def from_dict(job_dict): job_dict.setdefault('connector', []) job_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in job_dict['connector'] ] job_dict.setdefault('framework', []) job_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in job_dict['framework'] ] if not 'connection_id' in job_dict: job_dict['connection_id'] = job_dict['connection-id'] if not 'connector_id' in job_dict: job_dict['connector_id'] = job_dict['connector-id'] if not 'creation_user' in job_dict: job_dict['creation_user'] = job_dict.setdefault( 'creation-user', 'hue') if not 'creation_date' in job_dict: job_dict['creation_date'] = job_dict.setdefault('creation-date', 0) if not 'update_user' in job_dict: job_dict['update_user'] = job_dict.setdefault('update-user', 'hue') if not 'update_date' in job_dict: job_dict['update_date'] = job_dict.setdefault('update-date', 0) return Job(**job_dict)
def __init__(self): root = Tk() root.title(self.title) labels = ['Server Name', 'Remote Dir', 'File Name', 'Local Dir', 'User Name?', 'Password?'] Form.__init__(self, labels, root) self.mutex = _thread.allocate_lock() self.threads = 0
def _newForm(self): self.ui.add_btn.setDisabled(True) self.ui.sport_combo.setDisabled(True) self.leaguesReq(self.selected_sport) self.form = Form() self.ui.formWidgetLayout.addWidget(self.form) self.form.formClosed.connect(self._closeForm) self.repaint()
def create_form(answered_questions: Iterable[Question]) -> Form: """ A single Form stores single Passenger answers. """ form = Form() form.add_answers( (Answer(question, True) for question in answered_questions)) return form
def cool(): global f messagebox.show('hello world') f1 = Form(caption="New Form", left=320, top=200) btn1 = Button(f1, caption='Hello', left=5, top=5, width=200, height=100) btn1.on_click = cool2 btn1.background = 'blue' f1.show_modal() print "I'm a cool app"
def get_applicant(): form = Form(request.form) check = form.check() if check == True: Applicant.check_app_code() Applicant.check_for_school() return redirect(config.address+'/') else: return check + "\n\n Please go back to the form"
def get_applicant(): form = Form(request.form) check = form.check() if check == True: Applicant.check_app_code() Applicant.check_for_school() return redirect(config.address + '/') else: return check + "\n\n Please go back to the form"
def _form(self): if self.__form_cache is not None: return self.__form_cache inputs = map(lambda x: x.field, self.get_active_fields()) # TODO: creating the form everytime might by a wrong approach... logger.debug("Creating Form()...") form = Form(*inputs) form.fill(self.data) self.__form_cache = form return form
def hello_world(): form = Form() if form.validate_on_submit(): session['result'] = get_disease(form.symptom.data) return redirect('/') return render_template('base.html', title='基于随机森林的医疗初诊系统', form=form, result=session.get('result'))
def loadForms(self, src): mi = loadImage(src) start_pos = [] start_c = [] forms = [] #start_c = color(0) #start_p = PVector(0,0) for x in range(mi.width): for y in range(mi.height): if not (mi.get(x, y) == color(0) or mi.get(x, y) == color(255)): start_pos.append(PVector(x, y)) start_c.append(mi.get(x, y)) for k in range(len(start_pos)): tiles = [] self.floodFill(mi, tiles, floor(start_pos[k].x), floor(start_pos[k].y), start_c[k]) form = Form( tiles, PVector( 575 + random(-50, 25), height / 2 + height / (len(start_pos) + 3) * (k - len(start_pos) / 2))) if start_c[k] == color(255, 0, 0): form.setStateAll(1) if start_c[k] == color(0, 255, 0): form.setStateAll(2) if start_c[k] == color(0, 0, 255): form.setStateAll(3) form.angle = floor(random(4) + 1) * HALF_PI forms.append(form) return forms
def new_record(self, event): """Insert new record. Get values by presenting an empty form""" # does user want to fill with template ? template_name = None # show template chooser only if there are some templates if len(self.tpl_files) > 0: template_chooser = TemplateChooser(None, self.project_dir, self.tpl_files) if template_chooser.ShowModal() == wx.ID_CANCEL: return elif template_chooser.ShowModal() == wx.ID_OK: template_name = template_chooser.chosentemplate template_chooser.Destroy() if template_name == None: form = Form(None, self.fields_file, 'Fill in the values') else: template_vals = yaml.load(open(template_name)) form = Form(None, self.fields_file, 'Fill in the values', template_vals) if form.ShowModal() == wx.ID_OK: form.get_values() # Initialise lock as open form.vals['LOCK_STATUS'] = 'unlocked' self.records.insert_record(form.vals) # recreate index #self.register.index_summary = self.records.create_index() self.register.refresh_records() form.Destroy()
def create(model, **attributes): from tryton.gui import Main if model: from form import Form win = Form(model, **attributes) else: from board import Board win = Board(model, **attributes) win.icon = attributes.get('icon') Main.get_main().win_add(win, hide_current=Window.hide_current, allow_similar=Window.allow_similar)
def from_dict(connection_dict): connection_dict.setdefault('connector', []) connection_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in connection_dict['connector'] ] connection_dict.setdefault('framework', []) connection_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in connection_dict['framework'] ] if not 'connector_id' in connection_dict: connection_dict['connector_id'] = connection_dict.setdefault('connector-id', -1) return Connection(**connection_dict)
def saveForm(self, submit, message=None, success=True): """ Method to save the details @param message: the success message to check (optional) @param success: whether we're looking for a confirmation (default) or failure """ self.startCoverage("saveForm") f = Form(self) result = f.saveForm(submit, message, success) self.endCoverage() return result
def onConnect(self): Form.onConnect(self) servername = self.content['Server Name'].get() portnum = self.content['Port Number'].get() self.portnum = int(portnum) self.servername = servername print("%s %s" % (servername, portnum)) # connect to server self.connect(servername, int(portnum))
def index(): context = td.getInfo() form = Form() if form.validate_on_submit(): content_add = form.content_add.data if content_add != None: print(content_add) td.add_todo(content_add) else: print('提交表单失败!') return render_template('base.html', contexts=context, form=form)
def onSubmit(self): Form.onSubmit(self) localdir = self.content['Local Dir?'].get() portnumber = self.content['Port Number'].get() servername = self.content['Server Name'].get() filename = self.content['File Name'].get() if localdir: os.chdir(localdir) portnumber = int(portnumber) getfile.client(servername, portnumber, filename) showinfo('getfilegui', 'Download complete') if self.oneshot: Tk().quit()
def onSubmit(self): Form.onSubmit(self) localdir = self.content['Local Dir?'].get() portnumber = self.content['Port Number'].get() servername = self.content['Server Name'].get() filename = self.content['File Name'].get() if localdir: os.chdir(localdir) portnumber = int(portnumber) getfile.client(servername, portnumber, filename) showinfo('getfilegui', 'Download complete') if self.oneshot: Tk().quit() # else stay in last localdir
def from_dict(framework_dict): framework_dict.setdefault('job-forms', {}) framework_dict['job_forms'] = {} if 'IMPORT' in framework_dict['job-forms']: framework_dict['job_forms']['IMPORT'] = [ Form.from_dict(job_form_dict) for job_form_dict in framework_dict['job-forms']['IMPORT'] ] if 'EXPORT' in framework_dict['job-forms']: framework_dict['job_forms']['EXPORT'] = [ Form.from_dict(job_form_dict) for job_form_dict in framework_dict['job-forms']['EXPORT'] ] framework_dict.setdefault('con-forms', []) framework_dict['con_forms'] = [ Form.from_dict(con_form_dict) for con_form_dict in framework_dict['con-forms'] ] return Framework(**framework_dict)
def post(self): self.set_header('Content-Type', 'application/pdf; charset="utf-8"') self.set_header('Content-Disposition', 'attachment; filename="i-589-filled.pdf"') data = tornado.escape.json_decode(self.request.body) pages = form_constructor(data) form = Form(pages) output = form.assemble() tmp = BytesIO() output.write(tmp) self.write(tmp.getvalue()) self.finish()
def from_dict(connection_dict): connection_dict.setdefault("connector", []) connection_dict["connector"] = [Form.from_dict(con_form_dict) for con_form_dict in connection_dict["connector"]] connection_dict.setdefault("framework", []) connection_dict["framework"] = [ Form.from_dict(framework_form_dict) for framework_form_dict in connection_dict["framework"] ] if not "connector_id" in connection_dict: connection_dict["connector_id"] = connection_dict.setdefault("connector-id", -1) return Connection(**connection_dict)
def onSubmit(self): Form.onSubmit(self) localdir = self.content["Local Dir?"].get() portnumber = self.content["Port Number"].get() servername = self.content["Server Name"].get() filename = self.content["File Name"].get() if localdir: os.chdir(localdir) portnumber = int(portnumber) getfile.client(servername, portnumber, filename) showinfo("getfilegui", "Download complete") if self.oneshot: Tk().quit() # else stay in last localdir
def from_dict(connector_dict, resources_dict={}): connector_dict.setdefault('job-forms', {}) connector_dict['job_forms'] = {} if 'IMPORT' in connector_dict['job-forms']: connector_dict['job_forms']['IMPORT'] = [ Form.from_dict(job_form_dict) for job_form_dict in connector_dict['job-forms']['IMPORT'] ] if 'EXPORT' in connector_dict['job-forms']: connector_dict['job_forms']['EXPORT'] = [ Form.from_dict(job_form_dict) for job_form_dict in connector_dict['job-forms']['EXPORT'] ] connector_dict.setdefault('con-forms', []) connector_dict['con_forms'] = [ Form.from_dict(con_form_dict) for con_form_dict in connector_dict['con-forms'] ] connector_dict['resources'] = resources_dict.setdefault(unicode(connector_dict['id']), {}) return Connector(**connector_dict)
def __init__(self): root = Tk() root.title(self.title) root.geometry("600x600") Form.__init__(self) self.portnum = 0 self.nextport = 0 self.servername = "" self.filename = "" self.socket = None self.transfer_done = 0 self.data_transfer_done = 0
def checkForm (self, formTemplate, readonly=False): """ Method to check the layout of a form elementList: data to check the elements on the form buttonList: data to check the buttons on the form helpList: data to check the help balloons side effects: TestCase::fail() is called if any check failed side effects: messages are written out reflecting what was verified """ self.startCoverage("checkForm") f = Form(self) f.checkForm(formTemplate, readonly) self.endCoverage() return f
def menu(self): opcao = Form().menu() if (opcao == "1-1"): p = Form().cadastroAluno() Aluno().save(p.nome, p.idade) if (opcao == "1-2"): d = Form().cadastroDisciplina() Disciplina().save(d.nome) if (opcao == "1-3"): d = Form().cadastroProva() Prova().save(d.disciplina, d.pontos) if (opcao == "1-4"): d = Form().cadastroNota() if (opcao == "2-1"): Aluno().all() if (opcao == "2-2"): Disciplina().all(Prova().objects) if (opcao == "2-3"): Prova().all() if (opcao == "3-1"): Aluno().get(Form().pesquisaAluno(), Prova(), Disciplina().objects) if (opcao == "3-2"): Disciplina().get(Form().pesquisaDisciplina(Prova().objects), Prova()) if (opcao == "3-3"): Prova().get(Form().pesquisaProva()) if (opcao == "9"): clear = lambda: os.system('clear') clear() if (opcao != "x" and opcao != "X"): app.menu()
def from_dict(job_dict): job_dict.setdefault('connector', []) job_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in job_dict['connector'] ] job_dict.setdefault('framework', []) job_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in job_dict['framework'] ] if not 'connection_id' in job_dict: job_dict['connection_id'] = job_dict['connection-id'] if not 'connector_id' in job_dict: job_dict['connector_id'] = job_dict['connector-id'] return Job(**job_dict)
def __init__(self): root = Tk() root.title(self.title) root.geometry("600x600") labels = ['Server Name', 'Port Number'] Form.__init__(self, labels) self.portnum = 0 self.nextport = 0 self.servername = "" self.filename = "" self.socket = None self.transfer_done = 0 self.data_transfer_done = 0 self.filelist = []
def get_forms(page): data = page.read() soup = BeautifulSoup(data) forms = soup.findAll('form') f = [] for form in forms: this_form = Form() this_form.set_attributes(form.attrs) for element in form.recursiveChildGenerator(): try: if element.name in ['input', 'select', 'textarea', 'button']: this_form.add_element(element.name, element.attrs, element.string) except AttributeError, e: pass f.append(this_form)
def build_form_board(self, action, player): if action == 1: self.form_container = tk.Frame(self, relief=tk.GROOVE) self.form_container.pack(side=tk.TOP, padx=100, pady=100) self.form_container.rowconfigure(0, weight=1) self.form_container.columnconfigure(0, weight=1) self.form = Form(self.form_container, self) self.form.grid(row=0, column=0, sticky="nsew") self.form.tkraise() elif action == 2: self.form_container.destroy() self.form.destroy() self.build_board(player)
def load_and_edit_record(self, event): """Load the selected record into a form for editing""" selected_record = self.record_display.GetFirstSelected() if selected_record == -1: # none selected return # convert to string coz unicode object does not work selected_record_key = str(''.join([self.record_display.GetItem( selected_record, x).GetText() for x in range(len(self.index_keys))])) rec = self.db.db[selected_record_key] f = Form(self, 'report_docs/form_fields.yaml', selected_record_key) f.set_values(rec)
def ShowPublish(self, charactor): """label selection charactor-sprite""" charactor.sprite = Form(self.topSprites) charactor.sprite.SetTitle("Which label?") charactor.sprite.SetFields([" Label Name"]) charactor.sprite.rect = (400,900)
def ShowRegister(self, charactor): """register charactor-sprite""" charactor.sprite = Form(self.topSprites) charactor.sprite.SetTitle("Register") charactor.sprite.SetFields([" Name", " E-mail", "Password"]) charactor.sprite.rect = (400,900)
def edit_record(self, event): """Load the selected record into a form for editing.""" selected_record = self.register.record_display.GetFirstSelected() if selected_record == -1: self.register.SetStatusText('No record selected', 0) return id = str(self.register.record_display.GetItemData(selected_record)) record_vals = self.records.retrieve_record(id) if self.is_locked(selected_record): form = ReadOnlyForm(None, self.fields_file, 'Locked record. Cannot edit', record_vals) if form.ShowModal() == wx.ID_OK: form.Destroy else: form = Form(None, self.fields_file, 'Edit the values', record_vals) if form.ShowModal() == wx.ID_OK: form.get_values() # insert record with same id self.records.insert_record(form.vals, id) self.register.refresh_records() form.Destroy()
def getContours(img, imgContour, ogImage): contours, image = cv2.findContours( img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) form = None for cnt in contours: area = cv2.contourArea(cnt) print(area) areaMin = 5000 if area > areaMin: cv2.drawContours(imgContour, cnt, -1, (255, 0, 255), 7) peri = cv2.arcLength(cnt, True) approx = cv2.approxPolyDP(cnt, 0.02 * peri, True) corners = len(approx) area = int(area) M = cv2.moments(cnt) cX = int(M["m10"] / M["m00"]) cY = int(M["m01"] / M["m00"]) hsv = cv2.cvtColor(imgContour, cv2.COLOR_BGR2HSV) color = hsv[cY][cX] * [2, 1/2.55, 1/2.55] form = Form(corners, area, color) # Draw result on image x, y, w, h = cv2.boundingRect(approx) cv2.rectangle(imgContour, (x, y), (x + w, y + h), (0, 255, 0), 5) cv2.putText(imgContour, "Points: " + str(len(approx)), (x - 20, y - 20), cv2.FONT_HERSHEY_COMPLEX, .7, (0, 255, 0), 2) cv2.putText(imgContour, "Area: " + str(int(area)), (x - 20, y - 45), cv2.FONT_HERSHEY_COMPLEX, 0.7, (0, 255, 0), 2) return form
def handle_exception(ex, stacktrace=None): err_icon = os.path.join(os.path.dirname(__file__), 'graphics', 'icon_error.gif') frm = Form(caption='Exception: {}'.format(ex.__class__.__name__), left=100, top=100, width=350, height=180) frm.resizable = False msg = Label(frm, left=45, top=5, width=305, height=40, caption=ex.message) msg.wordwrap = True img = Image(frm, left=5, top=15, width=32, height=32, file=err_icon) trace = Memo(frm, left=5, top=55, width=335, height=90) trace.text = stacktrace def close_form(): frm.close() btn = Button(frm, left=140, top=148, width=65, height=27, caption="Close") btn.on_click = close_form frm.show_modal()
def ShowLogin(self, charactor): """login charactor-sprite""" charactor.sprite = Form(self.topSprites) charactor.sprite.SetTitle("Login") charactor.sprite.SetFields([" E-mail", "Password"]) charactor.sprite.user = None charactor.sprite.rect = (400,900)
def checkFormStrict(self, formTemplate, formName=None): """ Method to check that the visible element in the template Are all displayed and that they are the only ones displayed NOTE this is an *experimental method* it tries to check that the template matches what is displayed. It is not guaranteed to manage all possible form elements. If you have a element that you would like to be added to this method raise a ticket on Trac """ self.startCoverage("checkFormStrict") error = [] f = Form(self) error = f.checkFormStrict(formTemplate, formName) self.endCoverage() return error
def contact(): """Render the website's contact page.""" c_form = Form(request.form) if request.method == "POST": if c_form.validate_on_submit(): user_name = c_form.name.data user_email = c_form.email.data subject = c_form.subject.data msg = c_form.message.data send_email(user_name, user_email, subject, msg) flash("Email Sent.") return redirect(url_for('home')) return render_template('contact.html', form=c_form)
def __init__(self): pygame.init() self.settings = Settings() self.screen = pygame.display.set_mode(self.settings.screen_size) self.compass = Compass() self.place = Place(self.settings, self.screen, self.compass) self.form = Form(self.settings, self.screen, self.compass) self.functions = Functions(self.settings, self.screen, self.compass, self.place, self.form)
def from_dict(connection_dict): connection_dict.setdefault('connector', []) connection_dict['connector'] = [ Form.from_dict(con_form_dict) for con_form_dict in connection_dict['connector'] ] connection_dict.setdefault('framework', []) connection_dict['framework'] = [ Form.from_dict(framework_form_dict) for framework_form_dict in connection_dict['framework'] ] if not 'connector_id' in connection_dict: connection_dict['connector_id'] = connection_dict.setdefault( 'connector-id', -1) return Connection(**connection_dict)
def add_central_widget(self): form = Form(self.statusBar) title = self.create_title() central_widget = QWidget() central_layout = QVBoxLayout() central_layout.addWidget(title) central_layout.addWidget(form) central_widget.setLayout(central_layout) self.setCentralWidget(central_widget)
def create(view_ids, model, res_id=False, domain=None, context=None, order=None, mode=None, name=False, limit=None, search_value=None, icon=None, tab_domain=None): from tryton.gui import Main if context is None: context = {} if model: from form import Form win = Form(model, res_id, domain, order=order, mode=mode, view_ids=(view_ids or []), context=context, name=name, limit=limit, search_value=search_value, tab_domain=tab_domain) else: from board import Board win = Board(model, view_ids and view_ids[0] or None, context=context, name=name) win.icon = icon Main.get_main().win_add(win, hide_current=Window.hide_current, allow_similar=Window.allow_similar)
def onSubmit(self): Form.onSubmit(self) localdir = self.content['Local Dir'].get() remotedir = self.content['Remote Dir'].get() servername = self.content['Server Name'].get() filename = self.content['File Name'].get() username = self.content['User Name?'].get() password = self.content['Password?'].get() userinfo = () if username and password: userinfo = (username, password) if localdir: os.chdir(localdir) self.mutex.acquire() self.threads +=1 self.mutex.release() ftpargs = (filename, servername, remotedir, userinfo) _thread.start_new_thread(self.transfer, ftpargs) showinfo(self.title, '%s of "%s" started' % (self.mode, filename))
def onSubmit(self): Form.onSubmit(self) localdir = self.content['Local Dir'].get() remotedir = self.content['Remote Dir'].get() servername = self.content['Server Name'].get() filename = self.content['File Name'].get() username = self.content['User Name?'].get() password = self.content['Password?'].get() userinfo = () if username and password: userinfo = (username, password) if localdir: os.chdir(localdir) self.mutex.acquire() self.threads += 1 self.mutex.release() ftpargs = (filename, servername, remotedir, userinfo) _thread.start_new_thread(self.transfer, ftpargs) showinfo(self.title, '%s of "%s" started' % (self.mode, filename))
def show_signup_form(): if request.method == 'POST': name = request.form['name'] email = request.form['email'] password = request.form['password'] next = request.args.get('next', None) if next: return redirect(next) return redirect(url_for('index')) return render_template("signup_form.html", form=Form())
def run_rules(data): """Mandatory function which runs the rules pertaining to this module """ form = Form(data) for event in form.events(): for field in event.fields(): field_value = field.value if not field_value: continue else: is_cancelled = False is_cancelled = process_field_cancelled_value(field_value) if is_cancelled is True: # clear the field value field.clear_value() else: continue return form
def new_template(self, event): """Create a new template""" form = Form(None, self.fields_file, 'Fill in the values for template') if form.ShowModal() == wx.ID_OK: form.get_values() template_vals = form.vals form.Destroy() # get template name name_entry = wx.TextEntryDialog(None, 'Enter name for template') if name_entry.ShowModal() == wx.ID_OK: template_name = name_entry.GetValue() if not template_name.endswith('.tpl'): template_name += '.tpl' template_name = os.path.join(self.project_dir, template_name) else: return # write the template yaml.dump(template_vals, open(template_name, 'w'))
def __init__(self, name=None, method=None, action=None, enctype=None, fields=None, validators=None, processors=None, layout=None, **view_attrs): Form.__init__(self, name, method, action, enctype, fields, validators, processors) Viewable.__init__(self, **view_attrs) self.layout=layout or StackLayout()
def test_is_not_empty(self): raw_xml = """ <person_form_event> <person> <study_id>60</study_id> <all_form_events> <form> <name>hcv_rna_results</name> <event> <name>1_arm_1</name> <field><name/><value>o hai</value></field> <field><name>hcv_lbdtc</name><value/></field> </event> </form> </all_form_events> </person> </person_form_event>""" form = Form(etree.fromstring(raw_xml)) event = form.events().next() self.assertFalse(event.is_empty())
def get(self): if self.request.GET: # Creating empty sting variable that will later be used to populate form values onto the page. relationship = '' # Using try: to prevent checkbox errors try: # Set relationship_type equal to the value of the 'relationship1' checkbox if checked relationship_type = self.request.GET['relationship1'] # If the person did check the 'relationship1' checkbox if relationship_type: # Then set empty string variable equal to itself plus the new relationship variable type which will be equal to the checkbox 'relationship1' relationship = relationship + relationship_type + ' ' # If they check neither box no error will happen except StandardError: pass # Using try: to prevent checkbox errors try: # Set relationshiip_type2 equal to the value of the "relationship2" checkbox if checked relationship_type2 = self.request.GET['relationship2'] # If the person did check the 'relationship2' checkbox if relationship_type2: # Then set empty string variable equal to itself plus the new relationship variable type which will be equal to the checkbox 'relationship2' # Also because of this both can be checked relationship = relationship + relationship_type2 # If they check neither box no error will happen except StandardError: pass # Set variable form_info equal to all the user inputed form information form_info = self.request.GET['first_name'] + ' ' + self.request.GET['last_name'] + ' ' + self.request.GET['phone_type'] + ' ' + self.request.GET['phone_number'] + ' ' + relationship # Creates form Object form = Form(self) # Will populate the user inputed information on a new Form Page self.response.write(form.print_contents(form_info)) else: # Creates form Object form = Form(self) # Will populate the form for the user to input it's information self.response.write(form.print_contents())