Exemplo n.º 1
0
 def __init__(self,name,width=None,height=None,label=None,**kw):
     Component.__init__(self,name,**kw)
     if width is not None:
         self.width = width
     if height is not None:
         self.height = height
     if label is not None:
         self.label = label
Exemplo n.º 2
0
 def __str__(self):
     "This shows how elements are specified"
     name = Component.__str__(self)
     if self.width is None:
         return name
     if self.height is None:
         return name + ":%d" % self.width
     return name + ":%dx%d" % (self.width,self.height)
Exemplo n.º 3
0
 def __init__(self,index,editor,**kw):
     """editor may be a Panel for columns on a GenericForeignKey
     """
     #~ print 20100515, editor.name, editor.__class__
     #~ assert isinstance(editor,FieldElement), \
         #~ "%s.%s is a %r (expected FieldElement instance)" % (cm.grid.report,editor.name,editor)
     self.editor = editor
     #~ self.value_template = editor.grid_column_template
     kw.update(sortable=True)
     self.index = index
     self.label = editor.label
     kw.update(self.editor.get_column_options())
     kw.update(hidden=editor.hidden)
     if settings.USE_GRIDFILTERS and editor.filter_type:
         kw.update(filter=dict(type=editor.filter_type))
     #~ if isinstance(editor,FieldElement) and editor.field.primary_key:
     if isinstance(editor,FieldElement):
         self.field = editor.field
         rend = None
         if isinstance(editor.field,models.AutoField):
             rend = 'Lino.id_renderer'
             #~ kw.update(renderer=js_code('Lino.id_renderer'))
         elif isinstance(editor.field,models.ForeignKey):
             # FK fields are clickable if their target has a detail view
             rpt = editor.field.rel.to._lino_model_report
             if rpt.detail_action is not None:
             #~ a = rpt.get_action('detail')
             #~ if a is not None:
                 rend = "Lino.fk_renderer('%s','Lino.%s')" % (
                   editor.field.name + 'Hidden',
                   rpt.detail_action)
                 #~ rend = "Lino.fk_renderer('%s','%s')" % (
                   #~ editor.field.name + 'Hidden',
                   #~ editor.lh.rh.ui.get_actor_url(rpt))
         #~ if not rend:
             #~ rend = 'Lino.default_renderer'
         if rend:
             kw.update(renderer=js_code(rend))
         kw.update(editable=editor.editable)
         if editor.editable:
             kw.update(editor=editor)
     else:
         kw.update(editable=False)
     Component.__init__(self,editor.name,**kw)