Kivy Interactive Sandbox Example


The Kivy Interactive Sandbox (aka kivy.interactive.InteractiveLauncher) seems to be a powerful tool to help Kivy developers. “The InteractiveLauncher provides a user-friendly python shell interface to an App so that it can be prototyped and debugged interactively.”

For example, you can take advantage of IPython’s Tab Completion feature to discover Kivy’s class methods and properties.

I first heard about this when I tried to follow Gabriel Pettier’s YouTube Example of Brian Knapp’s Work, but the font was too small for me.

Then I found the documentation for Brian’s work here.

The following are my notes on getting this running. I did this on Windows XP. This article is divided into 2 sections.

Section-1 Preparation of Paths
Prepare & check that the os.getenv(‘path’) and sys.path for IPython work with the Kivy installation. Step-1 Open a Command Window – Prepare Paths. Step-2 In SAME Command Window – Check Paths.
Section-2 Running the Interactive Development Example
Given the preparation is complete, run the Interactive Development Example. Step-3 In SAME Command Window in IPython – Paste the PART_TO_PASTE. Step-4 In SAME Command Window in IPython – Type in the Interactive Commands one at a time.

Section-1 Preparation & Checking of Paths

I am assuming you have already downloaded & installed Kivy, see this link.

For my Windows XP Kivy-1.8.0-py2.7-win32 installation, I am using the “Send-to method” to Start a Kivy Application.

Here’s what I do to prepare & check that the os.getenv(‘path’) and sys.path for IPython work with my Kivy installation.

Step-1 Open a Command Window – Prepare Paths.

Open a cmd window & say something like the following 2 commands to see the listed output.

>cd "PATH_TO_KIVY_INSTALL\kivy\examples"
botstrapping Kivy @ C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32
Setting Environment Variables:
C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32gstreamerregistry.bin
C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32gstreamerlibgstreamer-1.0
C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32;C:Documents and SettingsjoeMy Documents
downloadskivyKivy-1.8.0-py2.7-win32Python27;C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-w
in32tools;C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32Python27Scripts;C:Documents an
d SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32gstreamerbin;C:Documents and SettingsjoeMy Documentsd
ownloadskivyKivy-1.8.0-py2.7-win32MinGWbin;C:Program FilesJavajdk1.7.0_10bin;C:WINDOWSsystem32;C:WINDOWS;C:WINDO
WSSystem32Wbem;C:1bat;C:Python27;C:Python27Scripts;C:Program FilesTortoiseHg;C:Program FilesTortoiseSVNbin;C:Pr
ogram FilesNotepad++
C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32kivy;
done bootstraping kivy...have fun!n

- Running a shell, you can browse kivyexamples and launch apps with: -
- python -

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Step-2 In SAME Command Window – Check Paths.

Next, IN THE SAME COMMAND WINDOW, start IPython. Check to see that the os.getenv(‘path’) and sys.path are good.

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: pwd
Out[1]: u'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32kivyexamples'

In [2]: import sys, os

In [3]: sys.path
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32kivy',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32kivyexamples',

In [4]: os.getenv('path').split(';')
['C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32Python27',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32tools',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32Python27Scripts',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32gstreamerbin',
 'C:Documents and SettingsjoeMy DocumentsdownloadskivyKivy-1.8.0-py2.7-win32MinGWbin',
 'C:Program FilesJavajdk1.7.0_10bin',
 'C:Program FilesTortoiseHg',
 'C:Program FilesTortoiseSVNbin',
 'C:Program FilesNotepad++']

In [5]:

Section-2 Running the Interactive Development Example

Step-3 In SAME Command Window in IPython – Paste the PART_TO_PASTE.

Next, in the same Command Window, in IPython, %paste the PART_TO_PASTE (shown below) of the Interactive Development example into IPython.

from kivy.interactive import InteractiveLauncher
from import App
from kivy.uix.widget import Widget
from import Color, Ellipse

class MyPaintWidget(Widget):
    def on_touch_down(self, touch):
        with self.canvas:
            Color(1, 1, 0)
            d = 30.
            Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))

class TestApp(App):
    def build(self):
        return Widget()

i = InteractiveLauncher(TestApp())

Step-4 In SAME Command Window in IPython – Type in the Interactive Commands one at a time.

Now, one at a time, even though IPython is not showing an input prompt, type in the Interactive Commands from the Interactive Development example into IPython as shown below.

i.       # press 'tab' to list attributes of the app - results in the ipython window

i.root.  # press 'tab' to list attributes of the root widget - results in the ipython window

# App is boring.  Attach a new widget! - results in the App window
# click in the app and yellow dots will show up 

# The application is now blocked.
# Click on the screen several times. - dots won't show up 
#    N.B. in windows, window turns white & says "Test (Not Responding)"

# The clicks will show up now
#    N.B. In Windows XP, dots show up & clicks again produce yellow dots on black background 
#        but the Test taskbar button still says "Test (Not Responding)" even though it is.

# Erase artwork and start over
# On Windows SP, clicks don't work until after, in ipython, you say "i.root.add_widget(MyPaintWidget())" again

# click in the app and yellow dots will show up 

Here’s a short link

I hope this helps you.

Love and peace,

Python NWC tool to reverse selected notes in a staff

Here’s the python code. Enjoy.

This code needs to import see

""" Reverses the Notes that are selected in a NoteWorthy Composer staff


import sys
import nwctxt # see
import logging
logging.basicConfig(filename='joeNWC_PY.log',level=logging.DEBUG)  # DEBUG => print ALL msgs

clip = nwctxt.NWC2Clip()
PlayContext = nwctxt.NWC2PlayContext()
txtItemL = clip.Items
clipItemL = [nwctxt.NWC2ClipItem(txtItem) for txtItem in txtItemL]
first2 = clipItemL[:2]
reversedClipItemL = first2 + list(reversed(clipItemL[2:]))
reversedTextItemL = [item.ReconstructClipText() for item in reversedClipItemL]

print clip.GetClipHeader()
for textItem in reversedTextItemL[2:]:
    #print "clipItem.GetObjType()= %s, type(clipItem.GetObjType())= %s, "%(clipItem.GetObjType(), type(clipItem.GetObjType()))
    print textItem
print clip.GetClipFooter()

# sys.exit(nwctxt.NWC2RC_REPORT) 

Essential Music Links

Music Software

NoteWorthy Composer
A music notation software authoring tool for Windows.
A Python Toolkit for Computer-Aided Musicology and Musical Analysis.
Create, play and print beautiful sheet music.
The standard open format for exchanging digital sheet music.
LilyPond is a music engraving program, devoted to producing the highest-quality sheet music possible.

Ear Training

The Musical Intervals Tutor
A study aid to help you learn the sounds of the basic music intervals from minor second to perfect octave.
Big Ears
The Original Online Ear Trainer!


Dolmetsch Online
Music theory & history online.