kivy-code-quality-4 #2270
|
@ -5,54 +5,50 @@
|
||||||
draft.py
|
draft.py
|
||||||
==============
|
==============
|
||||||
|
|
||||||
Draft screen
|
Draft screen for managing draft messages in Kivy UI.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.properties import (
|
from kivy.properties import ListProperty, StringProperty
|
||||||
ListProperty,
|
|
||||||
StringProperty
|
|
||||||
)
|
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from pybitmessage.bitmessagekivy.baseclass.common import (
|
from pybitmessage.bitmessagekivy.baseclass.common import (
|
||||||
show_limited_cnt, empty_screen_label,
|
show_limited_cnt, empty_screen_label, kivy_state_variables
|
||||||
kivy_state_variables
|
|
||||||
)
|
)
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
||||||
class Draft(Screen):
|
class Draft(Screen):
|
||||||
"""Draft screen class for kivy Ui"""
|
"""Draft screen class for Kivy UI"""
|
||||||
|
|
||||||
data = ListProperty()
|
data = ListProperty()
|
||||||
account = StringProperty()
|
account = StringProperty()
|
||||||
queryreturn = ListProperty()
|
queryreturn = ListProperty()
|
||||||
has_refreshed = True
|
has_refreshed = True
|
||||||
label_str = "yet no message for this account!!!!!!!!!!!!!"
|
label_str = "Yet no message for this account!"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Method used for storing draft messages"""
|
"""Initialize the Draft screen and set the default account"""
|
||||||
super(Draft, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.kivy_state = kivy_state_variables()
|
self.kivy_state = kivy_state_variables()
|
||||||
if self.kivy_state.selected_address == '':
|
if not self.kivy_state.selected_address:
|
||||||
if App.get_running_app().identity_list:
|
if App.get_running_app().identity_list:
|
||||||
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
|
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock Schedule for method draft accounts"""
|
"""Initialize the UI and load draft messages"""
|
||||||
self.load_draft()
|
self.load_draft()
|
||||||
logger.debug(dt)
|
logger.debug(f"UI initialized with dt: {dt}") # noqa: E999
|
||||||
|
|
||||||
def load_draft(self, where="", what=""):
|
def load_draft(self, where="", what=""):
|
||||||
"""Load draft list for Draft messages"""
|
"""Load the list of draft messages"""
|
||||||
self.set_draft_count('0')
|
self.set_draft_count('0')
|
||||||
self.ids.ml.add_widget(empty_screen_label(self.label_str))
|
self.ids.ml.add_widget(empty_screen_label(self.label_str))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_draft_count(Count):
|
def set_draft_count(count):
|
||||||
"""Set the count of draft mails"""
|
"""Set the count of draft messages in the UI"""
|
||||||
draftCnt_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt
|
draft_count_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt
|
||||||
draftCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count))
|
draft_count_obj.ids.badge_txt.text = show_limited_cnt(int(count))
|
||||||
|
|
|
@ -6,18 +6,14 @@
|
||||||
Kivy UI for inbox screen
|
Kivy UI for inbox screen
|
||||||
"""
|
"""
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.properties import (
|
from kivy.properties import ListProperty, StringProperty
|
||||||
ListProperty,
|
|
||||||
StringProperty
|
|
||||||
)
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.uix.screenmanager import Screen
|
from kivy.uix.screenmanager import Screen
|
||||||
|
|
||||||
from pybitmessage.bitmessagekivy.baseclass.common import kivy_state_variables, load_image_path
|
from pybitmessage.bitmessagekivy.baseclass.common import kivy_state_variables, load_image_path
|
||||||
|
|
||||||
|
|
||||||
class Inbox(Screen):
|
class Inbox(Screen):
|
||||||
"""Inbox Screen class for kivy Ui"""
|
"""Inbox Screen class for Kivy UI"""
|
||||||
|
|
||||||
queryreturn = ListProperty()
|
queryreturn = ListProperty()
|
||||||
has_refreshed = True
|
has_refreshed = True
|
||||||
|
@ -26,33 +22,32 @@ class Inbox(Screen):
|
||||||
label_str = "Yet no message for this account!"
|
label_str = "Yet no message for this account!"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize kivy variables"""
|
"""Initialize Kivy variables and set up the UI"""
|
||||||
super(Inbox, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs) # pylint: disable=missing-super-argument
|
||||||
self.kivy_running_app = App.get_running_app()
|
self.kivy_running_app = App.get_running_app()
|
||||||
self.kivy_state = kivy_state_variables()
|
self.kivy_state = kivy_state_variables()
|
||||||
self.image_dir = load_image_path()
|
self.image_dir = load_image_path()
|
||||||
Clock.schedule_once(self.init_ui, 0)
|
Clock.schedule_once(self.init_ui, 0)
|
||||||
|
|
||||||
def set_defaultAddress(self):
|
def set_default_address(self):
|
||||||
"""Set default address"""
|
"""Set the default address if none is selected"""
|
||||||
if self.kivy_state.selected_address == "":
|
if not self.kivy_state.selected_address and self.kivy_running_app.identity_list:
|
||||||
if self.kivy_running_app.identity_list:
|
|
||||||
self.kivy_state.selected_address = self.kivy_running_app.identity_list[0]
|
self.kivy_state.selected_address = self.kivy_running_app.identity_list[0]
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""loadMessagelist() call at specific interval"""
|
"""Initialize UI and load message list"""
|
||||||
self.loadMessagelist()
|
self.loadMessagelist()
|
||||||
|
|
||||||
def loadMessagelist(self, where="", what=""):
|
def loadMessagelist(self, where="", what=""):
|
||||||
"""Load inbox list for inbox messages"""
|
"""Load inbox messages"""
|
||||||
self.set_defaultAddress()
|
self.set_default_address()
|
||||||
self.account = self.kivy_state.selected_address
|
self.account = self.kivy_state.selected_address
|
||||||
|
|
||||||
def refresh_callback(self, *args):
|
def refresh_callback(self, *args):
|
||||||
"""Load inbox messages while wating-loader spins & called in inbox.kv"""
|
"""Refresh the inbox messages while showing a loading spinner"""
|
||||||
|
|
||||||
def refresh_on_scroll_down(interval):
|
def refresh_on_scroll_down(interval):
|
||||||
"""Reset fields and load data on scrolling upside down"""
|
"""Reset search fields and reload data on scroll"""
|
||||||
self.kivy_state.searching_text = ""
|
self.kivy_state.searching_text = ""
|
||||||
self.children[2].children[1].ids.search_field.text = ""
|
self.children[2].children[1].ids.search_field.text = ""
|
||||||
self.ids.ml.clear_widgets()
|
self.ids.ml.clear_widgets()
|
||||||
|
|
Reference in New Issue
Block a user