Sunday, May 25, 2014

3. Running Kivy on Windows

The same Python code is run, as in Example 2, but this time on Windows.




The Windows file, which is downloaded, is highlighted. You might want to use the other version, for Python 2.7, if you want to use an old library. However, the future in Python World is Python 3.




After downloading the zip file, extract it to a folder. The folder used here is Kivy, in the C drive. Note the contents of the folder. There is a MinGW compiler to compile C source code. There is the Python33 folder with the Python 3.3. The most important file is kivy.bat, the only file which we will call, and which, in turn, will call other libraries.




Next the path is updated to include the Kivy program. This is optional. If it is done, you can refer to bat file as kivy, rather than C:\Kivy\kivy, or whatever the full path may be in your installation. These instructions are for Windows 7. From the Control Panel, find the System. Then go to Advanced system settings.




At the bottom of the dialog, there is a button for Environment Variables, which should be clicked. In System variables, select Path and click on Edit.




The path is a list of folders separated by semicolons. After the last semicolon, type C:\Kivy and a semicolon. Select OK repeatedly to close all dialogs that may be open.




You can always open the command prompt, by searching for cmd, at the Start. The next step is totally optional. In the command prompt, if you click on the icon at the top-left corner, you can see many options, including Defaults. Selecting this allows us to have different font size, and different colors, rather than the standard ones, in all future sessions.




Some settings have been changed here, as you can see. The most important command besides calling kivy.bat is the cd command. The command cd stands for change directory and by writing two dots, we go up the folder tree. By writing the name after cd, we go into the directory. We should go into the directory where the python file is written, which is C:\ KivyEx in this Example. Now kivy is called by simply writing kivy and the python file.




In case, the Path was not set, you will have to type the entire path before kivy. This is shown here. If we had a very complex folder structure, setting the Path would make more of a difference. Here, we only have slightly more typing, and little chance of error in typing. However if we have a very long name, chances of error increase.




You can also install Kivy as a normal Python module in Windows. First you will have to install Python, if you don't already have it. Then you can find information, about using Kivy with existing Python, from links, from the Kivy homepage.




It will lead to this webpage with the downloads. You can select for the version of Python and the Windows operating system. Now, you can open Python IDLE and write things like import kivy and help(kivy). Instead of the Windows route, I went through the Linux Ubuntu route, since it has everything installed after installing the operating system. It has a better Terminal application, than, the command prompt in Windows. Since Android uses an operating system based on Linux, you can see there is nothing inherently beneficial about using Windows.




1 comment: