doc and style: formatted the whole codebase to pep8 plus added documentation where necessary

This commit is contained in:
Benedict Xavier Wanyonyi
2024-05-30 15:43:45 +03:00
parent e526e31083
commit b94987dfd7
54 changed files with 555 additions and 346 deletions

View File

@@ -1,3 +1,3 @@
# <MDLabel>:
# allow_copy:True
# allow_selection:True
<MDLabel>:
allow_copy:True
allow_selection:True

View File

@@ -4,18 +4,29 @@ from kivy.animation import Animation
from kivy.uix.modalview import ModalView
from kivymd.theming import ThemableBehavior
from kivymd.uix.behaviors import BackgroundColorBehavior,StencilBehavior,CommonElevationBehavior,HoverBehavior
from kivymd.uix.behaviors import (
BackgroundColorBehavior,
StencilBehavior,
CommonElevationBehavior,
HoverBehavior,
)
class MediaPopup(ThemableBehavior,HoverBehavior,StencilBehavior,CommonElevationBehavior,BackgroundColorBehavior,ModalView):
class MediaPopup(
ThemableBehavior,
HoverBehavior,
StencilBehavior,
CommonElevationBehavior,
BackgroundColorBehavior,
ModalView,
):
caller = ObjectProperty()
player = ObjectProperty()
def __init__(self, caller,*args,**kwarg):
def __init__(self, caller, *args, **kwarg):
self.caller = caller
super(MediaPopup,self).__init__(*args,**kwarg)
super(MediaPopup, self).__init__(*args, **kwarg)
def open(self, *_args, **kwargs):
"""Display the modal in the Window.
@@ -26,33 +37,32 @@ class MediaPopup(ThemableBehavior,HoverBehavior,StencilBehavior,CommonElevationB
"""
from kivy.core.window import Window
if self._is_open:
return
self._window = Window
self._is_open = True
self.dispatch('on_pre_open')
self.dispatch("on_pre_open")
Window.add_widget(self)
Window.bind(
on_resize=self._align_center,
on_keyboard=self._handle_keyboard)
Window.bind(on_resize=self._align_center, on_keyboard=self._handle_keyboard)
self.center = self.caller.to_window(*self.caller.center)
self.fbind('center', self._align_center)
self.fbind('size', self._align_center)
if kwargs.get('animation', True):
ani = Animation(_anim_alpha=1., d=self._anim_duration)
ani.bind(on_complete=lambda *_args: self.dispatch('on_open'))
self.fbind("center", self._align_center)
self.fbind("size", self._align_center)
if kwargs.get("animation", True):
ani = Animation(_anim_alpha=1.0, d=self._anim_duration)
ani.bind(on_complete=lambda *_args: self.dispatch("on_open"))
ani.start(self)
else:
self._anim_alpha = 1.
self.dispatch('on_open')
self._anim_alpha = 1.0
self.dispatch("on_open")
def _align_center(self, *_args):
if self._is_open:
self.center = self.caller.to_window(*self.caller.center)
def on_leave(self,*args):
def on_leave(self, *args):
def _leave(dt):
if not self.hovering:
self.dismiss()
Clock.schedule_once(_leave,2)
Clock.schedule_once(_leave, 2)

View File

@@ -1,8 +1,3 @@
<CommonNavigationRailItem@MDNavigationRailItem>
icon:""
text:""
<CommonNavigationRailItem>
MDNavigationRailItemIcon:
icon:root.icon