Exemple #1
0
 def change_to_readonly(self, cmp_name):
     old_obj = self.get_components(cmp_name)
     value = old_obj.value
     if isinstance(old_obj, XferCompSelect):
         if isinstance(old_obj.select_list, dict) and (value in old_obj.select_list.keys()):
             value = old_obj.select_list[value]
         if isinstance(old_obj.select_list, list):
             for key, sel_val in old_obj.select_list:
                 if value == key:
                     value = sel_val
                     break
     elif isinstance(old_obj, XferCompDate):
         value = formats.date_format(value, "DATE_FORMAT")
     elif isinstance(old_obj, XferCompDateTime):
         value = formats.date_format(value, "DATETIME_FORMAT")
     elif isinstance(old_obj, XferCompTime):
         value = formats.date_format(value, "TIME_FORMAT")
     elif isinstance(old_obj, XferCompFloat) and (value is not None):
         value = ("%%.%df" % old_obj.prec) % value
     if value is None:
         value = "---"
     self.remove_component(cmp_name)
     self.tab = old_obj.tab
     new_lbl = XferCompLabelForm(cmp_name)
     new_lbl.set_value(value)
     new_lbl.col = old_obj.col
     new_lbl.row = old_obj.row
     new_lbl.vmin = old_obj.vmin
     new_lbl.hmin = old_obj.hmin
     new_lbl.colspan = old_obj.colspan
     new_lbl.rowspan = old_obj.rowspan
     self.add_component(new_lbl)
Exemple #2
0
 def change_select_to_label(self, cmp_name):
     old_obj = self.get_components(cmp_name)
     if isinstance(old_obj, XferCompSelect):
         value = old_obj.value
         if isinstance(old_obj.select_list, list):
             for key, sel_val in old_obj.select_list:
                 if six.text_type(value) == six.text_type(key):
                     value = sel_val
                     break
             self.remove_component(cmp_name)
             self.tab = old_obj.tab
             new_lbl = XferCompLabelForm(cmp_name)
             new_lbl.set_value(value)
             new_lbl.col = old_obj.col
             new_lbl.row = old_obj.row
             new_lbl.vmin = old_obj.vmin
             new_lbl.hmin = old_obj.hmin
             new_lbl.colspan = old_obj.colspan
             new_lbl.rowspan = old_obj.rowspan
             new_lbl.description = old_obj.description
             self.add_component(new_lbl)
Exemple #3
0
 def change_to_readonly(self, cmp_name):
     old_obj = self.get_components(cmp_name)
     value = old_obj.value
     if isinstance(old_obj, XferCompSelect):
         if isinstance(old_obj.select_list,
                       dict) and (value in old_obj.select_list.keys()):
             value = old_obj.select_list[value]
         if isinstance(old_obj.select_list, list):
             for key, sel_val in old_obj.select_list:
                 if six.text_type(value) == six.text_type(key):
                     value = sel_val
                     break
     elif isinstance(old_obj, XferCompCheck):
         if value:
             value = _("Yes")
         else:
             value = _("No")
     elif value is None:
         value = "---"
     elif isinstance(old_obj, XferCompDate):
         value = formats.date_format(value, "DATE_FORMAT")
     elif isinstance(old_obj, XferCompDateTime):
         value = formats.date_format(value, "DATETIME_FORMAT")
     elif isinstance(old_obj, XferCompTime):
         value = formats.date_format(value, "TIME_FORMAT")
     elif isinstance(old_obj, XferCompFloat) and (value is not None):
         value = ("%%.%df" % old_obj.prec) % value
     self.remove_component(cmp_name)
     self.tab = old_obj.tab
     new_lbl = XferCompLabelForm(cmp_name)
     new_lbl.set_value(value)
     new_lbl.col = old_obj.col
     new_lbl.row = old_obj.row
     new_lbl.vmin = old_obj.vmin
     new_lbl.hmin = old_obj.hmin
     new_lbl.colspan = old_obj.colspan
     new_lbl.rowspan = old_obj.rowspan
     new_lbl.description = old_obj.description
     self.add_component(new_lbl)