Commits

anatoly techtonik committed ddfb068

FilePanel: Make sure label background stretches up to column width.

Comments (0)

Files changed (1)

         
         self.height = height  # in characters
         self.width = width
+        self.colwidth = width-2  # -borders
 
         # --- graphical state ---
 
         return (idx >= self.offset and idx < self.offset + self.height)
 
     def add_entry(self, name):
-        label = pyglet.text.Label(name, font_name=font_family, anchor_y='top',
+        if len(name) < self.colwidth:
+            label_text = name + ' '*(self.colwidth-len(name))
+        else:
+            label_text = name[:self.colwidth]
+        label = pyglet.text.Label(label_text, font_name=font_family, anchor_y='top',
                                   color=palette.foreground)
         label.set_style('background_color', palette.background)
         idx = len(self.items)  # index that will be assigned to the new entry