|
5 | 5 | draft.py |
6 | 6 | ============== |
7 | 7 |
|
8 | | -Draft screen |
9 | | -
|
| 8 | +Draft screen for managing draft messages in Kivy UI. |
10 | 9 | """ |
11 | 10 | from kivy.clock import Clock |
12 | | -from kivy.properties import ( |
13 | | - ListProperty, |
14 | | - StringProperty |
15 | | -) |
| 11 | +from kivy.properties import ListProperty, StringProperty |
16 | 12 | from kivy.uix.screenmanager import Screen |
17 | 13 | from kivy.app import App |
18 | 14 | from pybitmessage.bitmessagekivy.baseclass.common import ( |
19 | | - show_limited_cnt, empty_screen_label, |
20 | | - kivy_state_variables |
| 15 | + show_limited_cnt, empty_screen_label, kivy_state_variables |
21 | 16 | ) |
22 | 17 | import logging |
| 18 | + |
23 | 19 | logger = logging.getLogger('default') |
24 | 20 |
|
25 | 21 |
|
26 | 22 | class Draft(Screen): |
27 | | - """Draft screen class for kivy Ui""" |
| 23 | + """Draft screen class for Kivy UI""" |
28 | 24 |
|
29 | 25 | data = ListProperty() |
30 | 26 | account = StringProperty() |
31 | 27 | queryreturn = ListProperty() |
32 | 28 | has_refreshed = True |
33 | | - label_str = "yet no message for this account!!!!!!!!!!!!!" |
| 29 | + label_str = "Yet no message for this account!" |
34 | 30 |
|
35 | 31 | def __init__(self, *args, **kwargs): |
36 | | - """Method used for storing draft messages""" |
37 | | - super(Draft, self).__init__(*args, **kwargs) |
| 32 | + """Initialize the Draft screen and set the default account""" |
| 33 | + super().__init__(*args, **kwargs) |
38 | 34 | self.kivy_state = kivy_state_variables() |
39 | | - if self.kivy_state.selected_address == '': |
| 35 | + if not self.kivy_state.selected_address: |
40 | 36 | if App.get_running_app().identity_list: |
41 | 37 | self.kivy_state.selected_address = App.get_running_app().identity_list[0] |
42 | 38 | Clock.schedule_once(self.init_ui, 0) |
43 | 39 |
|
44 | 40 | def init_ui(self, dt=0): |
45 | | - """Clock Schedule for method draft accounts""" |
| 41 | + """Initialize the UI and load draft messages""" |
46 | 42 | self.load_draft() |
47 | | - logger.debug(dt) |
| 43 | + logger.debug(f"UI initialized with dt: {dt}") |
48 | 44 |
|
49 | 45 | def load_draft(self, where="", what=""): |
50 | | - """Load draft list for Draft messages""" |
| 46 | + """Load the list of draft messages""" |
51 | 47 | self.set_draft_count('0') |
52 | 48 | self.ids.ml.add_widget(empty_screen_label(self.label_str)) |
53 | 49 |
|
54 | 50 | @staticmethod |
55 | | - def set_draft_count(Count): |
56 | | - """Set the count of draft mails""" |
57 | | - draftCnt_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt |
58 | | - draftCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count)) |
| 51 | + def set_draft_count(count): |
| 52 | + """Set the count of draft messages in the UI""" |
| 53 | + draft_count_obj = App.get_running_app().root.ids.content_drawer.ids.draft_cnt |
| 54 | + draft_count_obj.ids.badge_txt.text = show_limited_cnt(int(count)) |
0 commit comments