Code Duplication    Length = 16-17 lines in 2 locations

doorstop/gui/main.py 1 location

@@ 125-141 (lines=17) @@
122
    return wrapped
123
124
125
class Listbox2(tk.Listbox):  # pragma: no cover (manual test), pylint: disable=R0901
126
127
    """Listbox class with automatic width adjustment."""
128
129
    def autowidth(self, maxwidth=250):
130
        """Resize the widget width to fit contents."""
131
        fnt = font.Font(font=self.cget("font"))
132
        pixels = 0
133
        for item in self.get(0, "end"):
134
            pixels = max(pixels, fnt.measure(item))
135
        # bump listbox size until all entries fit
136
        pixels = pixels + 10
137
        width = int(self.cget("width"))
138
        for shift in range(0, maxwidth + 1, 5):
139
            if self.winfo_reqwidth() >= pixels:
140
                break
141
            self.config(width=width + shift)
142
143
144
class Application(ttk.Frame):  # pragma: no cover (manual test), pylint: disable=R0901,R0902

doorstop/gui/widget.py 1 location

@@ 47-62 (lines=16) @@
44
# # Widget
45
46
47
class _Listbox2(tk.Listbox):
48
    """Listbox class with automatic width adjustment."""
49
50
    def autowidth(self, maxwidth=250):
51
        """Resize the widget width to fit contents."""
52
        fnt = font.Font(font=self.cget("font"))
53
        pixels = 0
54
        for item in self.get(0, "end"):
55
            pixels = max(pixels, fnt.measure(item))
56
        # bump listbox size until all entries fit
57
        pixels = pixels + 10
58
        width = int(self.cget("width"))
59
        for shift in range(0, maxwidth + 1, 5):
60
            if self.winfo_reqwidth() >= pixels:
61
                break
62
            self.config(width=width + shift)
63
64
65
def Button(parent, *args, **kwargs):