first commit

This commit is contained in:
Yura 2024-09-15 15:12:16 +03:00
commit 417e54da96
5696 changed files with 900003 additions and 0 deletions

View file

@ -0,0 +1 @@
from .dropdownitem import MDDropDownItem # NOQA F401

View file

@ -0,0 +1,38 @@
<_Triangle>:
canvas:
Color:
rgba: app.theme_cls.text_color
Triangle:
points:
[ \
self.right-dp(14), self.y+dp(7), \
self.right-dp(7), self.y+dp(7), \
self.right-dp(7), self.y+dp(14) \
]
<MDDropDownItem>
orientation: "vertical"
size_hint: None, None
size: self.minimum_size
spacing: "5dp"
padding: "5dp", "5dp", "5dp", 0
MDBoxLayout:
adaptive_size: True
spacing: "10dp"
Label:
id: label_item
size_hint: None, None
size: self.texture_size
color: root.theme_cls.text_color
disabled_color: root.theme_cls.disabled_hint_text_color
font_size: root.font_size
_Triangle:
size_hint: None, None
size: "20dp", "20dp"
MDSeparator:

View file

@ -0,0 +1,113 @@
"""
Components/DropdownItem
=======================
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-item.png
:align: center
Usage
-----
.. code-block:: python
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen
MDDropDownItem:
id: drop_item
pos_hint: {'center_x': .5, 'center_y': .5}
text: 'Item'
on_release: print("Press item")
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
Test().run()
.. seealso::
`Work with the class MDDropdownMenu see here <https://kivymd.readthedocs.io/en/latest/components/menu/index.html#center-position>`_
"""
__all__ = ("MDDropDownItem",)
import os
from kivy.lang import Builder
from kivy.properties import NumericProperty, StringProperty
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget
from kivymd import uix_path
from kivymd.theming import ThemableBehavior
from kivymd.uix.behaviors import DeclarativeBehavior
with open(
os.path.join(uix_path, "dropdownitem", "dropdownitem.kv"), encoding="utf-8"
) as kv_file:
Builder.load_string(kv_file.read())
class _Triangle(Widget):
pass
class MDDropDownItem(
DeclarativeBehavior, ThemableBehavior, ButtonBehavior, BoxLayout
):
"""
Dropdown item class.
For more information, see in the
:class:`~kivymd.uix.behaviors.DeclarativeBehavior` and
:class:`~kivymd.theming.ThemableBehavior` and
:class:`~kivy.uix.behaviors.ButtonBehavior` and
:class:`~kivy.uix.boxlayout.BoxLayout`
classes documentation.
"""
text = StringProperty()
"""
Text item.
:attr:`text` is a :class:`~kivy.properties.StringProperty`
and defaults to `''`.
"""
current_item = StringProperty()
"""
Current name item.
:attr:`current_item` is a :class:`~kivy.properties.StringProperty`
and defaults to `''`.
"""
font_size = NumericProperty("16sp")
"""
Item font size.
:attr:`font_size` is a :class:`~kivy.properties.NumericProperty`
and defaults to `'16sp'`.
"""
def on_text(self, instance_drop_down_item, text_item: str) -> None:
self.ids.label_item.text = text_item
def set_item(self, name_item: str) -> None:
"""Sets new text for an item."""
self.ids.label_item.text = name_item
self.current_item = name_item