Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from kivy.app import App
from kivy.clock import Clock, mainthread
from kivy.properties import ListProperty
from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ThreeLineAvatarListItem
from pyetheroll.constants import ROUND_DIGITS
from etherollapp.etheroll.ui_utils import Dialog, SubScreen, load_kv_from_py
from etherollapp.etheroll.utils import run_in_thread
load_kv_from_py(__file__)
class DiceResultWidget(ILeftBody, MDLabel):
pass
class RollResultsScreen(SubScreen):
roll_logs = ListProperty()
def __init__(self, **kwargs):
super(RollResultsScreen, self).__init__(**kwargs)
# TODO: make it a property that starts/stops spinner on set
self._fetching_results = False
Clock.schedule_once(self._after_init)
def _after_init(self, dt):
"""
Binds events.
root.active_color_type == "custom" else root._active_color if root.use_active else \
root.theme_cls.secondary_text_color
text: root.badge_text
halign: 'right'
:
canvas:
Color:
rgba: self.theme_cls.divider_color
Line:
points: root.x ,root.y+dp(8), root.x+self.width, root.y+dp(8)
""")
class NDIconLabel(ILeftBody, MDLabel):
pass
class NDBadgeLabel(IRightBody, MDLabel):
pass
class NavigationDrawerHeaderBase:
'''
Tells the :class:`~MDNavigationDrawer` that this should be in the header area (above the
:class:`~kivy.uix.scrollview.ScrollView`).
'''
pass
bs.open()
def set_error_message(self, *args):
if len(self.root.ids.text_field_error.text) == 2:
self.root.ids.text_field_error.error = True
else:
self.root.ids.text_field_error.error = False
def on_pause(self):
return True
def on_stop(self):
pass
class AvatarSampleWidget(ILeftBody, Image):
pass
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
pass
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
pass
if __name__ == '__main__':
KitchenSink().run()
else:
self.gl_content.add_widget(widget, index)
Builder.load_string('''
#:import md_icons kivymd.icon_definitions.md_icons
font_style: 'Icon'
text: u"{}".format(md_icons[root.icon])
halign: 'center'
theme_text_color: 'Primary'
valign: 'middle'
''')
class ListBSIconLeft(ILeftBody, MDLabel):
icon = StringProperty()
class MDListBottomSheet(MDBottomSheet):
mlist = ObjectProperty()
def __init__(self, **kwargs):
super(MDListBottomSheet, self).__init__(**kwargs)
self.mlist = MDList()
self.gl_content.add_widget(self.mlist)
Clock.schedule_once(self.resize_content_layout, 0)
def resize_content_layout(self, *largs):
self.gl_content.height = self.mlist.height
def add_item(self, text, callback, icon=None):
BoxLayout:
MDLabel:
font_style: 'Headline'
theme_text_color: 'Primary'
text: "Counter: 0"
halign: 'center'
pos_hint: {'center_x': 0.5, 'center_y': 0.75}
MDFloatingActionButton:
icon: 'plus'
elevation_normal: 2
pos_hint: {'center_x': 0.5, 'center_y': 0.25}
on_press: app.ads.show_rewarded_ad()
""")
class AvatarIconWidget(ILeftBody, Image):
pass
class KivMobDemoUI(FloatLayout):
def switch_to_screen(self, name, title):
self.ids.toolbar.title = title
self.ids.toolbar.left_action_items = [['chevron-left', lambda x: self.back_to_menu()]]
self.ids.scr_mngr.transition.direction = 'left'
self.ids.scr_mngr.current = name
self.snackbar = Snackbar(text="Interstitial has not yet loaded.")
def back_to_menu(self):
self.ids.scr_mngr.transition.direction = 'right'
self.ids.scr_mngr.current = "menu"
root.active_color_type == "custom" else root._active_color if root.use_active else \
root.theme_cls.secondary_text_color
text: root.badge_text
halign: 'right'
:
canvas:
Color:
rgba: self.theme_cls.divider_color
Line:
points: root.x ,root.y+dp(8), root.x+self.width, root.y+dp(8)
""")
class NDIconLabel(ILeftBody, MDLabel):
pass
class NDBadgeLabel(IRightBody, MDLabel):
pass
class NavigationDrawerHeaderBase:
'''
Tells the :class:`~MDNavigationDrawer` that this should be in the header area (above the
:class:`~kivy.uix.scrollview.ScrollView`).
'''
pass
Line(points=[x_left, y_up, x_left+0.8*self.r*sin(pi/30*time.second), y_up+0.8*self.r*cos(pi/30*time.second)], width=1, cap="round")
Color(1.0, 1.0, 1.0, 1)
Line(points=[x_left, y_up, x_left+0.7*self.r*sin(pi/30*time.minute), y_up+0.7*self.r*cos(pi/30*time.minute)], width=2, cap="round")
Color(1.0, 1.0, 1.0, 1)
th = time.hour*60 + time.minute
Line(points=[x_left, y_up, x_left+0.5*self.r*sin(pi/360*th), y_up+0.5*self.r*cos(pi/360*th)], width=3, cap="round")
class MyClockWidget(FloatLayout):
Ticks = Ticks()
pass
#KIVYMD classes
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
pass
class AvatarSampleWidget(ILeftBody, Image):
pass
#_________________________________________________________________
#MAINAPP
class MainApp(App):
theme_cls = ThemeManager()
version = StringProperty()
timenow = StringProperty()
datenow = StringProperty()
daynow = StringProperty()
yearnow = StringProperty()
ampm = StringProperty()
tempnow = StringProperty()
def add_widget(self, widget, index=0):
if issubclass(widget.__class__, ILeftBody):
self.ids['_left_container'].add_widget(widget)
elif issubclass(widget.__class__, ILeftBodyTouch):
self.ids['_left_container'].add_widget(widget)
self._touchable_widgets.append(widget)
elif issubclass(widget.__class__, IRightBody):
self.ids['_right_container'].add_widget(widget)
elif issubclass(widget.__class__, IRightBodyTouch):
self.ids['_right_container'].add_widget(widget)
self._touchable_widgets.append(widget)
else:
return super(BaseListItem, self).add_widget(widget)