Post

FlatRoundButton

FlatRoundButton

SimpleKivy.SimpleKivy.FlatRoundButton(text='flat_round_btn', lcolor=[0.5, 0.5, 0.5, 1], bcolor_normal=[0.345, 0.345, 0.345, 0], bcolor_down=[0.2, 0.64, 0.8, 1], markup=True, focus_behavior=False, hover_highlight=False, enable_events=True, on_event='on_release', k=None, **kwargs)

FlatRoundButton.png

Creates a Flat-style rounded button widget dynamically with added functionalities.

Dynamic Creation Parameters

focus_behavior: bool

Whether the widget will have FocusBehavior:

  • False: No focus behavior.
  • True: Widget class created with FocusBehavior.

Default is False.

hover_highlight: bool

Whether the widget will have HoverHighlightBehavior. See HoverHighlightBehavior for more details.

  • False: Nothing will happen on hover.
  • True: Widget will be highlighted on mouse hover.

Default is False

Parameters

segments: int

Number of segments used to represent the rounded corners.

r: VariableListProperty(length=4)

Radius used for each of the corners in the order top-left, top-right, bottom-right, bottom-left

bcolor_normal, bcolor_down, bcolor, lcolor and any other valid properties with color in their name can be specified with sequence or str during creation:

  • sequence: [float, float, float, float]: Sequence (list or tuple) of 4 float numbers (0.0-1.0). Same as Kivy.
  • str: "{hex_string}": Hex color in the format "#000000".

bcolor_normal: Background color of the widget when state="normal".

bcolor_down: Background color of the widget when state="down".

bcolor: Current background color of the widget. Overwritten by widget’s current state. Avoid setting it.

lcolor: Line color of the widget.

lwidth: number (float or int)

Width of the widget’s border line.

k: None, str, or NOTKEY

Key specification for quick acess:

  • None: Automatically sets an int value.
  • str: Use specific string key.
  • NOTKEY: Special flag indicating no key should be used.

size: str or sequence of 2 ints

Size specification of the widget:

  • str: "x{width}": Sets widget width and size_hint_x = None.
  • str: "y{height}": Sets widget height and size_hint_y = None.
  • str: "xchildren": Sets size_hint_x = None and binds this widget’s width to the sum of the widths of its children.
  • str: "ychildren": Sets size_hint_y = None and binds this widget’s height to the sum of the heights of its children.
  • str: "xchild_max": Sets size_hint_x = None and binds this widget’s width to the child with the maximum width.
  • str: "ychild_max": Sets size_hint_y = None and binds this widget’s height to the child with the maximum height.

You can combine up to two of the above size string specifications.

  • str: "{number}": Processed as size = (number, number) and size_hint = (None,None). Cannot be combined with other string specifications.
  • sequence: (int, int): Size of the widget. Same as Kivy. Has no effect if size_hint argument is not set to None.

Example:

1
2
3
4
5
6
7
sk.FlatRoundButton(size = "y35")
sk.FlatRoundButton(size = "x120y35")
sk.FlatRoundButton(size = "xchildreny40")
sk.FlatRoundButton(size = "xchildrenychildren")
sk.FlatRoundButton(size = "xchild_maxy40")
sk.FlatRoundButton(size = "60")
sk.FlatRoundButton(size = (120,35), size_hint = (None, None))

enable_events: bool

Whether the widget will send events to the event_manager set in MyApp using the widgets k/id property as event identifier.

  • True: Triggers events.
  • False: Doesn’t trigger events.

on_event: str, iterable (tuple or list), dict

Defines which events/property changes will trigger the event_manager. Only has effect if enable_events = True.

  • str: Name of the event or property that will trigger the event_manager.
  • iterable: [str, str, ...]: Will trigger events for each name in the iterable.
  • dict: {"{event_name}": callback}: Calls instance.bind(**on_event) during widget creation.

Example:

1
2
3
4
5
sk.FlatRoundButton(enable_events = True, on_event = 'width')
sk.FlatRoundButton(enable_events = True, on_event = 'on_touch_down')
sk.FlatRoundButton(enable_events = True, on_event = ['width','height','pos'])
sk.FlatRoundButton(enable_events = True, on_event = {"size": lambda ins,v: print("size =",v)})

do_dot_subevent: bool

Adds a “.” to describe the event when triggering the event_manager.

  • True: The event identifier is str(widget.id)+".{event_name}".
  • False: The event identifier is the same as the widget’s k/id.

Default is False.

Returns

FlatRoundButton widget created dynamically.

Kivy Bases

  • RelativeLayout
    • Label

This page only details the new or modified features. All other parameters inherit from the base Kivy widgets and can be found in the official Kivy documentation.

Properties

is_held (BooleanProperty): Set internally when the button is held. Default is False.

repeat_delay (float): Seconds before repeating starts. Default is 0.5.

repeat_interval (float): Seconds between repeats. Default is 0.1.

Properties

Events

on_press(ins): Fired when the widget is pressed.

on_release(ins): Fired when the widget is released.

on_repeat(ins): Fired repeatedly when the button is held.

When created with hover_highlight = True

Properties

tooltip_text (StringProperty): Tooltip to be displayed when the mouse hovers over the FlatRoundButton widget. Default is "".

tooltip_args (ObjectProperty): Dictionary of Label properties for the tooltip widget. See Label. Default tooltip properties are dict(color="#CCCCCC", bcolor=(.13,.13,.13,1), lcolor="gray", valign="middle", size="y30", size_behavior="texth", padding=[4,4,4,4]).

do_highlight (BooleanProperty): Whether the widget is highlighted when the mouse hovers over it. Default is True.

Events

on_enter(): Fired when the mouse enters the widget.

on_leave(): Fired when the mouse leaves the widget.

Alias

  • FlatRoundB
  • FlatRoundButton
This post is licensed under CC BY 4.0 by the author.