Skip to content
Steven Tran edited this page Oct 31, 2019 · 5 revisions

Welcome to the CilantroAudit wiki!

How to Add Screens to the Main Menu (home_page.py)

  1. Go to the home_page.py file.

    1. https://github.com/seanlesch/CilantroAudit/blob/master/cilantro_audit/home_page.py for ref
  2. Import your screen like from cilantro_audit.completed_audits_list_page import CompletedAuditsListPage at the top of the file. An outline would be from cilantro_audit.<YOUR_PYTHON_FILE> import <YOUR_PAGE>.

  3. In the build(self) method of CilantroAudit, add your view to the screen manager like sm.add_widget(YourPythonClassName(name="NameForYourScreen")). If we were trying to add completed_audits_list_page, the result would be sm.add_widget(CompletedAuditsListPage(name="CompletedAuditsListPage")).

  4. Now your screen manager should have an entry for CompletedAuditsListPage. This String is how you will be referencing in your other Python/kv files.

  5. In your .kv file, you must have a certain property for a button for instance e.g. on_press: root.manager.current = 'ADMIN_SCREEN', if you'd like to have your screen go back to the ADMIN_SCREEN.

  6. If you want to link a page to your screen, you must do the reverse, so on_press: root.manager.current = 'CompletedAuditsListPage' if your screen name was named CompletedAuditsListPage.

    1. https://github.com/seanlesch/CilantroAudit/blob/master/cilantro_audit/widgets/home_page.kv for ref
  7. root.manager.current has 3 parts. The root is the root widget of the kivy app, which in this case is HomePage. The manager is the screen manager that the root widget has already created in its build method. The current property of the screen manager refers to the current screen. Once the current field is changed, the screen will be updated accordingly.

  8. If everything works as intended, you will be able to run home_page.py, and then navigate to your desired page. After navigating to your page, going backwards should work as well.

Clone this wiki locally