mirror of https://github.com/tqdm/tqdm.git
fix ipywidgets>=8 display
This commit is contained in:
parent
05e3d32a5f
commit
8fb3d91f56
|
@ -312,15 +312,18 @@
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"# NBVAL_TEST_NAME: leave\n",
|
"# NBVAL_TEST_NAME: leave\n",
|
||||||
"assert (False, None) != (getattr(t.container, \"visible\", False), getattr(t.container, \"_ipython_display_\", None))\n",
|
"def is_hidden(widget):\n",
|
||||||
|
" return ('hidden', False, None) == (\n",
|
||||||
|
" getattr(getattr(widget, \"layout\", None), \"visibility\", 'visible'), # ipyw>=8\n",
|
||||||
|
" getattr(widget, \"visible\", False), getattr(widget, \"_ipython_display_\", None)) # ipyw<8\n",
|
||||||
|
"\n",
|
||||||
|
"assert not is_hidden(t.container)\n",
|
||||||
"for total in (1, 9):\n",
|
"for total in (1, 9):\n",
|
||||||
" with tqdm(total=total, leave=False) as t:\n",
|
" with tqdm(total=total, leave=False) as t:\n",
|
||||||
" print(t)\n",
|
" print(t)\n",
|
||||||
" t.update()\n",
|
" t.update()\n",
|
||||||
" print(t)\n",
|
" print(t)\n",
|
||||||
" assert total != 1 or (False, None) == (\n",
|
" assert total != 1 or is_hidden(t.container)"
|
||||||
" getattr(t.container, \"visible\", False), getattr(t.container, \"_ipython_display_\", None)\n",
|
|
||||||
" )"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,6 +192,7 @@ class tqdm_notebook(std_tqdm):
|
||||||
self.container.close()
|
self.container.close()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.container.visible = False
|
self.container.visible = False
|
||||||
|
self.container.layout.visibility = 'hidden' # IPYW>=8
|
||||||
|
|
||||||
if check_delay and self.delay > 0 and not self.displayed:
|
if check_delay and self.delay > 0 and not self.displayed:
|
||||||
display(self.container)
|
display(self.container)
|
||||||
|
|
Loading…
Reference in New Issue