Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
anchor_x: 'right'
anchor_y: 'center'
size_hint: 1, None
height: dp(52) if len(root._action_buttons) > 0 else 0
padding: dp(8), dp(8)
GridLayout:
id: action_area
rows: 1
size_hint: None, None if len(root._action_buttons) > 0 else 1
height: dp(36) if len(root._action_buttons) > 0 else 0
width: self.minimum_width
spacing: dp(8)
''')
class MDDialog(ThemableBehavior, RectangularElevationBehavior, ModalView):
title = StringProperty('')
content = ObjectProperty(None)
md_bg_color = ListProperty([0, 0, 0, .2])
_container = ObjectProperty()
_action_buttons = ListProperty([])
_action_area = ObjectProperty()
def __init__(self, **kwargs):
super(MDDialog, self).__init__(**kwargs)
self.bind(_action_buttons=self._update_action_buttons,
auto_dismiss=lambda *x: setattr(self.shadow, 'on_release',
self.shadow.dismiss if self.auto_dismiss else None))
class NavigationDrawerDivider(OneLineListItem):
'''
A small full-width divider that can be placed in the :class:`MDNavigationDrawer`
'''
disabled = True
divider = None
_txt_top_pad = NumericProperty(dp(8))
_txt_bot_pad = NumericProperty(dp(8))
def __init__(self, **kwargs):
super(OneLineListItem, self).__init__(**kwargs)
self.height = dp(16)
class MDNavigationDrawer(BoxLayout, ThemableBehavior, RectangularElevationBehavior):
'''
'''
_elevation = NumericProperty(0)
_header_container = ObjectProperty()
_list = ObjectProperty()
active_item = ObjectProperty(None)
orientation = 'vertical'
panel = ObjectProperty()
shadow_color = ListProperty([0, 0, 0, 0])
def __init__(self, **kwargs):
super(MDNavigationDrawer, self).__init__(**kwargs)
def add_widget(self, widget, index=0):
'''
If the widget is a subclass of :class:`~NavigationDrawerHeaderBase`, then it will be placed above the
text = StringProperty('')
_capitalized_text = StringProperty('')
def on_text(self, instance, value):
self._capitalized_text = value.upper()
class MDIconButton(BaseRoundButton, BaseFlatButton, BasePressedButton):
icon = StringProperty('checkbox-blank-circle')
class MDFlatButton(BaseRectangularButton, BaseFlatButton, BasePressedButton):
pass
class MDRaisedButton(BaseRectangularButton, RectangularElevationBehavior,
BaseRaisedButton, BasePressedButton):
pass
class MDFloatingActionButton(BaseRoundButton, CircularElevationBehavior,
BaseRaisedButton):
icon = StringProperty('android')
background_palette = StringProperty('Accent')
class ColorSelector(MDIconButton):
color_name = OptionProperty(
'Indigo',
options=['Red', 'Pink', 'Purple', 'DeepPurple', 'Indigo', 'Blue',
'LightBlue', 'Cyan', 'Teal', 'Green', 'LightGreen',
'Lime', 'Yellow', 'Amber', 'Orange', 'DeepOrange',
'Brown', 'Grey', 'BlueGrey'])
def rgb_hex(self, col):
return get_color_from_hex(colors[col][self.theme_cls.accent_hue])
class MDThemePicker(ThemableBehavior, FloatLayout, ModalView,
SpecificBackgroundColorBehavior,
RectangularElevationBehavior):
pass
if __name__ == "__main__":
from kivy.app import App
from kivymd.theming import ThemeManager
class ThemePickerApp(App):
theme_cls = ThemeManager()
def build(self):
main_widget = Builder.load_string("""
#:import MDRaisedButton kivymd.button.MDRaisedButton
#:import MDThemePicker kivymd.theme_picker.MDThemePicker
FloatLayout:
MDRaisedButton:
MDFlatButton:
width: dp(32)
id: ok_button
pos: root.pos[0]+root.size[0]-self.width-dp(10), root.pos[1] + dp(10)
text: "OK"
on_release: root.close_ok()
MDFlatButton:
id: cancel_button
pos: root.pos[0]+root.size[0]-self.width-ok_button.width-dp(10), root.pos[1] + dp(10)
text: "Cancel"
on_release: root.close_cancel()
""")
class MDTimePicker(ThemableBehavior, FloatLayout, ModalView,
RectangularElevationBehavior):
# md_bg_color = ListProperty((0, 0, 0, 0))
time = ObjectProperty()
def __init__(self, **kwargs):
super(MDTimePicker, self).__init__(**kwargs)
self.current_time = self.ids.time_picker.time
def set_time(self, time):
try:
self.ids.time_picker.set_time(time)
except AttributeError:
raise TypeError(
'MDTimePicker.set_time must receive a datetime object, '
'not a "{}"'.format(type(time).__name__))
def close_cancel(self):
font_style: 'Title'
opposite_colors: root.opposite_colors
theme_text_color: 'Custom'
text_color: root.specific_text_color
text: root.title
shorten: True
shorten_from: 'right'
BoxLayout:
id: right_actions
orientation: 'horizontal'
size_hint_x: None
padding: [0, (self.height - dp(48))/2]
''')
class Toolbar(ThemableBehavior, RectangularElevationBehavior,
SpecificBackgroundColorBehavior, BoxLayout):
left_action_items = ListProperty()
"""The icons on the left of the Toolbar.
To add one, append a list like the following:
['icon_name', callback]
where 'icon_name' is a string that corresponds to an icon definition and
callback is the function called on a touch release event.
"""
right_action_items = ListProperty()
"""The icons on the left of the Toolbar.
Works the same way as :attr:`left_action_items`
font_size: root._label_font_size
pos_hint: {'center_x': .5, 'center_y': 0.6}
canvas:
Color:
rgba: root.theme_cls.bg_normal
Rectangle:
size: root.size
""")
class MDTabBar(ThemableBehavior, BackgroundColorBehavior, BoxLayout):
pass
class MDBottomNavigationBar(ThemableBehavior, BackgroundColorBehavior, FloatLayout, RectangularElevationBehavior):
pass
class MDTabHeader(MDFlatButton):
""" Internal widget for headers based on MDFlatButton"""
width = BoundedNumericProperty(dp(0), min=dp(72), max=dp(264), errorhandler=lambda x: dp(72))
tab = ObjectProperty(None)
panel = ObjectProperty(None)
class MDBottomNavigationErrorCache:
last_size_warning = 0
def small_error_warn(x):
class DayButton(ThemableBehavior, CircularRippleBehavior, ButtonBehavior,
AnchorLayout):
text = StringProperty()
owner = ObjectProperty()
is_today = BooleanProperty(False)
is_selected = BooleanProperty(False)
def on_release(self):
self.owner.set_selected_widget(self)
class WeekdayLabel(MDLabel):
pass
class MDDatePicker(FloatLayout, ThemableBehavior, RectangularElevationBehavior,
SpecificBackgroundColorBehavior, ModalView):
_sel_day_widget = ObjectProperty()
cal_list = None
cal_layout = ObjectProperty()
sel_year = NumericProperty()
sel_month = NumericProperty()
sel_day = NumericProperty()
day = NumericProperty()
month = NumericProperty()
year = NumericProperty()
today = date.today()
callback = ObjectProperty()
background_color = ListProperty([0, 0, 0, 0.7])
class SetDateError(Exception):
pass