Skip to content

Commit

Permalink
fix ipywidgets>=8 display
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Sep 3, 2022
1 parent 05e3d32 commit 8fb3d91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,18 @@
],
"source": [
"# 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",
" with tqdm(total=total, leave=False) as t:\n",
" print(t)\n",
" t.update()\n",
" print(t)\n",
" assert total != 1 or (False, None) == (\n",
" getattr(t.container, \"visible\", False), getattr(t.container, \"_ipython_display_\", None)\n",
" )"
" assert total != 1 or is_hidden(t.container)"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions tqdm/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def display(self, msg=None, pos=None,
self.container.close()
except AttributeError:
self.container.visible = False
self.container.layout.visibility = 'hidden' # IPYW>=8

if check_delay and self.delay > 0 and not self.displayed:
display(self.container)
Expand Down

0 comments on commit 8fb3d91

Please sign in to comment.