Script creates a project with the MVC pattern

New in version 1.0.0.

See also

MVC pattern

Use a clean architecture for your applications.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/preview-mvc.png

Use a clean architecture for your applications. KivyMD allows you to quickly create a project template with the MVC pattern. So far, this is the only pattern that this utility offers. You can also include database support in your project. At the moment, support for the Firebase database (the basic implementation of the real time database) and RestDB (the full implementation) is available.

Project creation

Template command:

python -m kivymd.tools.patterns.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version

Example command:

python -m kivymd.tools.patterns.create_project \
    MVC \
    /Users/macbookair/Projects \
    MyMVCProject \
    python3.10 \
    2.1.0

This command will by default create a project with an MVC pattern. Also, the project will create a virtual environment with Python 3.10, Kivy version 2.1.0 and KivyMD master version.

Note

Please note that the Python version you specified must be installed on your computer.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/mvc-base.png

Creating a project using a database

Note

Note that in the following command, you can use one of two database names: ‘firebase’ or ‘restdb’.

Template command:

python -m kivymd.tools.patterns.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --name_database

Example command:

python -m kivymd.tools.patterns.create_project \
    MVC \
    /Users/macbookair/Projects \
    MyMVCProject \
    python3.10 \
    2.1.0 \
    --name_database restdb

This command will create a project with an MVC template by default. The project will also create a virtual environment with Python 3.10, Kivy version 2.1.0, KivyMD master version and a wrapper for working with the database restdb.io.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/mvc-database.png
class DataBase:
    def __init__(self):
        database_url = "https://restdbio-5498.restdb.io"
        api_key = "7ce258d66f919d3a891d1166558765f0b4dbd"

Note

Please note that database.py the shell in the DataBase class uses the database_url and api_key parameters on the test database (works only in read mode), so you should use your data for the database.

Preview of the basic MVC template using the RestDB database

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/mvc-restbd-preview.png

Create project with hot reload

Template command:

python -m kivymd.tools.patterns.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --use_hotreload

Example command:

python -m kivymd.tools.patterns.create_project \
    MVC \
    /Users/macbookair/Projects \
    MyMVCProject \
    python3.10 \
    2.1.0 \
    --use_hotreload yes

After creating the project, open the file main.py, there is a lot of useful information. Also, the necessary information is in other modules of the project in the form of comments. So do not forget to look at the source files of the created project.

Others command line arguments

Required Arguments

  • pattern
    • the name of the pattern with which the project will be created

  • directory
    • directory in which the project will be created

  • name
    • project name

  • python_version
    • the version of Python (specify as python3.9 or python3.8) with

    • which the virtual environment will be created

  • kivy_version
    • version of Kivy (specify as 2.1.0 or master) that will be used in the project

Optional arguments

  • name_screen
    • the name of the class which be used when creating the project pattern

  • name_database
    • provides a basic template for working with the ‘firebase’ library

    • or a complete implementation for working with a database ‘restdb.io’

  • use_hotreload
    • creates a hot reload entry point to the application

-use_localization
  • creates application localization files

Warning

On Windows, hot reloading of Python files may not work. But, for example, there is no such problem in macOS. If you fix this, please report it to the KivyMD community.

API - kivymd.tools.patterns.create_project

kivymd.tools.patterns.create_project.available_patterns = ['MVC']
kivymd.tools.patterns.create_project.available_databases = ['firebase', 'restdb']
kivymd.tools.patterns.create_project.main()
kivymd.tools.patterns.create_project.create_main_with_hotreload(path_to_project: str, project_name: str, name_screen: str, module_name: str, name_database: str, use_localization: str) None
kivymd.tools.patterns.create_project.create_main(name_database: str, use_localization: str, path_to_project: str, project_name: str) None
kivymd.tools.patterns.create_project.create_model(name_database: str, name_screen: str, module_name: str, path_to_project: str) None
kivymd.tools.patterns.create_project.create_controller(name_database: str, use_hotreload: str, name_screen: str, module_name: str, path_to_project: str) None
kivymd.tools.patterns.create_project.create_view(name_database: str, use_localization: str, name_screen: str, module_name: str, path_to_project: str) None
kivymd.tools.patterns.create_project.create_requirements(name_database: str, path_to_project: str) None
kivymd.tools.patterns.create_project.create_makefile(path_to_project: str, project_name: str, module_name: str, name_screen: str) None
kivymd.tools.patterns.create_project.create_mofile(path_to_project: str) None
kivymd.tools.patterns.create_project.create_virtual_environment(python_version: str, path_to_project: str) None
kivymd.tools.patterns.create_project.localization_po_file(path_to_project: str) None
kivymd.tools.patterns.create_project.install_requirements(path_to_project: str, kivy_version: str, name_database: str) None
kivymd.tools.patterns.create_project.rename_ext_py_tmp_to_py(path_to_project: str) None
kivymd.tools.patterns.create_project.move_init(path_to_project: str, name_screen: str) None
kivymd.tools.patterns.create_project.check_databases(name_database: str, path_to_project: str) None
kivymd.tools.patterns.create_project.chek_camel_case_name_project(name_project) Union[bool, list]
kivymd.tools.patterns.create_project.replace_in_file(path_to_file: str, args) None
kivymd.tools.patterns.create_project.create_argument_parser() ArgumentParserWithHelp