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:

kivymd.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version

Example command:

kivymd.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:

kivymd.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --name_database

Example command:

kivymd.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.

Create project with hot reload#

Template command:

kivymd.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --use_hotreload

Example command:

kivymd.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.

Create project with responsive view#

When creating a project, you can specify which views should use responsive behavior. To do this, specify the name of the view/views in the –use_responsive argument:

Template command:

kivymd.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --name_screen FirstScreen SecondScreen ThirdScreen \
    --use_responsive FirstScreen SecondScreen

The FirstScreen and SecondScreen views will be created with an responsive architecture. For more detailed information about using the adaptive view, see the MDResponsiveLayout widget.

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

When you need to create an application template with multiple screens, use multiple values separated by a space for the name_screen parameter, for example, as shown below:

Template command:

kivymd.create_project \
    name_pattern \
    path_to_project \
    name_project \
    python_version \
    kivy_version \
    --name_screen FirstScreen SecondScreen ThirdScreen
  • 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

  • use_responsive
    • the name/names of the views to be used by the responsive UI

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.main()#

Project creation function.