def display(self, record, field): super(Binary, self).display(record, field) if not field: if self.wid_text: self.wid_text.set_text('') self.wid_size.set_text('') self.but_save_as.hide() return False if hasattr(field, 'get_size'): size = field.get_size(record) else: size = len(field.get(record)) self.wid_size.set_text(common.humanize(size or 0)) reset_position(self.wid_size) if self.wid_text: self.wid_text.set_text(self.filename_field.get(record) or '') reset_position(self.wid_text) if size: stock, tooltip = 'tryton-open', _("Open...") else: stock, tooltip = None, '' pos = gtk.ENTRY_ICON_PRIMARY self.wid_text.set_icon_from_stock(pos, stock) self.wid_text.set_icon_tooltip_text(pos, tooltip) self.update_buttons(bool(size)) return True
def display(self): super().display() if self.record: self.entry.set_width_chars(self.width) value = self.get_client_value() self.entry.set_text(value) reset_position(self.entry)
def display(self): super(Binary, self).display() if not self.field: if self.wid_text: self.wid_text.set_text('') self.wid_size.set_text('') self.but_save_as.hide() return False if hasattr(self.field, 'get_size'): size = self.field.get_size(self.record) else: size = len(self.field.get(self.record)) self.wid_size.set_text(common.humanize(size or 0)) reset_position(self.wid_size) if self.wid_text: self.wid_text.set_text(self.filename_field.get(self.record) or '') reset_position(self.wid_text) if size: icon, tooltip = 'tryton-open', _("Open...") else: icon, tooltip = None, '' pos = Gtk.EntryIconPosition.PRIMARY if icon: pixbuf = common.IconFactory.get_pixbuf(icon, Gtk.IconSize.MENU) else: pixbuf = None self.wid_text.set_icon_from_pixbuf(pos, pixbuf) self.wid_text.set_icon_tooltip_text(pos, tooltip) self.update_buttons(bool(size)) return True
def set_value(self, value): if value is not None: txt_val = locale.format('%d', value, True) else: txt_val = '' self.widget.set_text(txt_val) reset_position(self.widget)
def display(self): super(Char, self).display() if self.autocomplete: if self.record: if self.field_name not in self.record.autocompletion: self.record.do_autocomplete(self.field_name) selection = self.record.autocompletion.get(self.field_name, []) else: selection = [] self.set_popdown([(x, x) for x in selection], self.entry) # Set size if self.autocomplete: size_entry = self.entry.get_child() else: size_entry = self.entry if self.record: field_size = self.record.expr_eval(self.attrs.get('size')) size_entry.set_width_chars(field_size or self.default_width_chars) size_entry.set_max_length(field_size or 0) else: size_entry.set_width_chars(self.default_width_chars) size_entry.set_max_length(0) value = self.get_client_value() if not self.autocomplete: self.entry.set_text(value) reset_position(self.entry) else: self.entry.handler_block_by_func(self.changed) if not self.set_popdown_value(self.entry, value) or not value: child = self.entry.get_child() child.set_text(value) reset_position(child) self.entry.handler_unblock_by_func(self.changed)
def display(self): super(TimeDelta, self).display() if not self.field: value = '' else: value = self.field.get_client(self.record) self.entry.set_text(value) reset_position(self.entry)
def display(self, record, field): super(TimeDelta, self).display(record, field) if not field: value = '' else: value = field.get_client(record) self.entry.set_text(value) reset_position(self.entry)
def display(self, record, field): # skip Char call because set_text doesn't work with int super(Char, self).display(record, field) if not field: self.entry.set_text('') return False self.entry.set_text(field.get_client(record, factor=self.factor)) reset_position(self.entry)
def set_value(self, value): digits = self.digits() if value is not None: txt_val = locale.format('%.' + str(digits[1]) + 'f', value, True) else: txt_val = '' self.widget.set_width_chars(sum(digits)) self.widget.set_text(txt_val) reset_position(self.widget)
def set_value(self, value): digits = self.digits if digits: self.widget.digits = digits[1] else: self.widget.digits = None self.widget.set_width_chars(self.width) if value is not None: txt_val = locale.format('%.*f', (digits[1], value), True) else: txt_val = '' self.widget.set_text(txt_val) reset_position(self.widget)
def set_value(self, value): digits = self.digits if digits: self.widget.digits = digits[1] else: self.widget.digits = None self.widget.set_width_chars(self.width) if value is not None: txt_val = locale.localize( '{0:.{1}f}'.format(value, digits[1]), True) else: txt_val = '' self.widget.set_text(txt_val) reset_position(self.widget)
def display(self): def set_symbol(entry, text): if text: entry.set_text(text) entry.set_width_chars(len(text) + 1) entry.show() else: entry.set_text('') entry.hide() super().display() self.entry.set_width_chars(self.width) if self.field and self.symbol: symbol, position = self.field.get_symbol(self.record, self.symbol) if position < 0.5: set_symbol(self.symbol_start, symbol) set_symbol(self.symbol_end, '') else: set_symbol(self.symbol_start, '') set_symbol(self.symbol_end, symbol) value = self.get_client_value() self.entry.set_text(value) reset_position(self.entry)
def display(self, record, field): super(Binary, self).display(record, field) if not field: if self.wid_text: self.wid_text.set_text('') self.wid_size.set_text('') if self.but_open: self.but_open.set_sensitive(False) self.but_save_as.set_sensitive(False) return False if self.wid_text: self.wid_text.set_text(self.filename_field.get(record) or '') reset_position(self.wid_text) if hasattr(field, 'get_size'): size = field.get_size(record) else: size = len(field.get(record)) self.wid_size.set_text(common.humanize(size or 0)) reset_position(self.wid_size) if self.but_open: self.but_open.set_sensitive(bool(size)) self.but_save_as.set_sensitive(bool(size)) return True
def display(self, record, field): super(Char, self).display(record, field) if self.autocomplete: if record: selection = record.autocompletion.get(self.field_name, []) else: selection = [] self.set_popdown([(x, x) for x in selection], self.entry) # Set size if self.autocomplete: size_entry = self.entry.get_child() else: size_entry = self.entry if record: field_size = record.expr_eval(self.attrs.get('size')) size_entry.set_width_chars(field_size or -1) size_entry.set_max_length(field_size or 0) else: size_entry.set_width_chars(-1) size_entry.set_max_length(0) if not field: value = '' else: value = field.get_client(record) if not self.autocomplete: self.entry.set_text(value) reset_position(self.entry) else: self.entry.handler_block_by_func(self.changed) if not self.set_popdown_value(self.entry, value) or not value: child = self.entry.get_child() child.set_text(value) reset_position(child) self.entry.handler_unblock_by_func(self.changed)
def set_value(self, value): values = dict(self.definition['selection']) self.widget.child.set_text(values.get(value, '')) reset_position(self.widget.child)
def set_value(self, value): self.widget.set_text(value or '') reset_position(self.widget)
def set_value(self, value): values = dict(self.definition['selection']) child = self.widget.get_child() child.set_text(values.get(value, '')) reset_position(child)
def set_text(self, value): if not value: value = '' self.wid_text.set_text(value) reset_position(self.wid_text)
def translate_widget_set(widget, value): widget.set_text(value or '') reset_position(widget)
def translate_widget_set(self, widget, value): widget.set_text(value) reset_position(widget)