Skip to content

Commit

Permalink
Renamed no_height to has_height
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 5, 2018
1 parent ff76755 commit ea6b564
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions panel/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@
from .viewable import Reactive, Viewable


def no_height(layout):
def has_height(obj):
"""
Whether the supplied layout has no height
Whether the supplied layout has a height
"""
if isinstance(layout, BkBox):
for child in layout.children:
if isinstance(child, BkBox):
if no_height(child):
return False

height = getattr(child, 'height', None)
if height is not None:
return False
elif isinstance(BkWidgetBox):
return False
elif getattr(child, 'height', False) is None:
return False
return True
if isinstance(obj, BkBox):
for child in obj.children:
cond = has_height(child)
if cond:
return True
elif isinstance(obj, BkWidgetBox):
return True
elif getattr(obj, 'height', None) is not None:
return True
return False


class Panel(Reactive):
Expand Down Expand Up @@ -138,7 +134,7 @@ def _get_model(self, doc, root=None, parent=None, comm=None):
objects = self._get_objects(model, [], doc, root, comm)

# HACK ALERT: Insert Spacer if last item in Column has no height
if (isinstance(self, Column) and objects and no_height(objects[-1])):
if (isinstance(self, Column) and objects and not has_height(objects[-1])):
objects.append(BkSpacer(height=50))

props = dict(self._init_properties(), objects=objects)
Expand Down

0 comments on commit ea6b564

Please sign in to comment.