mirror of https://github.com/kivy/kivy.git
examples: Make important property more obvious
This commit is contained in:
parent
99d7d4d01d
commit
a4d93d65f6
|
@ -14,7 +14,7 @@ ActionBar:
|
|||
icon: 'atlas://data/images/defaulttheme/audio-volume-high'
|
||||
ActionButton:
|
||||
important: True
|
||||
text: 'Btn1'
|
||||
text: 'Important'
|
||||
ActionButton:
|
||||
text: 'Btn2'
|
||||
ActionButton:
|
||||
|
|
|
@ -58,36 +58,41 @@ if Config:
|
|||
|
||||
|
||||
class ActionBarException(Exception):
|
||||
'''ActionBarException class
|
||||
'''
|
||||
ActionBarException class
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
class ActionItem(object):
|
||||
'''ActionItem class, an abstract class for all ActionBar widgets. To create
|
||||
a custom widget for an ActionBar, inherit from this
|
||||
class. See module documentation for more information.
|
||||
'''
|
||||
ActionItem class, an abstract class for all ActionBar widgets. To create a
|
||||
custom widget for an ActionBar, inherit from this class. See module
|
||||
documentation for more information.
|
||||
'''
|
||||
|
||||
minimum_width = NumericProperty('90sp')
|
||||
'''Minimum Width required by an ActionItem.
|
||||
'''
|
||||
Minimum Width required by an ActionItem.
|
||||
|
||||
:attr:`minimum_width` is a :class:`~kivy.properties.NumericProperty` and
|
||||
defaults to '90sp'.
|
||||
:attr:`minimum_width` is a :class:`~kivy.properties.NumericProperty` and
|
||||
defaults to '90sp'.
|
||||
'''
|
||||
|
||||
def get_pack_width(self):
|
||||
return max(self.minimum_width, self.width)
|
||||
|
||||
pack_width = AliasProperty(get_pack_width, bind=('minimum_width', 'width'))
|
||||
'''(read-only) The actual width to use when packing the item. Equal to the
|
||||
greater of minimum_width and width.
|
||||
'''
|
||||
(read-only) The actual width to use when packing the item. Equal to the
|
||||
greater of minimum_width and width.
|
||||
|
||||
:attr:`pack_width` is an :class:`~kivy.properties.AliasProperty`.
|
||||
:attr:`pack_width` is an :class:`~kivy.properties.AliasProperty`.
|
||||
'''
|
||||
|
||||
important = BooleanProperty(False)
|
||||
'''Determines if an ActionItem is important or not. If an item is important
|
||||
'''
|
||||
Determines if an ActionItem is important or not. If an item is important
|
||||
and space is limited, this item will be displayed in preference to others.
|
||||
|
||||
:attr:`important` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
|
@ -95,42 +100,47 @@ class ActionItem(object):
|
|||
'''
|
||||
|
||||
inside_group = BooleanProperty(False)
|
||||
'''(internal) Determines if an ActionItem is displayed inside an
|
||||
ActionGroup or not.
|
||||
'''
|
||||
(internal) Determines if an ActionItem is displayed inside an
|
||||
ActionGroup or not.
|
||||
|
||||
:attr:`inside_group` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
:attr:`inside_group` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
'''
|
||||
|
||||
background_normal = StringProperty(
|
||||
'atlas://data/images/defaulttheme/action_item')
|
||||
'''Background image of the ActionItem used for the default graphical
|
||||
representation when the ActionItem is not pressed.
|
||||
'''
|
||||
Background image of the ActionItem used for the default graphical
|
||||
representation when the ActionItem is not pressed.
|
||||
|
||||
:attr:`background_normal` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_item'.
|
||||
:attr:`background_normal` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_item'.
|
||||
'''
|
||||
|
||||
background_down = StringProperty(
|
||||
'atlas://data/images/defaulttheme/action_item_down')
|
||||
'''Background image of the ActionItem used for default graphical
|
||||
representation when an ActionItem is pressed.
|
||||
'''
|
||||
Background image of the ActionItem used for default graphical
|
||||
representation when an ActionItem is pressed.
|
||||
|
||||
:attr:`background_down` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_item_down'.
|
||||
:attr:`background_down` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_item_down'.
|
||||
'''
|
||||
|
||||
mipmap = BooleanProperty(True)
|
||||
'''Defines whether the image/icon dispayed on top of the button uses a
|
||||
mipmap or not.
|
||||
'''
|
||||
Defines whether the image/icon dispayed on top of the button uses a
|
||||
mipmap or not.
|
||||
|
||||
:attr:`mipmap` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to `True`.
|
||||
:attr:`mipmap` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to `True`.
|
||||
'''
|
||||
|
||||
|
||||
class ActionButton(Button, ActionItem):
|
||||
'''ActionButton class, see module documentation for more information.
|
||||
'''
|
||||
ActionButton class, see module documentation for more information.
|
||||
|
||||
The text color, width and size_hint_x are set manually via the Kv language
|
||||
file. It covers a lot of cases: with/without an icon, with/without a group
|
||||
|
@ -148,7 +158,8 @@ class ActionButton(Button, ActionItem):
|
|||
'''
|
||||
|
||||
icon = StringProperty(None, allownone=True)
|
||||
'''Source image to use when the Button is part of the ActionBar. If the
|
||||
'''
|
||||
Source image to use when the Button is part of the ActionBar. If the
|
||||
Button is in a group, the text will be preferred.
|
||||
|
||||
:attr:`icon` is a :class:`~kivy.properties.StringProperty` and defaults
|
||||
|
@ -157,7 +168,8 @@ class ActionButton(Button, ActionItem):
|
|||
|
||||
|
||||
class ActionPrevious(BoxLayout, ActionItem):
|
||||
'''ActionPrevious class, see module documentation for more information.
|
||||
'''
|
||||
ActionPrevious class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
with_previous = BooleanProperty(True)
|
||||
|
@ -171,11 +183,12 @@ class ActionPrevious(BoxLayout, ActionItem):
|
|||
'''
|
||||
|
||||
app_icon = StringProperty(window_icon)
|
||||
'''Application icon for the ActionView.
|
||||
'''
|
||||
Application icon for the ActionView.
|
||||
|
||||
:attr:`app_icon` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to the window icon if set, otherwise
|
||||
'data/logo/kivy-icon-32.png'.
|
||||
:attr:`app_icon` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to the window icon if set, otherwise
|
||||
'data/logo/kivy-icon-32.png'.
|
||||
'''
|
||||
|
||||
app_icon_width = NumericProperty(0)
|
||||
|
@ -261,87 +274,100 @@ class ActionPrevious(BoxLayout, ActionItem):
|
|||
|
||||
|
||||
class ActionToggleButton(ActionItem, ToggleButton):
|
||||
'''ActionToggleButton class, see module documentation for more information.
|
||||
'''
|
||||
ActionToggleButton class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
icon = StringProperty(None, allownone=True)
|
||||
'''Source image to use when the Button is part of the ActionBar. If the
|
||||
'''
|
||||
Source image to use when the Button is part of the ActionBar. If the
|
||||
Button is in a group, the text will be preferred.
|
||||
'''
|
||||
|
||||
|
||||
class ActionLabel(ActionItem, Label):
|
||||
'''ActionLabel class, see module documentation for more information.
|
||||
'''
|
||||
ActionLabel class, see module documentation for more information.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
class ActionCheck(ActionItem, CheckBox):
|
||||
'''ActionCheck class, see module documentation for more information.
|
||||
'''
|
||||
ActionCheck class, see module documentation for more information.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
class ActionSeparator(ActionItem, Widget):
|
||||
'''ActionSeparator class, see module documentation for more information.
|
||||
'''
|
||||
ActionSeparator class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
background_image = StringProperty(
|
||||
'atlas://data/images/defaulttheme/separator')
|
||||
'''Background image for the separators default graphical representation.
|
||||
'''
|
||||
Background image for the separators default graphical representation.
|
||||
|
||||
:attr:`background_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/separator'.
|
||||
:attr:`background_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/separator'.
|
||||
'''
|
||||
|
||||
|
||||
class ActionDropDown(DropDown):
|
||||
'''ActionDropDown class, see module documentation for more information.
|
||||
'''
|
||||
ActionDropDown class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
|
||||
class ActionGroup(ActionItem, Button):
|
||||
'''ActionGroup class, see module documentation for more information.
|
||||
'''
|
||||
ActionGroup class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
use_separator = BooleanProperty(False)
|
||||
'''Specifies whether to use a separator after/before this group or not.
|
||||
'''
|
||||
Specifies whether to use a separator after/before this group or not.
|
||||
|
||||
:attr:`use_separator` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
:attr:`use_separator` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
'''
|
||||
|
||||
separator_image = StringProperty(
|
||||
'atlas://data/images/defaulttheme/separator')
|
||||
'''Background Image for an ActionSeparator in an ActionView.
|
||||
'''
|
||||
Background Image for an ActionSeparator in an ActionView.
|
||||
|
||||
:attr:`separator_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/separator'.
|
||||
:attr:`separator_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/separator'.
|
||||
'''
|
||||
|
||||
separator_width = NumericProperty(0)
|
||||
'''Width of the ActionSeparator in an ActionView.
|
||||
'''
|
||||
Width of the ActionSeparator in an ActionView.
|
||||
|
||||
:attr:`separator_width` is a :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to 0.
|
||||
:attr:`separator_width` is a :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to 0.
|
||||
'''
|
||||
|
||||
mode = OptionProperty('normal', options=('normal', 'spinner'))
|
||||
'''Sets the current mode of an ActionGroup. If mode is 'normal', the
|
||||
ActionGroups children will be displayed normally if there is enough
|
||||
space, otherwise they will be displayed in a spinner. If mode is
|
||||
'spinner', then the children will always be displayed in a spinner.
|
||||
'''
|
||||
Sets the current mode of an ActionGroup. If mode is 'normal', the
|
||||
ActionGroups children will be displayed normally if there is enough
|
||||
space, otherwise they will be displayed in a spinner. If mode is
|
||||
'spinner', then the children will always be displayed in a spinner.
|
||||
|
||||
:attr:`mode` is a :class:`~kivy.properties.OptionProperty` and
|
||||
defaults to 'normal'.
|
||||
:attr:`mode` is an :class:`~kivy.properties.OptionProperty` and defaults
|
||||
to 'normal'.
|
||||
'''
|
||||
|
||||
dropdown_width = NumericProperty(0)
|
||||
'''If non zero, provides the width for the associated DropDown. This is
|
||||
'''
|
||||
If non zero, provides the width for the associated DropDown. This is
|
||||
useful when some items in the ActionGroup's DropDown are wider than usual
|
||||
and you don't want to make the ActionGroup widget itself wider.
|
||||
|
||||
:attr:`dropdown_width` is an :class:`~kivy.properties.NumericProperty`
|
||||
:attr:`dropdown_width` is a :class:`~kivy.properties.NumericProperty`
|
||||
and defaults to 0.
|
||||
|
||||
.. versionadded:: 1.10.0
|
||||
|
@ -442,15 +468,17 @@ class ActionGroup(ActionItem, Button):
|
|||
|
||||
|
||||
class ActionOverflow(ActionGroup):
|
||||
'''ActionOverflow class, see module documentation for more information.
|
||||
'''
|
||||
ActionOverflow class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
overflow_image = StringProperty(
|
||||
'atlas://data/images/defaulttheme/overflow')
|
||||
'''Image to be used as an Overflow Image.
|
||||
'''
|
||||
Image to be used as an Overflow Image.
|
||||
|
||||
:attr:`overflow_image` is an :class:`~kivy.properties.ObjectProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/overflow'.
|
||||
:attr:`overflow_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/overflow'.
|
||||
'''
|
||||
|
||||
def add_widget(self, action_item, index=0):
|
||||
|
@ -478,43 +506,49 @@ class ActionOverflow(ActionGroup):
|
|||
|
||||
|
||||
class ActionView(BoxLayout):
|
||||
'''ActionView class, see module documentation for more information.
|
||||
'''
|
||||
ActionView class, see module documentation for more information.
|
||||
'''
|
||||
|
||||
action_previous = ObjectProperty(None)
|
||||
'''Previous button for an ActionView.
|
||||
'''
|
||||
Previous button for an ActionView.
|
||||
|
||||
:attr:`action_previous` is an :class:`~kivy.properties.ObjectProperty`
|
||||
and defaults to None.
|
||||
:attr:`action_previous` is an :class:`~kivy.properties.ObjectProperty`
|
||||
and defaults to None.
|
||||
'''
|
||||
|
||||
background_color = ListProperty([1, 1, 1, 1])
|
||||
'''Background color in the format (r, g, b, a).
|
||||
'''
|
||||
Background color in the format (r, g, b, a).
|
||||
|
||||
:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
|
||||
defaults to [1, 1, 1, 1].
|
||||
:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
|
||||
defaults to [1, 1, 1, 1].
|
||||
'''
|
||||
|
||||
background_image = StringProperty(
|
||||
'atlas://data/images/defaulttheme/action_view')
|
||||
'''Background image of an ActionViews default graphical representation.
|
||||
'''
|
||||
Background image of an ActionViews default graphical representation.
|
||||
|
||||
:attr:`background_image` is an :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_view'.
|
||||
:attr:`background_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_view'.
|
||||
'''
|
||||
|
||||
use_separator = BooleanProperty(False)
|
||||
'''Specify whether to use a separator before every ActionGroup or not.
|
||||
'''
|
||||
Specify whether to use a separator before every ActionGroup or not.
|
||||
|
||||
:attr:`use_separator` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
:attr:`use_separator` is a :class:`~kivy.properties.BooleanProperty` and
|
||||
defaults to False.
|
||||
'''
|
||||
|
||||
overflow_group = ObjectProperty(None)
|
||||
'''Widget to be used for the overflow.
|
||||
'''
|
||||
Widget to be used for the overflow.
|
||||
|
||||
:attr:`overflow_group` is an :class:`~kivy.properties.ObjectProperty`
|
||||
and defaults to an instance of :class:`ActionOverflow`.
|
||||
:attr:`overflow_group` is an :class:`~kivy.properties.ObjectProperty` and
|
||||
defaults to an instance of :class:`ActionOverflow`.
|
||||
'''
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -723,14 +757,16 @@ class ActionView(BoxLayout):
|
|||
|
||||
|
||||
class ContextualActionView(ActionView):
|
||||
'''ContextualActionView class, see the module documentation
|
||||
for more information.
|
||||
'''
|
||||
ContextualActionView class, see the module documentation for more
|
||||
information.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
class ActionBar(BoxLayout):
|
||||
'''ActionBar, see the module documentation for more information.
|
||||
'''
|
||||
ActionBar, see the module documentation for more information.
|
||||
|
||||
:Events:
|
||||
`on_previous`
|
||||
|
@ -738,30 +774,37 @@ class ActionBar(BoxLayout):
|
|||
'''
|
||||
|
||||
action_view = ObjectProperty(None)
|
||||
'''action_view of ActionBar.
|
||||
'''
|
||||
action_view of the ActionBar.
|
||||
|
||||
:attr:`action_view` is an :class:`~kivy.properties.ObjectProperty` and
|
||||
defaults to an instance of ActionView.
|
||||
:attr:`action_view` is an :class:`~kivy.properties.ObjectProperty` and
|
||||
defaults to an instance of ActionView.
|
||||
'''
|
||||
|
||||
background_color = ListProperty([1, 1, 1, 1])
|
||||
'''Background color, in the format (r, g, b, a).
|
||||
'''
|
||||
Background color, in the format (r, g, b, a).
|
||||
|
||||
:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
|
||||
defaults to [1, 1, 1, 1].
|
||||
:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
|
||||
defaults to [1, 1, 1, 1].
|
||||
'''
|
||||
|
||||
background_image = StringProperty(
|
||||
'atlas://data/images/defaulttheme/action_bar')
|
||||
|
||||
'''Background image of the ActionBars default graphical representation.
|
||||
'''
|
||||
Background image of the ActionBars default graphical representation.
|
||||
|
||||
:attr:`background_image` is an :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_bar'.
|
||||
:attr:`background_image` is a :class:`~kivy.properties.StringProperty`
|
||||
and defaults to 'atlas://data/images/defaulttheme/action_bar'.
|
||||
'''
|
||||
|
||||
border = ListProperty([2, 2, 2, 2])
|
||||
''':attr:`border` to be applied to the :attr:`background_image`.
|
||||
'''
|
||||
The border to be applied to the :attr:`background_image`.
|
||||
|
||||
:attr:`border` is a :class:`~kivy.properties.ListProperty` and defaults to
|
||||
[2, 2, 2, 2]
|
||||
'''
|
||||
|
||||
__events__ = ('on_previous',)
|
||||
|
|
Loading…
Reference in New Issue