Box Layout¶
morphui.uix.boxlayout
¶
MorphSimpleBoxLayout(*widgets, **kwargs)
¶
Bases: MorphIdentificationBehavior, MorphAutoSizingBehavior, BoxLayout
A simple BoxLayout that supports auto-sizing and identification.
This class combines the functionality of Kivy's BoxLayout with MorphUI's declarative behaviors to enhance its capabilities. It allows for adding child widgets in a declarative manner while maintaining the standard behavior and features of a BoxLayout.
Examples:
from morphui.app import MorphApp
from morphui.uix.boxlayout import MorphSimpleBoxLayout
from morphui.uix.label import MorphLabel
class MyApp(MorphApp):
def build(self):
return MorphSimpleBoxLayout(
MorphLabel(
identity="label1",
text="Label 1",),
MorphLabel(
identity="label2",
text="Label 2",),
orientation='vertical',
padding=50,
spacing=15,)
MyApp().run()
default_config = dict(orientation='horizontal')
class-attribute
instance-attribute
¶
Initialize the MorphSimpleBoxLayout with the provided configuration.
MorphBoxLayout(*widgets, **kwargs)
¶
Bases: MorphDeclarativeBehavior, MorphColorThemeBehavior, MorphSurfaceLayerBehavior, MorphAutoSizingBehavior, BoxLayout
A BoxLayout that supports declarative child widgets via
:class:~morphui.uix.behaviors.MorphDeclarativeBehavior.
This class combines the functionality of Kivy's BoxLayout with
several MorphUI behaviors to enhance its capabilities:
- MorphDeclarativeBehavior: Enables declarative property binding.
- MorphColorThemeBehavior: Integrates color theming capabilities.
- MorphSurfaceLayerBehavior: Provides surface styling options.
- MorphAutoSizingBehavior: Enables automatic sizing based on content.
Examples:
from morphui.app import MorphApp
from morphui.uix.boxlayout import MorphBoxLayout
from morphui.uix.label import MorphLabel
class MyApp(MorphApp):
def build(self):
return MorphBoxLayout(
MorphLabel(
identity="label1",
text="Label 1",
theme_color_bindings={
'normal_surface_color': 'surface_container_color',
'normal_content_color': 'content_surface_color',
'normal_border_color': 'outline_color',},
radius=[5, 25, 5, 25],),
MorphLabel(
identity="label2",
text="Label 2",
theme_color_bindings={
'normal_surface_color': 'surface_container_low_color',
'normal_content_color': 'content_surface_color',
'normal_border_color': 'outline_variant_color',},
radius=[25, 5, 25, 5],),
theme_style='surface',
orientation='vertical',
padding=50,
spacing=15,)
MyApp().run()
default_config = dict(orientation='horizontal', theme_color_bindings=(dict(normal_surface_color='transparent_color')))
class-attribute
instance-attribute
¶
Initialize the MorphBoxLayout with the provided configuration.
MorphElevationBoxLayout(*widgets, **kwargs)
¶
Bases: MorphDeclarativeBehavior, MorphColorThemeBehavior, MorphSurfaceLayerBehavior, MorphElevationBehavior, MorphAutoSizingBehavior, BoxLayout
A BoxLayout that includes elevation behavior for shadow effects.
This class extends the standard BoxLayout by incorporating elevation capabilities through the MorphElevationBehavior, allowing for shadow effects and depth representation in the UI.
Examples:
from morphui.app import MorphApp
from morphui.uix.boxlayout import MorphElevationBoxLayout
from morphui.uix.label import MorphLabel
class MyApp(MorphApp):
def build(self):
return MorphElevationBoxLayout(
MorphLabel(
identity="label1",
text="Elevated Label 1",
theme_color_bindings={
'normal_surface_color': 'surface_container_color',
'normal_content_color': 'content_surface_color',
'normal_border_color': 'outline_color',},
radius=[5, 25, 5, 25],),
MorphLabel(
identity="label2",
text="Elevated Label 2",
theme_color_bindings={
'normal_surface_color': 'surface_container_low_color',
'normal_content_color': 'content_surface_color',
'normal_border_color': 'outline_variant_color',},
radius=[25, 5, 25, 5],),
theme_style='surface',
elevation=4,
orientation='vertical',
padding=50,
spacing=15,)
return self.root
if __name__ == '__main__':
MyApp().run()
default_config = dict(orientation='horizontal', theme_color_bindings=(dict(normal_surface_color='surface_container_color')), elevation=2)
class-attribute
instance-attribute
¶
Initialize the MorphElevationBoxLayout with the provided configuration.