Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
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
Exemplo n.º 10
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()
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
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"
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
Arquivo: fapi.py Projeto: BuloZB/foris
 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
Exemplo n.º 16
0
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())
Exemplo n.º 17
0
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'))
Exemplo n.º 18
0
def get_form(form_name='Form1',
             layout=None,
             has_file_menu=True,
             Left=611,
             Height=240,
             Top=162,
             Width=320,
             Caption=None,
             LCLVersion='1.6.0.4'):

    return Form(**key_word_args(FORM_PARAML, locals()))
Exemplo n.º 19
0
 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)
Exemplo n.º 20
0
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)
Exemplo n.º 21
0
    def __init__(self, parent):
        super(RegisterSong, self).__init__(parent)
        self.container = Frame(parent, style="DarkGray.TFrame")

        self.form = Form(self.container, 'Faixa', [
            {'label': 'Álbum', 'attr': 'cod_alb', 'type': 'select', 'target': 'Album', 'target_label': 'descricao', 'target_key': 'cod'},
            {'label': 'Tipo de Composição', 'attr': 'tipo_comp', 'type': 'select', 'target': 'Tipo_Comp', 'target_label': 'descricao', 'target_key': 'cod'},
            {'label': 'Tempo de execução', 'attr': 'tempo_exec', 'type': 'text'},
            {'label': 'Tipo de Gravação', 'attr': 'tipo_grav', 'type': 'text'},
            {'label': 'Descrição', 'attr': 'descricao', 'type': 'text'}
        ], lambda: random.randint(1, 9999))
Exemplo n.º 22
0
 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())
Exemplo n.º 23
0
def create_art(nation, creator):
    category = creator.choice(ART_CATEGORIES[creator.periods[-1].role])

    style = ''
    sub_category = ''
    material = ''

    if category == 'drawing':
        style = creator.choice(ART_STYLES[category])
        sub_category = creator.choice(ART_SUBCATEGORIES[category])

        gen_forms = creator.choice(ART_SUBJECTS[sub_category])
    else:
        gen_forms = creator.choice(ART_SUBJECTS[category])

    gen = Form(gen_forms, custom_weights=creator.periods[-1].custom_weights)
    subject, content = gen.generate(nation=nation, creator=creator)

    if subject is not None:
        creator.periods[-1].custom_weights = gen.custom_weights

        material_gen = None
        if style in ART_MATERIALS:
            material_gen = Form(
                ART_MATERIALS[style],
                custom_weights=creator.periods[-1].custom_weights)
        elif category in ART_MATERIALS:
            material_gen = Form(
                ART_MATERIALS[category],
                custom_weights=creator.periods[-1].custom_weights)

        name = utility.titlecase(nation.language.translateTo(subject))

        if material_gen is not None:
            material = material_gen.generate(nation=nation, creator=creator)[0]
            creator.periods[-1].custom_weights = material_gen.custom_weights

        return Art(nation, creator, name, subject, category, style,
                   sub_category, content, material, None, gen)
    else:
        return None
Exemplo n.º 24
0
 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()
Exemplo n.º 25
0
    def __init__(self, parent):
        super(RegisterAlbum, self).__init__(parent)
        self.container = Frame(parent, style="DarkGray.TFrame")

        self.form = Form(self.container, 'Album', [
            {'label': 'Gravadora', 'attr': 'codgrav', 'type': 'select', 'target': 'Gravadora', 'target_label': 'nome', 'target_key': 'cod'},
            {'label': 'Preço de Compra', 'attr': 'pr_compra', 'type': 'int'},
            {'label': 'Data de Compra', 'attr': 'data_compra', 'type': 'text'},
            {'label': 'Data de Gravação', 'attr': 'data_grav', 'type': 'text'},
            {'label': 'Tipo de Compra', 'attr': 'tipo_compra', 'type': 'text'},
            {'label': 'Descrição', 'attr': 'descricao', 'type': 'text'}
        ], lambda: random.randint(1, 9999))
Exemplo n.º 26
0
def execute_window(view_ids,
                   model,
                   res_id=False,
                   domain=None,
                   view_type='form',
                   context={},
                   mode='form,tree',
                   name=None,
                   target=None,
                   limit=None):
    """Performs `actions.act_window` action.

    @param view_ids: view ids
    @param model: a model for which the action should be performed
    @param res_id: resource id
    @param domain: domain
    @param view_type: view type, eigther `form` or `tree`
    @param context: the context
    @param mode: view mode, eigther `form,tree` or `tree,form` or None

    @return: view (mostly XHTML code)
    """

    params = TinyDict()

    params.model = model
    params.ids = res_id
    params.view_ids = view_ids
    params.domain = domain or []
    params.context = context or {}
    params.limit = limit

    if name:
        params.context['_terp_view_name'] = name

    if params.ids and not isinstance(params.ids, list):
        params.ids = [params.ids]

    params.id = (params.ids or False) and params.ids[0]

    mode = mode or view_type

    if view_type == 'form':
        mode = mode.split(',')
        params.view_mode = mode

        return Form().create(params)

    elif view_type == 'tree':
        return Tree().create(params)

    else:
        raise common.message(_("Invalid View!"))
Exemplo n.º 27
0
    def __init__(self, params):

        self.params = TinyDict(**params.copy())
        self.params.view_type = 'form'

        form = Form().create_form(self.params)

        record = self._make_record(form)
        self.clear()

        self.update(record.copy())
        self['id'] = params.id or False
Exemplo n.º 28
0
    def __init__(self, screenWidth, screenHeight):
        super().__init__()

        self.screenWidth = screenWidth
        self.screenHeight = screenHeight
        self.form = Form()
        self.setCentralWidget(self.form)
        self.statusBar().showMessage('Ready')
        self.setWindowTitle("Öğrenci Bilgileri")
        self.createMyMenu()
        self.center()
        self.show()
Exemplo n.º 29
0
def setupREST():
    """
    Create Rest instance with other services added to it.
    """
    rest = Rest()
    rest.form = Form()
    rest.form.analytics = Analytics()

    #rest.test.mood = Mood()
    #rest.test.test3 = Test3()
    #rest.test.user = User()
    return rest
Exemplo n.º 30
0
    def __init__(self, parent):
        super(RegisterRecord, self).__init__(parent)
        self.container = Frame(parent, style="DarkGray.TFrame")

        self.form = Form(self.container, 'Gravadora', [
            {'label': 'Nome', 'attr': 'nome', 'type': 'text'},
           	{'label': 'Rua', 'attr': 'rua', 'type': 'text'},
           	{'label': 'Cidade', 'attr': 'cidade', 'type': 'text'},
           	{'label': 'UF', 'attr': 'uf', 'type': 'text'},
           	{'label': 'País', 'attr': 'pais', 'type': 'text'},
           	{'label': 'Nº', 'attr': 'numero', 'type': 'int'},
           	{'label': 'Homepage', 'attr': 'homepage', 'type': 'text'}
        ], lambda: random.randint(1, 9999))