def __init__(self): DateEntry.__init__(self) ValidatableProxyWidgetMixin.__init__(self) # Add some space to the entry, so it has rom for the icon, in case # of a validation error. # # Since we set the widget's width based on the number of characters, # get the width of a single char, so we can calculate how many # 'chars' the icon takes. layout = self.entry.get_layout() context = layout.get_context() metrics = context.get_metrics(context.get_font_description()) char_width = metrics.get_approximate_char_width() / pango.SCALE current_width = self.entry.get_width_chars() # We add 4 pixels to the width, because of the icon borders icon_width = VALIDATION_ICON_WIDTH + 4 self.entry.set_width_chars(current_width + int(icon_width / char_width))