UI.GUI.AccountCreation
index
/home/flempriere/personal_projects/Languages/Python/BeginToCodeWithPython/03_UsefulPython/13_PythonAndGraphicalUserInterfaces/Exercises/03_GraphicalBankingApplication/UI/GUI/AccountCreation.py

Exercise 13.3e Account Creation
 
Provides Graphical widgets for creating bank accounts
 
Classes
-------
ApplicationForm
    Abstract class for providing a framework for providing forms to the user
SavingsAccountApplicationForm
    Class providing an application form for a Savings Account
LongTermSavingsAccountApplicationForm
    Class providing an application for for a LongTermSavingsAccount
CreditAccountApplication
    Class providing an application form for a CreditAccount
AccountCreationWidget
    Abstract class for providing an account creation widget. Designed to be
    used with a standalone window, and to present an `ApplicationForm`
 
Variables
---------
account_creation_dictionary : dict[str, ApplicationForm]
    Class mapping the `Account.Account.account_type` parameter to the
    corresponding `ApplicationForm` class

 
Modules
       
Data.Account
abc
tkinter

 
Classes
       
abc.ABC(builtins.object)
ApplicationForm
CreditAccountApplicationForm
LongTermSavingsAccountApplicationForm
SavingsAccountApplicationForm
builtins.object
AccountCreationWidget

 
class AccountCreationWidget(builtins.object)
    AccountCreationWidget(root, receiver)
 
Provides a basic widget for Account Creation
 
This widget is designed to by contained in a separate dialog window. It displays
a button for creating account, and logic for creating the account on click.
 
The widget uses dependency injection and has a specific workflow,
 
1. Create the AccountCreationWidget assigning its `root` as the dialog
   and a `receiver` to accept the `account_created(account)` message
2. Create a widget to display to the user, to accept any required information.
   This widget should have the `AccountCreationWidget` as the parent, and be
   placed into the frame of the widget at `row=0, column=0` on the grid
3. Define a function, that takes no arguments and creates an account. This function
   must use `ValueError` to indicate any failure conditions. The design intent
   is that this accesses any required input from the widget supplied in step 2
4. Register the function by calling `register_account_creation_factory` and
   passing the function
5. Accounts will now be created when the button is clicked, the call to
   `create_account` will defer to the registered function for account creation
 
This allows the same generic window and user input validation logic to be
used to display different account application forms. See the `ApplicationForm`
class for an example widget designed to work with this class
 
Attributes
----------
frame
    the frame containing this component. The user should hook a widget onto
    this frame using the grid position `row=0, column=0`
receiver
    object to receive the `account_created(account)` message
 
  Methods defined here:
__init__(self, root, receiver)
Create a new `AccountCreationWidget`
 
Parameters
----------
root
    parent widget
receiver
    object to receive the `account_created(account)` message
create_account(self)
Create a new account
 
Defers to the registered factory function to create the account.
Inform the user of the result and close the dialog box on success
 
Returns
-------
None
register_account_creation_factory(self, account_creation_factory)
Register a function for `Account` creation
 
The function should take no arguments and return an `Account` object
when called, else raise `ValueError` if an object cannot be created
 
Parameters
----------
account_creation_factory : callable[None,Account.Account]
    factory function to create accounts. Must take no arguments and
    return an `Account` subclass on call. May raise `ValueError` to
    indicate failures
 
Returns
-------
None

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ApplicationForm(abc.ABC)
    ApplicationForm(root)
 
Abstract class representing an account application form
 
This class should be overwritten with the required fields to get
the information required from the user to apply for an account.
 
The information should be accessed via the `get` method which should
be overwritten by a class
 
Attributes
----------
frame
    frame containing the elements of the widget
 
 
Method resolution order:
ApplicationForm
abc.ABC
builtins.object

Methods defined here:
__init__(self, root)
create a new `ApplicationForm`
 
This is an abstract class and the constructor should not be
called directly
 
Parameters
----------
root
    parent widget
get(self)
Return the details of an account application
 
The details should be returned in the format of a dictionary
containing key : value pairs where the key's are strings describing
required attributes and the values are the associated values
 
Returns
-------
dict[str, Any]
    key : value pairs describing an account application

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Data and other attributes defined here:
__abstractmethods__ = frozenset({'get'})

 
class CreditAccountApplicationForm(ApplicationForm)
    CreditAccountApplicationForm(root)
 
Represents a graphical application form for a credit account
 
 
Method resolution order:
CreditAccountApplicationForm
ApplicationForm
abc.ABC
builtins.object

Methods defined here:
__init__(self, root)
Create a new `CreditAccountApplicationForm`
 
Parameters
----------
root
    parent widget
get(self)
Return the details for a credit account
 
Returns
-------
dict[str, int]
    dictionary containing the max withdrawal limit keyed by "withdrawal_limit"

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Data descriptors inherited from ApplicationForm:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class LongTermSavingsAccountApplicationForm(ApplicationForm)
    LongTermSavingsAccountApplicationForm(root)
 
Represents a graphical application form for a Long Term Savings Account
 
 
Method resolution order:
LongTermSavingsAccountApplicationForm
ApplicationForm
abc.ABC
builtins.object

Methods defined here:
__init__(self, root)
Create a new `LongTermSavingsAccountApplicationForm`
 
Parameters
----------
root
    parent widget
get(self)
Return the details of an application for a long term savings account
 
Returns
-------
dict[str, int]
    dictionary containing the term limit keyed by "term_limit"

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Data descriptors inherited from ApplicationForm:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SavingsAccountApplicationForm(ApplicationForm)
    SavingsAccountApplicationForm(root)
 
Represents a graphical application form for a Savings Account
 
 
Method resolution order:
SavingsAccountApplicationForm
ApplicationForm
abc.ABC
builtins.object

Methods defined here:
get(self)
Return the details of an application for a savings account
 
Returns
-------
dict[str, Any]
    empty dictionary

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from ApplicationForm:
__init__(self, root)
create a new `ApplicationForm`
 
This is an abstract class and the constructor should not be
called directly
 
Parameters
----------
root
    parent widget

Data descriptors inherited from ApplicationForm:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
Data
        account_creation_dictionary = {'Credit Account': <class 'UI.GUI.AccountCreation.CreditAccountApplicationForm'>, 'Long Term Savings Account': <class 'UI.GUI.AccountCreation.LongTermSavingsAccountApplicationForm'>, 'Savings Account': <class 'UI.GUI.AccountCreation.SavingsAccountApplicationForm'>}