We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
WidgetBox doesn't support padding
### The issue:

The WidgetBox widget doesn't support the padding attribute. 

Right Now I can use padding inside children widgets to space them.
But the `text_closed` and `text_open`can't be padded

It would be nice to have a `spacing` and a `padding` attribute
the spacing attribute could be used to space the widgets inside the widgetBox and padding attribute could be used for padding `text_open` and `text_closed`

### Required:

- [X] I have searched past issues to see if this bug has already been reported.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libqtile/widget/widgetbox.py`
Content:
```
1 # Copyright (c) 2020 elParaguayo
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20 from __future__ import annotations
21 
22 from typing import TYPE_CHECKING
23 
24 from libqtile import bar
25 from libqtile.command.base import expose_command
26 from libqtile.log_utils import logger
27 from libqtile.widget import Systray, base
28 
29 if TYPE_CHECKING:
30     from typing import Any
31 
32 
33 class WidgetBox(base._Widget):
34     """A widget to declutter your bar.
35 
36     WidgetBox is a widget that hides widgets by default but shows them when
37     the box is opened.
38 
39     Widgets that are hidden will still update etc. as if they were on the main
40     bar.
41 
42     Button clicks are passed to widgets when they are visible so callbacks will
43     work.
44 
45     Widgets in the box also remain accessible via command interfaces.
46 
47     Widgets can only be added to the box via the configuration file. The widget
48     is configured by adding widgets to the "widgets" parameter as follows::
49 
50         widget.WidgetBox(widgets=[
51             widget.TextBox(text="This widget is in the box"),
52             widget.Memory()
53             ]
54         ),
55     """
56 
57     orientations = base.ORIENTATION_HORIZONTAL
58     defaults: list[tuple[str, Any, str]] = [
59         ("font", "sans", "Text font"),
60         ("fontsize", None, "Font pixel size. Calculated if None."),
61         ("fontshadow", None, "font shadow color, default is None(no shadow)"),
62         ("foreground", "#ffffff", "Foreground colour."),
63         (
64             "close_button_location",
65             "left",
66             "Location of close button when box open ('left' or 'right')",
67         ),
68         ("text_closed", "[<]", "Text when box is closed"),
69         ("text_open", "[>]", "Text when box is open"),
70         ("widgets", list(), "A list of widgets to include in the box"),
71         ("start_opened", False, "Spawn the box opened"),
72     ]
73 
74     def __init__(self, _widgets: list[base._Widget] | None = None, **config):
75         base._Widget.__init__(self, bar.CALCULATED, **config)
76         self.add_defaults(WidgetBox.defaults)
77         self.box_is_open = False
78         self.add_callbacks({"Button1": self.toggle})
79 
80         if _widgets:
81             logger.warning(
82                 "The use of a positional argument in WidgetBox is deprecated. "
83                 "Please update your config to use widgets=[...]."
84             )
85             self.widgets = _widgets
86 
87         self.close_button_location: str
88         if self.close_button_location not in ["left", "right"]:
89             val = self.close_button_location
90             logger.warning("Invalid value for 'close_button_location': %s", val)
91             self.close_button_location = "left"
92 
93     def _configure(self, qtile, bar):
94         base._Widget._configure(self, qtile, bar)
95 
96         self.layout = self.drawer.textlayout(
97             self.text_open if self.box_is_open else self.text_closed,
98             self.foreground,
99             self.font,
100             self.fontsize,
101             self.fontshadow,
102             markup=False,
103         )
104 
105         if self.configured:
106             return
107 
108         for idx, w in enumerate(self.widgets):
109             if w.configured:
110                 w = w.create_mirror()
111                 self.widgets[idx] = w
112             self.qtile.register_widget(w)
113             w._configure(self.qtile, self.bar)
114             w.offsety = self.bar.border_width[0]
115 
116             # In case the widget is mirrored, we need to draw it once so the
117             # mirror can copy the surface but draw it off screen
118             w.offsetx = self.bar.width
119             self.qtile.call_soon(w.draw)
120 
121             # Setting the configured flag for widgets was moved to Bar._configure so we need to
122             # set it here.
123             w.configured = True
124 
125         # Disable drawing of the widget's contents
126         for w in self.widgets:
127             w.drawer.disable()
128 
129         # We're being cautious: `box_is_open` should never be True here...
130         if self.start_opened and not self.box_is_open:
131             self.qtile.call_soon(self.toggle)
132 
133     def calculate_length(self):
134         return self.layout.width
135 
136     def set_box_label(self):
137         self.layout.text = self.text_open if self.box_is_open else self.text_closed
138 
139     def toggle_widgets(self):
140         for widget in self.widgets:
141             try:
142                 self.bar.widgets.remove(widget)
143                 # Override drawer.drawer with a no-op
144                 widget.drawer.disable()
145 
146                 # Systray widget needs some additional steps to hide as the icons
147                 # are separate _Window instances.
148                 # Systray unhides icons when it draws so we only need to hide them.
149                 if isinstance(widget, Systray):
150                     for icon in widget.tray_icons:
151                         icon.hide()
152 
153             except ValueError:
154                 continue
155 
156         index = self.bar.widgets.index(self)
157 
158         if self.close_button_location == "left":
159             index += 1
160 
161         if self.box_is_open:
162             # Need to reverse list as widgets get added in front of eachother.
163             for widget in self.widgets[::-1]:
164                 # enable drawing again
165                 widget.drawer.enable()
166                 self.bar.widgets.insert(index, widget)
167 
168     def draw(self):
169         self.drawer.clear(self.background or self.bar.background)
170 
171         self.layout.draw(0, int(self.bar.height / 2.0 - self.layout.height / 2.0) + 1)
172 
173         self.drawer.draw(offsetx=self.offsetx, offsety=self.offsety, width=self.width)
174 
175     @expose_command()
176     def toggle(self):
177         """Toggle box state"""
178         self.box_is_open = not self.box_is_open
179         self.toggle_widgets()
180         self.set_box_label()
181         self.bar.draw()
182
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/libqtile/widget/widgetbox.py b/libqtile/widget/widgetbox.py
--- a/libqtile/widget/widgetbox.py
+++ b/libqtile/widget/widgetbox.py
@@ -21,16 +21,16 @@
 
 from typing import TYPE_CHECKING
 
