Page 1 of 1

Any tutorials on how to make a simple Menu app in Python?

Posted: Mon Oct 05, 2015 7:36 pm
by AforAlex
Hi, not sure if this is the right place to post, had a route through the other forums and a bit of a google search bit didn't find much so thought would be worth posting here, please let me know if you think I would be better posting else where.

I'm wanting to build a simple application that makes use of the lovely touch screen, ideally in Python that will essentially just be an area on the screen that shows some information, and then the user can tap 'ok' / 'Cancel' and maybe some kind of 'more info' button. I have a project in mind that will utilise a simple Mifare card reader, it will identify the card id, look up the owner from a mysql database and will then display some info returned. The user can then tap 'OK' , 'Cancel' or 'More Info'

I'm ok with all the card reader / mysql / python (except the touch screen interface bits)

Reading about I think my only option would perhaps be something using kivy (http://kivy.org/docs/installation/installation-rpi.html) ? and before I started I wondered whether there was a bit of help guide out there to get me started on my project or whether I will have to learn it from scratch.

Thanks in advanced

Alex

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Wed Oct 07, 2015 12:58 pm
by elParaguayo
Kivy may be a good place to start for this.

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Fri Oct 09, 2015 9:02 pm
by MattRichardson
I made this how-to that's specific to using Kivy with the official touch screen: https://github.com/mrichardson23/rpi-kivy-screen

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Fri Oct 09, 2015 9:08 pm
by lmoss30
Hi Matt,

Although I have posted elsewhere I have been trying to follow your guide and when I get to the download key section, I get a time out error to the server any thoughts

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Fri Oct 09, 2015 9:16 pm
by MattRichardson
lmoss30 wrote:Although I have posted elsewhere I have been trying to follow your guide and when I get to the download key section, I get a time out error to the server any thoughts
Yes, there used to be a note in the guide that said you just had to try it again if it doesn't work the first time around. I then updated the guide this morning to fix the issue entirely. Here's how to get it on the first try:
gpg --keyserver pgp.mit.edu --recv-keys 0C667A3E
Please report back and let me know if that works. I ran through the whole thing with Jessie this morning and everything still works mostly the same. I made a few tweaks to the guide.

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Fri Oct 09, 2015 9:18 pm
by AforAlex
Thanks people, I suspected kivy was what I needed to use. Going to give it a proper go tomorrow,tjanks for the link on how to get but installed and set up.

Ta

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Fri Oct 09, 2015 9:26 pm
by lmoss30
cheers Matt, I will try tomorrow and see how it goes will let you know

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 5:01 pm
by lmoss30
Successfully set using the new guide many thanks Matt

One question though what is the magic line to get the app to run on touch display

Managed to get the touch screen element working but couldn't see how to make the demo run on the screen

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 6:16 pm
by MattRichardson
lmoss30 wrote:Successfully set using the new guide many thanks Matt
Glad to hear it!
lmoss30 wrote:One question though what is the magic line to get the app to run on touch display

Managed to get the touch screen element working but couldn't see how to make the demo run on the screen
Can you clarify? Are you saying that the interface appears on HDMI and not the display?

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 6:25 pm
by lmoss30
I have a Motorola lapdock which I want to use as the primary display, I made this happen by changing the default display value in the config.txt file

I then want to develop the kivy app to run on the display if this is possible

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 6:28 pm
by MattRichardson
Not totally sure, as I haven't done this myself. It may have to do with updating kivy's config.ini file to specify the display's framebuffer.

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 6:46 pm
by lmoss30
The launch demo video Alex done had a set up running so I guess it a case of trawling through the info

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 9:23 pm
by JimmyN
I'm having trouble when I get to this point. I've started over three times from the beginning and it always stops at the same place.

Code: Select all

sudo pip install cython pygments docutils
Collecting cython
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading Cython-0.23.4.tar.gz (1.6MB)
    100% |################################| 1.6MB 19kB/s
Collecting pygments
  Downloading Pygments-2.0.2-py2-none-any.whl (672kB)
    100% |################################| 675kB 31kB/s
Collecting docutils
  Downloading docutils-0.12.tar.gz (1.6MB)
    100% |################################| 1.6MB 21kB/s
Building wheels for collected packages: cython, docutils
  Running setup.py bdist_wheel for cython
_
I've let it sit for an hour each time, I assume it shouldn't take any longer.

Before I started installing I updated/upgraded and made an image of the SD card. After it failed the first time I wrote the image back to the SD card to clear out everything from the first try, but that and the next round all quit at the same point again. Everything up to that point went fine and it uninstalled pip-1.1 and installed pip-7.1.2.
Any idea why it hangs when installing cython?

Code: Select all

uname -a
Linux rpi2 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sat Oct 10, 2015 10:00 pm
by MattRichardson
Not sure what the problem could be. Here's what I used to create the guide:
  • Raspberry Pi 2 Model B
  • 8gb micro SD
  • Fresh image of Raspbian written directly to the card. I've done it with the last Wheezy and the recent Jessie release. Haven't tried NOOBS, but no reason that wouldn't work that I can think of.
  • In raspi-config, I disabled boot to the X11 desktop, and I expanded the filesystem and rebooted before starting.
The Cython step does take a while, but no more than 15 minutes. Probably closer to 10.

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sun Oct 11, 2015 11:35 am
by lostcaggy
I had a similar problem with that step. Ran it a couple of times and it did eventually install but did take quite a while

Re: Any tutorials on how to make a simple Menu app in Python

Posted: Sun Oct 11, 2015 12:27 pm
by JimmyN
I skipped the step installing pip 7.2 from source and used the pip 1.1 already installed.

Code: Select all

sudo pip install --upgrade cython
Cython install completed after that, so I installed "pygments" and "docutils"

Kivy installed without a problem and I've gone through the examples and demos and it's working great.

Kivy is really nice... and the pictures demo is a good example of multi-touch, pretty awesome. Now I just have to go through the example scripts and learn how to use it.