##// END OF EJS Templates
Added flexible box model align properties.
Added flexible box model align properties.

File last commit:

r14333:13b5a372
r14333:13b5a372
Show More
widget_container.py
148 lines | 5.0 KiB | text/x-python | PythonLexer
Jonathan Frederic
Cleaned up Python widget code.
r14283 """ContainerWidget class.
Represents a container that can be used to group other widgets.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Jonathan Frederic
More relative imports, Travis w/ Py3.3
r14308 from .widget import Widget
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 from IPython.utils.traitlets import Unicode, Bool
Jonathan Frederic
Add container widget
r14239
Jonathan Frederic
Cleaned up Python widget code.
r14283 #-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
Jonathan Frederic
Add container widget
r14239 class ContainerWidget(Widget):
Jonathan Frederic
Made registered model name look like other model names
r14275 target_name = Unicode('ContainerWidgetModel')
Jonathan Frederic
Add container widget
r14239 default_view_name = Unicode('ContainerView')
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268
Jonathan Frederic
Cleaned up Python widget code.
r14283 # Keys, all private and managed by helper methods. Flexible box model
# classes...
Jonathan Frederic
Added flexible box model align properties.
r14333 _keys = ['_vbox', '_hbox', '_align_start', '_align_end', '_align_center',
'_pack_start', '_pack_end', '_pack_center']
Jonathan Frederic
Flex box system improvements...
r14269 _hbox = Bool(False)
_vbox = Bool(False)
Jonathan Frederic
Added flexible box model align properties.
r14333 _align_start = Bool(False)
_align_end = Bool(False)
_align_center = Bool(False)
_pack_start = Bool(False)
_pack_end = Bool(False)
_pack_center = Bool(False)
Jonathan Frederic
Flex box system improvements...
r14269
def hbox(self, enabled=True):
Jonathan Frederic
Cleaned up Python widget code.
r14283 """Make this container an hbox. Automatically disables conflicting
features.
Parameters
----------
enabled: bool (optional)
Enabled or disable the hbox feature of the container, defaults to
True."""
Jonathan Frederic
Flex box system improvements...
r14269 self._hbox = enabled
if enabled:
self._vbox = False
def vbox(self, enabled=True):
Jonathan Frederic
Cleaned up Python widget code.
r14283 """Make this container an vbox. Automatically disables conflicting
features.
Parameters
----------
enabled: bool (optional)
Enabled or disable the vbox feature of the container, defaults to
True."""
Jonathan Frederic
Flex box system improvements...
r14269 self._vbox = enabled
if enabled:
self._hbox = False
Jonathan Frederic
Added flexible box model align properties.
r14333 def align_start(self, enabled=True):
Jonathan Frederic
Cleaned up Python widget code.
r14283 """Make the contents of this container align to the start of the axis.
Automatically disables conflicting alignments.
Parameters
----------
enabled: bool (optional)
Enabled or disable the start alignment of the container, defaults to
True."""
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_start = enabled
Jonathan Frederic
Flex box system improvements...
r14269 if enabled:
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_end = False
self._align_center = False
Jonathan Frederic
Flex box system improvements...
r14269
Jonathan Frederic
Added flexible box model align properties.
r14333 def align_end(self, enabled=True):
Jonathan Frederic
Cleaned up Python widget code.
r14283 """Make the contents of this container align to the end of the axis.
Automatically disables conflicting alignments.
Parameters
----------
enabled: bool (optional)
Enabled or disable the end alignment of the container, defaults to
True."""
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_end = enabled
Jonathan Frederic
Flex box system improvements...
r14269 if enabled:
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_start = False
self._align_center = False
Jonathan Frederic
Flex box system improvements...
r14269
Jonathan Frederic
Added flexible box model align properties.
r14333 def align_center(self, enabled=True):
Jonathan Frederic
Cleaned up Python widget code.
r14283 """Make the contents of this container align to the center of the axis.
Automatically disables conflicting alignments.
Parameters
----------
enabled: bool (optional)
Enabled or disable the center alignment of the container, defaults to
True."""
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_center = enabled
Jonathan Frederic
Flex box system improvements...
r14269 if enabled:
Jonathan Frederic
Added flexible box model align properties.
r14333 self._align_start = False
self._align_end = False
def pack_start(self, enabled=True):
"""Make the contents of this container pack to the start of the axis.
Automatically disables conflicting packings.
Parameters
----------
enabled: bool (optional)
Enabled or disable the start packing of the container, defaults to
True."""
self._pack_start = enabled
if enabled:
self._pack_end = False
self._pack_center = False
def pack_end(self, enabled=True):
"""Make the contents of this container pack to the end of the axis.
Automatically disables conflicting packings.
Parameters
----------
enabled: bool (optional)
Enabled or disable the end packing of the container, defaults to
True."""
self._pack_end = enabled
if enabled:
self._pack_start = False
self._pack_center = False
def pack_center(self, enabled=True):
"""Make the contents of this container pack to the center of the axis.
Automatically disables conflicting packings.
Parameters
----------
enabled: bool (optional)
Enabled or disable the center packing of the container, defaults to
True."""
self._pack_center = enabled
if enabled:
self._pack_start = False
self._pack_end = False