Exemplo n.º 1
0
    def adjust_widths(self):
        f = Font()

        max_name_len = f.measure(self.heading("#0")["text"])
        max_dir_len = f.measure(self.heading("directory")["text"])

        for d in self.descs:
            l = f.measure(d.name)
            if l > max_name_len:
                max_name_len = l

            l = f.measure(d.directory)
            if l > max_dir_len:
                max_dir_len = l

            self.column("#0", width=max_name_len)
            self.column("directory", width=max_dir_len)
Exemplo n.º 2
0
    def adjust_widths(self, hidden=False):
        f = Font()

        for col_idx, col in enumerate(("#0", ) + self.cget("columns")):
            if not col in self.auto_columns:
                continue

            col_max_len = f.measure(self.heading(col)["text"])

            max_cell_width = self.get_max_width("", col_idx, f, hidden)

            if col == "#0":
                max_cell_width += self.zero_column_extra_width

            cur_width = self.column(col, "width")
            max_width = max(col_max_len, max_cell_width)

            if cur_width < max_width or not self.column(col, "stretch"):
                self.column(col, width=max_width)