Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/buttons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CButton

## Overview
CButton is a custom Kivy button widget that belongs to the custom widgets in the `kivy-widgets` package. It's a customizable button equipped with optional icon and text.

## Properties

### 1. `text`
- Type: `StringProperty`
- Example: "Hello, World!"
- Description: This property is used to set the text to be displayed on the button. It's optional, and the default is an empty string.

### 2. `markup`
- Type: `BooleanProperty`
- Example: True, False
- Description: This property opens up the text property to being edited with Kivy's Markup language. The default is `False`.

### 3. `font_size`
- Type: `NumericProperty`
- Example: dp(50), '50dp', etc.
- Description: Dictates the size of the text on the button, indirectly determining the button's size. The default is `sp(18)`.

### 4. `font_color`
- Type: `ColorProperty`
- Example: [0,0,0,0]
- Description: Dictates the color of the button's text. The default is [0,0,0,1].

### 5. `halign`
- Type: `OptionProperty`
- Options: 'center', 'left', 'right'
- Description: Dictates the horizontal alignment of the button's text within the button space. The default is 'center'.

### 6. `icon`
- Type: `StringProperty`
- Description: Dictates the icon the button should contain/use. This property works in collaboration with `kivy_widgets.icon_definitions.icon_unicodes`. Check the documentation of [icon_unicodes](link_here) for more information.
4 changes: 2 additions & 2 deletions kivy_widgets/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CButton(ButtonBehavior, BoxLayout):
halign = OptionProperty("center", options=["left", "center", "right"])

icon = StringProperty()
icon_font = StringProperty()

icon_color = ColorProperty([0, 0, 0, 1])
icon_size = NumericProperty(dp(24))
icon_position = OptionProperty("left", options=["left", "right"])
Expand Down Expand Up @@ -331,7 +331,7 @@ def update_label_text_size(self, *args):
id: icon
text: "{}".format(root.icon) if isinstance(root.icon, str) else "blank"
icon: root.icon
font_name: root.icon_font
font_name:"materialdesignicons-webfont.ttf"
size_hint: (None, None)
size: self.texture_size if self.icon else (dp(0), dp(0))
font_size: root.icon_size # this is the icon size
Expand Down
Binary file added tests/materialdesignicons-webfont.ttf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/test_demo4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from kivy.app import App
from kivy.lang import Builder
from kivy_widgets.buttons import CButton
from kivy_widgets.dropdown import CDropDown
from kivy.metrics import dp, sp


kv = """
#:import icon_unicodes kivy_widgets.icon_definitions.icon_unicodes
FloatLayout:
canvas.before:
Color:
Expand All @@ -14,7 +17,18 @@
size: self.size
pos: self.pos
CButton:
text: "[b]Hello, World![b]"
markup: True
font_size: sp(50)
font_color: 0.5, 0.7, 0.3, 1
halign: "center"
pos_hint: {"center_x": 0.5, "center_y": 0.5}

icon: icon_unicodes['account']
icon_color: 0.5, 0.7, 0.3, 1
icon_size: dp(60)
icon_position: "left"

"""


Expand Down