Monday, October 26, 2015

10-26-2015 Kivy and API (status: in progress)


I need an API for taking tests and storing tests. Mongo, redis, and other technologies can wait. When I get to the point of saving test results, I will need Mongo. Probably for test purposes will just have a non-sharded mongo.

Kivy is already setup. This will get the basic API going which involves MySQL, and python API for kivy to use, and the programs kivy makes. We redo the kivy installation steps in the virtual environment for another Linux user account. 
  1. virtualenv --no-site-packages kivyinstall
  2. . kivyinstall/bin/activate
  3. mkdir Kivy
  4. cd Kivy
  5. pip install Cython==0.21.2
  6. pip install kivy
  7. pip install git+https://github.com/kivy/buildozer.git@master
  8. pip install git+https://github.com/kivy/plyer.git@master
  9. pip install -U pygments docutils
  10. ln -s ~/kivyinstall/share/kivy-examples kivy-examples
  11. rm /usr/bin/kivy # as root
  12. ln -s /home/test/kivyinstall/bin/python /usr/bin/kivy # as root
  13. # bulldozr already installed
  14. buildozer init
  15. buildozer android debug deploy run
  16. git clone git://github.com/kivy/python-for-android
  17. cd python-for-android/
  18. ./distribute.sh -m "pil openssl kivy"
    1. Ran into an error. seomthing with the wrong version of bulldozer. 
    2. Ha to rebuild bulldozer as root, remove the builddozer spec file in the normal account, reinit bulldozer
    3. Will try this again... takes a while to compile everything
    4. This no longer works, redoing python for andriod from the readme file
  19. pip install git+https://github.com/kivy/python-for-android.git
  20. python-for-android recipes # test
    1. python-for-android or p4a are the executables
  21. pip install jnius

Now making the program....

Learning is first:
  1. http://kivy.org/docs/tutorials/firstwidget.html
  2. http://kivy.org/docs/tutorials-index.html
  3. https://www.quora.com/What-is-a-good-resource-to-learn-Kivy
  4. http://kivy.org/docs/gettingstarted/intro.html
  5. http://kivy.org/docs/gettingstarted/examples.html
Stuff to use:
  1. http://kivy.org/docs/api-kivy.uix.textinput.html
    1. Inputting an answer. 
  2. http://kivy.org/docs/api-kivy.uix.togglebutton.html
    1. For selecting which answer is correct. 
  3. http://kivy.org/docs/api-kivy.uix.scrollview.html
  4. http://kivy.org/docs/api-kivy.uix.tabbedpanel.html 
    1. one window for account
    2. one for selecting test
    3. one for taking test
    4. one for making test
  5. http://kivy.org/docs/api-kivy.clock.html -- timed tests
  6. http://kivy.org/docs/api-kivy.core.camera.html -- cusotmize account


I have to do the stuff below. First thing, I have to download docs:

  • Download docs and install on local laptop: DONE
    • python
    • apache
    • kivy documentation
      • https://github.com/kivy/kivy/blob/master/doc/README.md
        • apt-get install python-sphinx
        • pip install sphinxcontrib-blockdiag sphinxcontrib-seqdiag
        • pip install sphinxcontrib-actdiag sphinxcontrib-nwdiag
        • download: https://github.com/kivy/kivy/archive/master.zip
          • unzip kivy-master.zip 
          • apt-get install Cython
          • cd kivy-master
          • make html --- this  failed damn it, skipping. have\ pdf version. 
From here on out, start kivy with ". kivyinstall/bin/activate" to start the kivy session.

Understand:
  1. Widget: http://kivy.org/docs/api-kivy.uix.widget.html
    1. Everything is a widget. 
  2. Layouts: http://kivy.org/docs/gettingstarted/layouts.html
  3. Objects:
    1. http://kivy.org/docs/api-kivy.html
      1. Focus on the kivy.uix.* modules. Those are the objects, like buttons. 
        1. Bubble: http://kivy.org/docs/api-kivy.uix.bubble.html
        2. Button: http://kivy.org/docs/api-kivy.uix.button.html
        3. Action Bar: http://kivy.org/docs/api-kivy.uix.actionbar.html
          1. To me this is a slicker way of making the top bar. 
        4. anchor lauout: http://kivy.org/docs/api-kivy.uix.anchorlayout.html
          1. Useful for positioning basic stuff. 
        5. box layout:http://kivy.org/docs/api-kivy.uix.boxlayout.html
          1. Useful for adding buttons. 
        6. Checkbox: http://kivy.org/docs/api-kivy.uix.checkbox.html
          1. Useful for choosing one answer. 
        7. Drop down list: http://kivy.org/docs/api-kivy.uix.widget.html
          1. Probably the default for the top bar. 
        8. Image: http://kivy.org/docs/api-kivy.uix.image.html
          1. not immediately useful, but for later. 
        9. popup: http://kivy.org/docs/api-kivy.uix.image.html
          1. Messages to popup. Can be buttons. 
        10. screens: http://kivy.org/docs/api-kivy.uix.screenmanager.html
          1. Have 4 screen initially, for different purposes, and they don't die. You should switch between them. 
        11. When looking at examples, do this:
          1. Download exmaples
          2. cd kivy-examples/demo/showcase
          3. kivy main.py
          4. Look at the root source code. This example is the one example to get you started. There are lots of other good examples, but this one is great. 

  1. Make API
    1. http://kivy.org/docs/api-index.html
    2. Login API
  2. Connection to MySQL database
    1. add session
    2. add cookie
  3. Connect to mongo to save results

DOING

Making the android version...

DOING

Running on android server..

DOING

No comments:

Post a Comment