kivy-code-quality-1 #2272
|
@ -1,50 +1,62 @@
|
||||||
# pylint: disable=no-member, too-many-arguments, too-few-public-methods
|
# pylint: disable=no-member, too-many-arguments, too-few-public-methods
|
||||||
"""
|
|
||||||
Addressbook widgets are here.
|
"""Addressbook widgets are here."""
|
||||||
"""
|
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivymd.uix.button import MDRaisedButton
|
from kivymd.uix.button import MDRaisedButton
|
||||||
from kivymd.uix.dialog import MDDialog
|
from kivymd.uix.dialog import MDDialog
|
||||||
|
|
||||||
|
|
||||||
class HelperAddressBook(object):
|
class HelperAddressBook:
|
||||||
"""Widget used in Addressbook are here"""
|
"""Widget utilities for Addressbook."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def address_detail_popup(obj, send_message, update_address, close_popup, width):
|
def address_detail_popup(obj, send_message, update_address, close_popup, width):
|
||||||
"""This function shows the address's details and opens the popup."""
|
"""
|
||||||
show_dialogue = MDDialog(
|
Shows address details in a popup with clear actions.
|
||||||
type="custom",
|
|
||||||
size_hint=(width, .25),
|
Args:
|
||||||
content_cls=obj,
|
obj: The widget containing the address details to display.
|
||||||
|
send_message: The function to call when the "Send message" button is pressed.
|
||||||
|
update_address: The function to call when the "Save" button is pressed.
|
||||||
|
close_popup: The function to call when the "Cancel" button is pressed or the popup is closed.
|
||||||
|
width: The desired width of the popup as a proportion of the screen.
|
||||||
|
"""
|
||||||
|
|
||||||
buttons = [
|
buttons = [
|
||||||
MDRaisedButton(
|
MDRaisedButton(text="Send message", on_release=send_message),
|
||||||
text="Send message to",
|
MDRaisedButton(text="Update Address", on_release=update_address),
|
||||||
on_release=send_message,
|
MDRaisedButton(text="Cancel", on_release=close_popup),
|
||||||
),
|
]
|
||||||
MDRaisedButton(
|
|
||||||
text="Save",
|
return MDDialog(
|
||||||
on_release=update_address,
|
type="custom",
|
||||||
),
|
size_hint=(width, 0.25),
|
||||||
MDRaisedButton(
|
content_cls=obj,
|
||||||
text="Cancel",
|
buttons=buttons,
|
||||||
on_release=close_popup,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
return show_dialogue
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def compose_message(from_addr=None, to_addr=None):
|
def compose_message(from_addr=None, to_addr=None):
|
||||||
"""This UI independent method for message sending to reciever"""
|
"""
|
||||||
window_obj = App.get_runnint_app().root.ids
|
Composes a new message (UI-independent).
|
||||||
if to_addr:
|
|
||||||
window_obj.id_create.children[1].ids.txt_input.text = to_addr
|
Args:
|
||||||
if from_addr:
|
from_addr (str, optional): The address to set in the "From" field. Defaults to None.
|
||||||
window_obj.id_create.children[1].ids.txt_input.text = from_addr
|
to_addr (str, optional): The address to set in the "To" field. Defaults to None.
|
||||||
window_obj.id_create.children[1].ids.ti.text = ''
|
"""
|
||||||
window_obj.id_create.children[1].ids.composer_dropdown.text = 'Select'
|
|
||||||
window_obj.id_create.children[1].ids.subject.text = ''
|
app = App.get_running_app()
|
||||||
window_obj.id_create.children[1].ids.body.text = ''
|
|
||||||
window_obj.scr_mngr.current = 'create'
|
ids = app.root.ids
|
||||||
|
create_screen = ids.id_create.children[1].ids
|
||||||
|
|
||||||
|
# Reset fields
|
||||||
|
create_screen.txt_input.text = to_addr if to_addr else from_addr
|
||||||
|
create_screen.ti.text = ""
|
||||||
|
create_screen.composer_dropdown.text = "Select"
|
||||||
|
create_screen.subject.text = ""
|
||||||
|
create_screen.body.text = ""
|
||||||
|
|
||||||
|
# Navigate to create screen
|
||||||
|
ids.scr_mngr.current = "create"
|
||||||
|
|
Reference in New Issue
Block a user