コード例 #1
0
 def _fill_label_editor(self):
     edit = XferCompMemo('value')
     edit.set_value(self.item.value)
     edit.set_location(2, 4)
     edit.set_size(100, 500)
     edit.with_hypertext = True
     self.fill_menu_memo(edit)
     self.add_component(edit)
コード例 #2
0
ファイル: views.py プロジェクト: povtux/core
 def _fill_label_editor(self):
     edit = XferCompMemo('value')
     edit.set_value(self.item.value)
     edit.set_location(1, 4, 2)
     edit.set_size(100, 500)
     edit.with_hypertext = True
     self.fill_menu_memo(edit)
     self.add_component(edit)
コード例 #3
0
 def _add_option_selectors(self, gui):
     row_idx = 3
     for name_selector, title_selector, option_selector in self.selector:
         if isinstance(option_selector, list):
             comp = XferCompSelect(name_selector)
             comp.set_select(option_selector)
             comp.set_value(gui.getparam(name_selector, 0))
         elif isinstance(option_selector, tuple):
             comp = XferCompFloat(name_selector, option_selector[0],
                                  option_selector[1], option_selector[2])
             comp.set_value(option_selector[0])
         elif isinstance(option_selector, six.binary_type):
             comp = XferCompEdit(name_selector)
             comp.set_value(option_selector.decode())
         elif isinstance(option_selector, six.text_type):
             comp = XferCompMemo(name_selector)
             comp.with_hypertext = True
             comp.set_value(option_selector)
         elif isinstance(option_selector, bool):
             comp = XferCompCheck(name_selector)
             comp.set_value(option_selector)
         else:
             comp = None
         if comp is not None:
             comp.set_location(0, row_idx, 2)
             comp.description = title_selector
             gui.add_component(comp)
             row_idx += 1
コード例 #4
0
    def _fill_listing_editor(self):
        edt = XferCompFloat('page_width', 0, 9999, 0)
        edt.set_location(2, 3)
        edt.set_value(self.item.page_width)
        edt.description = _("list page width")
        self.add_component(edt)
        edt = XferCompFloat('page_heigth', 0, 9999, 0)
        edt.set_location(2, 4)
        edt.set_value(self.item.page_height)
        edt.description = _("list page height")
        self.add_component(edt)

        lab = XferCompLabelForm('lbl_col_size')
        lab.set_location(1, 5)
        lab.set_value_as_infocenter(_("size"))
        self.add_component(lab)
        lab = XferCompLabelForm('lbl_col_title')
        lab.set_location(2, 5)
        lab.set_value_as_infocenter(_("title"))
        self.add_component(lab)
        lab = XferCompLabelForm('lbl_col_text')
        lab.set_location(3, 5)
        lab.set_value_as_infocenter(_("text"))
        self.add_component(lab)

        col_index = 0
        for col_size, col_title, col_text in (self.item.columns + [[0, '', ''], [0, '', ''], [0, '', '']]):
            edt = XferCompFloat('col_size_%d' % col_index, 0, 999, 0)
            edt.set_location(1, 6 + col_index)
            edt.set_value(col_size)
            self.add_component(edt)
            edt = XferCompMemo('col_title_%d' % col_index)
            edt.set_location(2, 6 + col_index)
            edt.set_value(col_title)
            edt.set_size(75, 200)
            self.add_component(edt)
            edt = XferCompMemo('col_text_%d' % col_index)
            edt.set_location(3, 6 + col_index)
            edt.set_size(50, 300)
            edt.with_hypertext = True
            edt.set_value(col_text)
            self.fill_menu_memo(edt)
            self.add_component(edt)
            col_index += 1
コード例 #5
0
ファイル: views.py プロジェクト: Diacamma2/asso
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
コード例 #6
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     dlg.get_components('activity').colspan = 3
     dlg.get_components('date').colspan = 3
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                    close=CLOSE_YES,
                    params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
コード例 #7
0
 def _create_comp_textfield(self, field_name, dep_field):
     comp = XferCompMemo(field_name)
     comp.set_value(self._get_value_from_field(field_name, dep_field, ""))
     return comp
