def _set_column_widget(self, column, attributes, arrow=True, align=0.5): hbox = Gtk.HBox(homogeneous=False, spacing=2) label = Gtk.Label(label=attributes['string']) field = self.field_attrs.get(attributes['name'], {}) if field and self.view.editable: required = field.get('required') readonly = field.get('readonly') common.apply_label_attributes(label, readonly, required) attrlist = Pango.AttrList() self._format_set(attributes, attrlist) label.set_attributes(attrlist) label.show() help = attributes.get('help') if help: tooltips = Tooltips() tooltips.set_tip(label, help) tooltips.enable() if arrow: arrow_widget = Gtk.Image() arrow_widget.show() column.arrow = arrow_widget hbox.pack_start(label, expand=True, fill=True, padding=0) if arrow: hbox.pack_start(arrow_widget, expand=False, fill=False, padding=0) column.set_clickable(True) hbox.show() column.set_widget(hbox) column.set_alignment(align)
def set_column_widget(self, column, field, attributes, arrow=True, align=0.5): hbox = gtk.HBox(False, 2) label = gtk.Label(attributes['string']) if field and self.editable: required = field.attrs.get('required') readonly = field.attrs.get('readonly') common.apply_label_attributes(label, readonly, required) label.show() help = None if field and field.attrs.get('help'): help = field.attrs['help'] elif attributes.get('help'): help = attributes['help'] if help: tooltips = Tooltips() tooltips.set_tip(label, help) tooltips.enable() if arrow: arrow_widget = gtk.Arrow(gtk.ARROW_NONE, gtk.SHADOW_NONE) arrow_widget.show() column.arrow = arrow_widget hbox.pack_start(label, True, True, 0) if arrow: hbox.pack_start(arrow_widget, False, False, 0) column.set_clickable(True) hbox.show() column.set_widget(hbox) column.set_alignment(align)
def state_set(self, record): super(Label, self).state_set(record) if 'name' in self.attrs and record: field = record.group.fields[self.attrs['name']] else: field = None if not self.attrs.get('string', True) and field: if record: text = field.get_client(record) or '' else: text = '' self.set_text(text) if record: state_changes = record.expr_eval(self.attrs.get('states', {})) else: state_changes = {} required = ((field and field.attrs.get('required')) or state_changes.get('required')) readonly = ((field and field.attrs.get('readonly')) or state_changes.get('readonly', not bool(field))) common.apply_label_attributes(self, readonly, required)
def _set_label_state(self): common.apply_label_attributes(self.title, self._readonly, self._required)