-from libqtile import bar
 from libqtile.command.base import expose_command
 from libqtile.log_utils import logger
+from libqtile.pangocffi import markup_escape_text
 from libqtile.widget import Systray, base
 
 if TYPE_CHECKING:
     from typing import Any
 
 
-class WidgetBox(base._Widget):
+class WidgetBox(base._TextBox):
     """A widget to declutter your bar.
 
     WidgetBox is a widget that hides widgets by default but shows them when
@@ -56,10 +56,6 @@
 
     orientations = base.ORIENTATION_HORIZONTAL
     defaults: list[tuple[str, Any, str]] = [
-        ("font", "sans", "Text font"),
-        ("fontsize", None, "Font pixel size. Calculated if None."),
-        ("fontshadow", None, "font shadow color, default is None(no shadow)"),
-        ("foreground", "#ffffff", "Foreground colour."),
         (
             "close_button_location",
             "left",
@@ -72,7 +68,7 @@
     ]
 
     def __init__(self, _widgets: list[base._Widget] | None = None, **config):
-        base._Widget.__init__(self, bar.CALCULATED, **config)
+        base._TextBox.__init__(self, **config)
         self.add_defaults(WidgetBox.defaults)
         self.box_is_open = False
         self.add_callbacks({"Button1": self.toggle})
@@ -91,16 +87,9 @@
             self.close_button_location = "left"
 
     def _configure(self, qtile, bar):
-        base._Widget._configure(self, qtile, bar)
+        base._TextBox._configure(self, qtile, bar)
 
-        self.layout = self.drawer.textlayout(
-            self.text_open if self.box_is_open else self.text_closed,
-            self.foreground,
-            self.font,
-            self.fontsize,
-            self.fontshadow,
-            markup=False,
-        )
+        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)
 
         if self.configured:
             return
@@ -130,11 +119,8 @@
         if self.start_opened and not self.box_is_open:
             self.qtile.call_soon(self.toggle)
 
-    def calculate_length(self):
-        return self.layout.width
-
     def set_box_label(self):
-        self.layout.text = self.text_open if self.box_is_open else self.text_closed
+        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)
 
     def toggle_widgets(self):
         for widget in self.widgets:
@@ -165,13 +151,6 @@
                 widget.drawer.enable()
                 self.bar.widgets.insert(index, widget)
 
-    def draw(self):
-        self.drawer.clear(self.background or self.bar.background)
-
-        self.layout.draw(0, int(self.bar.height / 2.0 - self.layout.height / 2.0) + 1)
-
-        self.drawer.draw(offsetx=self.offsetx, offsety=self.offsety, width=self.width)
-
     @expose_command()
     def toggle(self):
         """Toggle box state"""

{"golden_diff": "diff --git a/libqtile/widget/widgetbox.py b/libqtile/widget/widgetbox.py\n--- a/libqtile/widget/widgetbox.py\n+++ b/libqtile/widget/widgetbox.py\n@@ -21,16 +21,16 @@\n \n from typing import TYPE_CHECKING\n \n-from libqtile import bar\n from libqtile.command.base import expose_command\n from libqtile.log_utils import logger\n+from libqtile.pangocffi import markup_escape_text\n from libqtile.widget import Systray, base\n \n if TYPE_CHECKING:\n     from typing import Any\n \n \n-class WidgetBox(base._Widget):\n+class WidgetBox(base._TextBox):\n     \"\"\"A widget to declutter your bar.\n \n     WidgetBox is a widget that hides widgets by default but shows them when\n@@ -56,10 +56,6 @@\n \n     orientations = base.ORIENTATION_HORIZONTAL\n     defaults: list[tuple[str, Any, str]] = [\n-        (\"font\", \"sans\", \"Text font\"),\n-        (\"fontsize\", None, \"Font pixel size. Calculated if None.\"),\n-        (\"fontshadow\", None, \"font shadow color, default is None(no shadow)\"),\n-        (\"foreground\", \"#ffffff\", \"Foreground colour.\"),\n         (\n             \"close_button_location\",\n             \"left\",\n@@ -72,7 +68,7 @@\n     ]\n \n     def __init__(self, _widgets: list[base._Widget] | None = None, **config):\n-        base._Widget.__init__(self, bar.CALCULATED, **config)\n+        base._TextBox.__init__(self, **config)\n         self.add_defaults(WidgetBox.defaults)\n         self.box_is_open = False\n         self.add_callbacks({\"Button1\": self.toggle})\n@@ -91,16 +87,9 @@\n             self.close_button_location = \"left\"\n \n     def _configure(self, qtile, bar):\n-        base._Widget._configure(self, qtile, bar)\n+        base._TextBox._configure(self, qtile, bar)\n \n-        self.layout = self.drawer.textlayout(\n-            self.text_open if self.box_is_open else self.text_closed,\n-            self.foreground,\n-            self.font,\n-            self.fontsize,\n-            self.fontshadow,\n-            markup=False,\n-        )\n+        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)\n \n         if self.configured:\n             return\n@@ -130,11 +119,8 @@\n         if self.start_opened and not self.box_is_open:\n             self.qtile.call_soon(self.toggle)\n \n-    def calculate_length(self):\n-        return self.layout.width\n-\n     def set_box_label(self):\n-        self.layout.text = self.text_open if self.box_is_open else self.text_closed\n+        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)\n \n     def toggle_widgets(self):\n         for widget in self.widgets:\n@@ -165,13 +151,6 @@\n                 widget.drawer.enable()\n                 self.bar.widgets.insert(index, widget)\n \n-    def draw(self):\n-        self.drawer.clear(self.background or self.bar.background)\n-\n-        self.layout.draw(0, int(self.bar.height / 2.0 - self.layout.height / 2.0) + 1)\n-\n-        self.drawer.draw(offsetx=self.offsetx, offsety=self.offsety, width=self.width)\n-\n     @expose_command()\n     def toggle(self):\n         \"\"\"Toggle box state\"\"\"\n", "issue": "WidgetBox doesn't support padding\n### The issue:\n\nThe WidgetBox widget doesn't support the padding attribute. \r\n\r\nRight Now I can use padding inside children widgets to space them.\r\nBut the `text_closed` and `text_open`can't be padded\r\n\r\nIt would be nice to have a `spacing` and a `padding` attribute\r\nthe spacing attribute could be used to space the widgets inside the widgetBox and padding attribute could be used for padding `text_open` and `text_closed`\n\n### Required:\n\n- [X] I have searched past issues to see if this bug has already been reported.\n", "before_files": [{"content": "# Copyright (c) 2020 elParaguayo\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom libqtile import bar\nfrom libqtile.command.base import expose_command\nfrom libqtile.log_utils import logger\nfrom libqtile.widget import Systray, base\n\nif TYPE_CHECKING:\n    from typing import Any\n\n\nclass WidgetBox(base._Widget):\n    \"\"\"A widget to declutter your bar.\n\n    WidgetBox is a widget that hides widgets by default but shows them when\n    the box is opened.\n\n    Widgets that are hidden will still update etc. as if they were on the main\n    bar.\n\n    Button clicks are passed to widgets when they are visible so callbacks will\n    work.\n\n    Widgets in the box also remain accessible via command interfaces.\n\n    Widgets can only be added to the box via the configuration file. The widget\n    is configured by adding widgets to the \"widgets\" parameter as follows::\n\n        widget.WidgetBox(widgets=[\n            widget.TextBox(text=\"This widget is in the box\"),\n            widget.Memory()\n            ]\n        ),\n    \"\"\"\n\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults: list[tuple[str, Any, str]] = [\n        (\"font\", \"sans\", \"Text font\"),\n        (\"fontsize\", None, \"Font pixel size. Calculated if None.\"),\n        (\"fontshadow\", None, \"font shadow color, default is None(no shadow)\"),\n        (\"foreground\", \"#ffffff\", \"Foreground colour.\"),\n        (\n            \"close_button_location\",\n            \"left\",\n            \"Location of close button when box open ('left' or 'right')\",\n        ),\n        (\"text_closed\", \"[<]\", \"Text when box is closed\"),\n        (\"text_open\", \"[>]\", \"Text when box is open\"),\n        (\"widgets\", list(), \"A list of widgets to include in the box\"),\n        (\"start_opened\", False, \"Spawn the box opened\"),\n    ]\n\n    def __init__(self, _widgets: list[base._Widget] | None = None, **config):\n        base._Widget.__init__(self, bar.CALCULATED, **config)\n        self.add_defaults(WidgetBox.defaults)\n        self.box_is_open = False\n        self.add_callbacks({\"Button1\": self.toggle})\n\n        if _widgets:\n            logger.warning(\n                \"The use of a positional argument in WidgetBox is deprecated. \"\n                \"Please update your config to use widgets=[...].\"\n            )\n            self.widgets = _widgets\n\n        self.close_button_location: str\n        if self.close_button_location not in [\"left\", \"right\"]:\n            val = self.close_button_location\n            logger.warning(\"Invalid value for 'close_button_location': %s\", val)\n            self.close_button_location = \"left\"\n\n    def _configure(self, qtile, bar):\n        base._Widget._configure(self, qtile, bar)\n\n        self.layout = self.drawer.textlayout(\n            self.text_open if self.box_is_open else self.text_closed,\n            self.foreground,\n            self.font,\n            self.fontsize,\n            self.fontshadow,\n            markup=False,\n        )\n\n        if self.configured:\n            return\n\n        for idx, w in enumerate(self.widgets):\n            if w.configured:\n                w = w.create_mirror()\n                self.widgets[idx] = w\n            self.qtile.register_widget(w)\n            w._configure(self.qtile, self.bar)\n            w.offsety = self.bar.border_width[0]\n\n            # In case the widget is mirrored, we need to draw it once so the\n            # mirror can copy the surface but draw it off screen\n            w.offsetx = self.bar.width\n            self.qtile.call_soon(w.draw)\n\n            # Setting the configured flag for widgets was moved to Bar._configure so we need to\n            # set it here.\n            w.configured = True\n\n        # Disable drawing of the widget's contents\n        for w in self.widgets:\n            w.drawer.disable()\n\n        # We're being cautious: `box_is_open` should never be True here...\n        if self.start_opened and not self.box_is_open:\n            self.qtile.call_soon(self.toggle)\n\n    def calculate_length(self):\n        return self.layout.width\n\n    def set_box_label(self):\n        self.layout.text = self.text_open if self.box_is_open else self.text_closed\n\n    def toggle_widgets(self):\n        for widget in self.widgets:\n            try:\n                self.bar.widgets.remove(widget)\n                # Override drawer.drawer with a no-op\n                widget.drawer.disable()\n\n                # Systray widget needs some additional steps to hide as the icons\n                # are separate _Window instances.\n                # Systray unhides icons when it draws so we only need to hide them.\n                if isinstance(widget, Systray):\n                    for icon in widget.tray_icons:\n                        icon.hide()\n\n            except ValueError:\n                continue\n\n        index = self.bar.widgets.index(self)\n\n        if self.close_button_location == \"left\":\n            index += 1\n\n        if self.box_is_open:\n            # Need to reverse list as widgets get added in front of eachother.\n            for widget in self.widgets[::-1]:\n                # enable drawing again\n                widget.drawer.enable()\n                self.bar.widgets.insert(index, widget)\n\n    def draw(self):\n        self.drawer.clear(self.background or self.bar.background)\n\n        self.layout.draw(0, int(self.bar.height / 2.0 - self.layout.height / 2.0) + 1)\n\n        self.drawer.draw(offsetx=self.offsetx, offsety=self.offsety, width=self.width)\n\n    @expose_command()\n    def toggle(self):\n        \"\"\"Toggle box state\"\"\"\n        self.box_is_open = not self.box_is_open\n        self.toggle_widgets()\n        self.set_box_label()\n        self.bar.draw()\n", "path": "libqtile/widget/widgetbox.py"}], "after_files": [{"content": "# Copyright (c) 2020 elParaguayo\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom libqtile.command.base import expose_command\nfrom libqtile.log_utils import logger\nfrom libqtile.pangocffi import markup_escape_text\nfrom libqtile.widget import Systray, base\n\nif TYPE_CHECKING:\n    from typing import Any\n\n\nclass WidgetBox(base._TextBox):\n    \"\"\"A widget to declutter your bar.\n\n    WidgetBox is a widget that hides widgets by default but shows them when\n    the box is opened.\n\n    Widgets that are hidden will still update etc. as if they were on the main\n    bar.\n\n    Button clicks are passed to widgets when they are visible so callbacks will\n    work.\n\n    Widgets in the box also remain accessible via command interfaces.\n\n    Widgets can only be added to the box via the configuration file. The widget\n    is configured by adding widgets to the \"widgets\" parameter as follows::\n\n        widget.WidgetBox(widgets=[\n            widget.TextBox(text=\"This widget is in the box\"),\n            widget.Memory()\n            ]\n        ),\n    \"\"\"\n\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults: list[tuple[str, Any, str]] = [\n        (\n            \"close_button_location\",\n            \"left\",\n            \"Location of close button when box open ('left' or 'right')\",\n        ),\n        (\"text_closed\", \"[<]\", \"Text when box is closed\"),\n        (\"text_open\", \"[>]\", \"Text when box is open\"),\n        (\"widgets\", list(), \"A list of widgets to include in the box\"),\n        (\"start_opened\", False, \"Spawn the box opened\"),\n    ]\n\n    def __init__(self, _widgets: list[base._Widget] | None = None, **config):\n        base._TextBox.__init__(self, **config)\n        self.add_defaults(WidgetBox.defaults)\n        self.box_is_open = False\n        self.add_callbacks({\"Button1\": self.toggle})\n\n        if _widgets:\n            logger.warning(\n                \"The use of a positional argument in WidgetBox is deprecated. \"\n                \"Please update your config to use widgets=[...].\"\n            )\n            self.widgets = _widgets\n\n        self.close_button_location: str\n        if self.close_button_location not in [\"left\", \"right\"]:\n            val = self.close_button_location\n            logger.warning(\"Invalid value for 'close_button_location': %s\", val)\n            self.close_button_location = \"left\"\n\n    def _configure(self, qtile, bar):\n        base._TextBox._configure(self, qtile, bar)\n\n        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)\n\n        if self.configured:\n            return\n\n        for idx, w in enumerate(self.widgets):\n            if w.configured:\n                w = w.create_mirror()\n                self.widgets[idx] = w\n            self.qtile.register_widget(w)\n            w._configure(self.qtile, self.bar)\n            w.offsety = self.bar.border_width[0]\n\n            # In case the widget is mirrored, we need to draw it once so the\n            # mirror can copy the surface but draw it off screen\n            w.offsetx = self.bar.width\n            self.qtile.call_soon(w.draw)\n\n            # Setting the configured flag for widgets was moved to Bar._configure so we need to\n            # set it here.\n            w.configured = True\n\n        # Disable drawing of the widget's contents\n        for w in self.widgets:\n            w.drawer.disable()\n\n        # We're being cautious: `box_is_open` should never be True here...\n        if self.start_opened and not self.box_is_open:\n            self.qtile.call_soon(self.toggle)\n\n    def set_box_label(self):\n        self.text = markup_escape_text(self.text_open if self.box_is_open else self.text_closed)\n\n    def toggle_widgets(self):\n        for widget in self.widgets:\n            try:\n                self.bar.widgets.remove(widget)\n                # Override drawer.drawer with a no-op\n                widget.drawer.disable()\n\n                # Systray widget needs some additional steps to hide as the icons\n                # are separate _Window instances.\n                # Systray unhides icons when it draws so we only need to hide them.\n                if isinstance(widget, Systray):\n                    for icon in widget.tray_icons:\n                        icon.hide()\n\n            except ValueError:\n                continue\n\n        index = self.bar.widgets.index(self)\n\n        if self.close_button_location == \"left\":\n            index += 1\n\n        if self.box_is_open:\n            # Need to reverse list as widgets get added in front of eachother.\n            for widget in self.widgets[::-1]:\n                # enable drawing again\n                widget.drawer.enable()\n                self.bar.widgets.insert(index, widget)\n\n    @expose_command()\n    def toggle(self):\n        \"\"\"Toggle box state\"\"\"\n        self.box_is_open = not self.box_is_open\n        self.toggle_widgets()\n        self.set_box_label()\n        self.bar.draw()\n", "path": "libqtile/widget/widgetbox.py"}]}