コード例 #8
0
 def get_write_comp(self):
     if self.type == 0:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
             param_cmp.with_hypertext = self.args['HyperText']
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == 1:  # Integer
         param_cmp = XferCompFloat(
             self.name, minval=self.args['Min'], maxval=self.args['Max'], precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 2:  # Real
         param_cmp = XferCompFloat(self.name, minval=self.args['Min'], maxval=self.args[
                                   'Max'], precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 3:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == 4:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = []
         for sel_idx in range(0, self.args['Enum']):
             selection.append((sel_idx, ugettext_lazy(self.name + ".%d" % sel_idx)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 5:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.security = 0
         param_cmp.set_value('')
     elif self.type == 6:  # select in object
         if (self.meta_info[0] != "") and (self.meta_info[1] != ""):
             db_mdl = apps.get_model(self.meta_info[0], self.meta_info[1])
         else:
             db_mdl = None
         if self.args['Multi']:
             param_cmp = XferCompCheckList(self.name)
             param_cmp.simple = 2
         else:
             param_cmp = XferCompSelect(self.name)
         param_cmp.set_needed(self.meta_info[4])
         selection = []
         if not self.meta_info[4]:
             if (self.args['oldtype'] == 1) or (self.args['oldtype'] == 2):
                 selection.append((0, None))
             else:
                 selection.append(('', None))
         if db_mdl is None:
             selection = self.meta_info[2]
         else:
             for obj_item in db_mdl.objects.filter(self.meta_info[2]):
                 selection.append((getattr(obj_item, self.meta_info[3]), six.text_type(obj_item)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
     param_cmp.description = six.text_type(ugettext_lazy(self.name))
     return param_cmp
コード例 #9
0
ファイル: views.py プロジェクト: Lucterios2/core
    def fillresponse(self, edt1='aaa', flt1=3.1399999, mm1='xyz', dt1='2007-04-23', tm1='12:34:00',
                     ck1=False, slct1='1', flt2=5, cl1=['1', '2'], cl2=['b', 'd', 'f'], stm1='2008-07-12 23:47:31'):
        act_modif = self.get_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select(
            {'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        checklist.set_value(cl1)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select(
            {'a': '123', 'b': '456', 'c': '789', 'd': '147', 'e': '258', 'f': '369'})
        checklist.set_value(cl2)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES)
コード例 #10
0
ファイル: parameters.py プロジェクト: povtux/core
 def get_write_comp(self):
     if self.type == 0:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == 1:  # Integer
         param_cmp = XferCompFloat(
             self.name, minval=self.args['Min'], maxval=self.args['Max'], precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 2:  # Real
         param_cmp = XferCompFloat(self.name, minval=self.args['Min'], maxval=self.args[
                                   'Max'], precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 3:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == 4:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = {}
         for sel_idx in range(0, self.args['Enum']):
             selection[sel_idx] = ugettext_lazy(self.name + ".%d" % sel_idx)
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 5:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.set_value('')
     return param_cmp
コード例 #11
0
ファイル: editors.py プロジェクト: mdanielo44/contacts
 def get_comp(self, value):
     comp = None
     args = self.item.get_args()
     if self.item.kind == 0:
         if args['multi']:
             comp = XferCompMemo(self.item.get_fieldname())
         else:
             comp = XferCompEdit(self.item.get_fieldname())
         comp.set_value(value)
     elif (self.item.kind == 1) or (self.item.kind == 2):
         comp = XferCompFloat(
             self.item.get_fieldname(), args['min'], args['max'], args['prec'])
         comp.set_value(value)
     elif self.item.kind == 3:
         comp = XferCompCheck(self.item.get_fieldname())
         comp.set_value(value)
     elif self.item.kind == 4:
         val_selected = value
         try:
             select_id = int(value)
         except ValueError:
             select_id = 0
         select_list = []
         for sel_item in args['list']:
             if sel_item == val_selected:
                 select_id = len(select_list)
             select_list.append((len(select_list), sel_item))
         comp = XferCompSelect(self.item.get_fieldname())
         comp.set_select(select_list)
         comp.set_value(select_id)
     return comp
コード例 #12
0
    def get_writing_comp(self, field_name):
        def get_value_from_field(default):
            try:
                val = getattr(self.item, field_name)
            except ObjectDoesNotExist:
                getLogger("lucterios.core").exception(
                    "fieldname '%s' not found", field_name)
                val = None
            if val is None:
                if is_needed:
                    if dep_field.default != NOT_PROVIDED:
                        val = dep_field.default
                    else:
                        val = default
            return val

        from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
        from django.db.models.fields.related import ForeignKey
        dep_field = self.item.get_field_by_name(field_name)
        is_needed = dep_field.unique or not (dep_field.blank or dep_field.null)
        if isinstance(dep_field, IntegerField):
            if (dep_field.choices
                    is not None) and (len(dep_field.choices) > 0):
                comp = XferCompSelect(field_name)
                comp.set_select(list(dep_field.choices))
                min_value = 0
            else:
                min_value, max_value = get_range_value(dep_field)
                comp = XferCompFloat(field_name, min_value, max_value, 0)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, DecimalField):
            min_value, max_value = get_range_value(dep_field)
            comp = XferCompFloat(field_name, min_value, max_value,
                                 dep_field.decimal_places)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, BooleanField):
            comp = XferCompCheck(field_name)
            comp.set_value(get_value_from_field(False))
        elif isinstance(dep_field, TextField):
            comp = XferCompMemo(field_name)
            comp.set_value(get_value_from_field(""))
        elif isinstance(dep_field, DateField):
            comp = XferCompDate(field_name)
            comp.set_value(get_value_from_field(datetime.date.today()))
        elif isinstance(dep_field, TimeField):
            comp = XferCompTime(field_name)
            comp.set_value(get_value_from_field(datetime.time()))
        elif isinstance(dep_field, DateTimeField):
            comp = XferCompDateTime(field_name)
            comp.set_value(get_value_from_field(datetime.datetime.now()))
        elif isinstance(dep_field, ForeignKey):
            comp = XferCompSelect(field_name)
            try:
                value = self.item
                for fieldname in field_name.split('.'):
                    value = getattr(value, fieldname)
            except ObjectDoesNotExist:
                value = None
            if value is None:
                comp.set_value(0)
            else:
                comp.set_value(value.id)
            if hasattr(self.item, fieldname + '_query'):
                sub_select = getattr(self.item, fieldname + '_query')
            else:
                sub_select = dep_field.remote_field.model.objects.all()
            comp.set_needed(not dep_field.null)
            comp.set_select_query(sub_select)
        elif (dep_field is not None
              ) and dep_field.is_relation and dep_field.many_to_many:
            comp = XferCompCheckList(field_name)
            comp.simple = 2
            if self.item.id is not None:
                values = []
                for item in getattr(self.item, field_name).all():
                    values.append(item.id)
                comp.set_value(values)
            if hasattr(self.item, field_name + '_query'):
                sub_select = getattr(self.item, field_name + '_query')
            else:
                sub_select = get_dico_from_setquery(
                    get_corrected_setquery(
                        dep_field.remote_field.model.objects.all()))
            comp.set_select(sub_select)
        else:
            comp = XferCompEdit(field_name)
            comp.set_value(get_value_from_field(""))
            if isinstance(dep_field, CharField):
                comp.size = dep_field.max_length
        comp.set_needed(is_needed)
        return comp
コード例 #13
0
    def fillresponse(self,
                     edt1='aaa',
                     flt1=3.1399999,
                     mm1='xyz',
                     dt1='2007-04-23',
                     tm1='12:34:00',
                     ck1=False,
                     slct1='1',
                     flt2=5,
                     cl1=['1', '2'],
                     cl2=['b', 'd', 'f'],
                     stm1='2008-07-12 23:47:31'):
        act_modif = self.return_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request,
                            act_modif,
                            modal=FORMTYPE_REFRESH,
                            close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request,
                         act_modif,
                         modal=FORMTYPE_REFRESH,
                         close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select({
            '1': 'abc',
            '2': 'def',
            '3': 'ghij',
            '4': 'klmn'
        })
        checklist.set_value(cl1)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select({
            'a': '123',
            'b': '456',
            'c': '789',
            'd': '147',
            'e': '258',
            'f': '369'
        })
        checklist.set_value(cl2)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES)
コード例 #14
0
ファイル: editors.py プロジェクト: Lucterios2/contacts
 def get_comp(self, value):
     comp = None
     args = self.item.get_args()
     if self.item.kind == 0:
         if args['multi']:
             comp = XferCompMemo(self.item.get_fieldname())
         else:
             comp = XferCompEdit(self.item.get_fieldname())
         comp.set_value(value)
     elif (self.item.kind == 1) or (self.item.kind == 2):
         comp = XferCompFloat(
             self.item.get_fieldname(), args['min'], args['max'], args['prec'])
         comp.set_value(value)
     elif self.item.kind == 3:
         comp = XferCompCheck(self.item.get_fieldname())
         comp.set_value(value)
     elif self.item.kind == 4:
         val_selected = value
         select_id = 0
         select_list = []
         for sel_item in args['list']:
             if sel_item == val_selected:
                 select_id = len(select_list)
             select_list.append((len(select_list), sel_item))
         comp = XferCompSelect(self.item.get_fieldname())
         comp.set_select(select_list)
         comp.set_value(select_id)
     return comp
コード例 #15
0
    def _get_from_selector(self):
        if not isinstance(self.selector, list) and (self.selector is not None):
            raise LucteriosException(GRAVE, "Error of print selector!")
        gui = XferContainerCustom()
        gui.model = self.model
        gui._initialize(self.request)
        gui.is_view_right = self.is_view_right
        gui.caption = self.caption
        gui.extension = self.extension
        gui.action = self.action
        gui.params = self.params
        pdfreport = self.get_persistent_pdfreport()
        if (pdfreport is not None) and (not isinstance(pdfreport, list)
                                        or len(pdfreport) == len(self.items)):
            presitent_report = XferCompCheck('PRINT_PERSITENT')
            presitent_report.set_value(True)
            presitent_report.set_location(0, 0, 2)
            presitent_report.description = _('Get saved report')
            presitent_report.java_script = """
var is_persitent=current.getValue();
parent.get('PRINT_MODE').setEnabled(!is_persitent);
parent.get('print_sep').setEnabled(!is_persitent);
"""
            if self.selector is not None:
                for name_selector, _selector, _selector in self.selector:
                    presitent_report.java_script += "parent.get('%s').setEnabled(!is_persitent);\n" % name_selector
            gui.add_component(presitent_report)
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_REGENERATE_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)
        elif (pdfreport is not None):
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_WARNING_SAVING_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)

        print_mode = XferCompSelect('PRINT_MODE')
        print_mode.set_select(self.print_selector)
        print_mode.set_value(PRINT_PDF_FILE)
        print_mode.set_location(0, 2, 2)
        print_mode.description = _('Kind of report')
        gui.add_component(print_mode)
        if self.selector is not None:
            row_idx = 3
            for name_selector, title_selector, option_selector in self.selector:
                if isinstance(option_selector, list):
                    comp = XferCompSelect(name_selector)
                    comp.set_select(option_selector)
                    comp.set_value(gui.getparam(name_selector, 0))
                elif isinstance(option_selector, tuple):
                    comp = XferCompFloat(name_selector, option_selector[0],
                                         option_selector[1],
                                         option_selector[2])
                    comp.set_value(option_selector[0])
                elif isinstance(option_selector, six.binary_type):
                    comp = XferCompEdit(name_selector)
                    comp.set_value(option_selector.decode())
                elif isinstance(option_selector, six.text_type):
                    comp = XferCompMemo(name_selector)
                    comp.with_hypertext = True
                    comp.set_value(option_selector)
                elif isinstance(option_selector, bool):
                    comp = XferCompCheck(name_selector)
                    comp.set_value(option_selector)
                else:
                    comp = None
                if comp is not None:
                    comp.set_location(0, row_idx, 2)
                    comp.description = title_selector
                    gui.add_component(comp)
                    row_idx += 1
        gui.add_action(self.get_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
コード例 #16
0
 def get_write_comp(self):
     param_cmp = None
     if self.type == Parameter.TYPE_STRING:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
             param_cmp.with_hypertext = self.args['HyperText']
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == Parameter.TYPE_INTEGER:  # Integer
         param_cmp = XferCompFloat(self.name,
                                   minval=self.args['Min'],
                                   maxval=self.args['Max'],
                                   precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_REAL:  # Real
         param_cmp = XferCompFloat(self.name,
                                   minval=self.args['Min'],
                                   maxval=self.args['Max'],
                                   precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_BOOL:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_SELECT:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = [(sel_idx, ugettext_lazy(self.name + ".%d" % sel_idx))
                      for sel_idx in range(0, self.args['Enum'])]
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == Parameter.TYPE_PASSWORD:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.security = 0
         param_cmp.set_value('')
     elif self.type == Parameter.TYPE_META:  # select in object
         param_cmp = self._get_meta_comp()
         param_cmp.set_needed(self.meta_info[4])
         param_cmp.set_select(self._get_selection_from_object())
         param_cmp.set_value(self.value)
     param_cmp.description = six.text_type(ugettext_lazy(self.name))
     return param_cmp