# Buggy code
def draw(self):
    self.drawer.clear(self.background or self.bar.background)

    offset = 0
    for i, g in enumerate(self.groups):
        is_block = self.highlight_method == "block"
        is_line = self.highlight_method == "line"
        if not is_line:
            highlight_color = None

        bw = self.box_width([g])

        if self.group_has_urgent(g) and self.urgent_alert_method == "text":
            text_color = self.urgent_text
        elif g.windows:
            text_color = self.active
        else:
            text_color = self.inactive

        if g.screen:
            if self.highlight_method == "text":
                border = self.bar.background
                text_color = self.this_current_screen_border
            else:
                if self.bar.screen.group.name == g.name:
                    if self.qtile.currentScreen == self.bar.screen:
                        border = self.this_current_screen_border
                        highlight_color = self.highlight_color
                    else:
                        border = self.this_screen_border
                        highlight_color = self.bar.background
                else:
                    border = self.other_screen_border
                    highlight_color = self.bar.background
        elif self.group_has_urgent(g) and self.urgent_alert_method in (
            "border",
            "block",
            "line",
        ):
            border = self.urgent_border
            highlight_color = self.bar.background
            if self.urgent_alert_method == "block":
                is_block = True
            elif self.urgent_alert_method == "line":
                is_line = True
        else:
            border = self.background or self.bar.background
            highlight_color = self.bar.background

        self.drawbox(
            self.margin_x + offset,
            g.name,
            border,
            text_color,
            highlight_color,
            self.line_thickness,
            self.rounded,
            is_block,
            bw - self.margin_x * 2 - self.padding_x * 2,
            is_line,
        )
        offset += bw
    self.drawer.draw(offsetx=self.offset, width=self.width)


# Traceback (UnboundLocalError)
Traceback (most recent call last):
File "/usr/lib64/python3.4/asyncio/events.py", line 120, in _run
self._callback(*self._args)
File "/usr/lib64/python3.4/site-packages/libqtile/manager.py", line 1156, in f
func(*args)
File "/usr/lib64/python3.4/site-packages/libqtile/bar.py", line 288, in _actual_draw
i.draw()
File "/usr/lib64/python3.4/site-packages/libqtile/widget/groupbox.py", line 318, in draw
highlight_color,
UnboundLocalError: local variable 'highlight_color' referenced before assignment

# Fixed code
def draw(self):
    self.drawer.clear(self.background or self.bar.background)

    offset = 0
    for i, g in enumerate(self.groups):
        to_highlight = False
        is_block = self.highlight_method == "block"
        is_line = self.highlight_method == "line"

        bw = self.box_width([g])

        if self.group_has_urgent(g) and self.urgent_alert_method == "text":
            text_color = self.urgent_text
        elif g.windows:
            text_color = self.active
        else:
            text_color = self.inactive

        if g.screen:
            if self.highlight_method == "text":
                border = self.bar.background
                text_color = self.this_current_screen_border
            else:
                if self.bar.screen.group.name == g.name:
                    if self.qtile.currentScreen == self.bar.screen:
                        border = self.this_current_screen_border
                        to_highlight = True
                    else:
                        border = self.this_screen_border
                else:
                    border = self.other_screen_border
        elif self.group_has_urgent(g) and self.urgent_alert_method in (
            "border",
            "block",
            "line",
        ):
            border = self.urgent_border
            if self.urgent_alert_method == "block":
                is_block = True
            elif self.urgent_alert_method == "line":
                is_line = True
        else:
            border = self.background or self.bar.background

        self.drawbox(
            self.margin_x + offset,
            g.name,
            border,
            text_color,
            width=bw - self.margin_x * 2 - self.padding_x * 2,
            rounded=self.rounded,
            block=is_block,
            line=is_line,
            highlighted=to_highlight,
        )
        offset += bw
    self.drawer.draw(offsetx=self.offset, width=self.width)