User:Rmyers/IDLE on the XO
I decided to try to get the IDLE environment working on the XO. I wanted an XO based Python IDE that I could use to show Python code, and which would allow intermediate level development directly on the XO. As Develop matures this will probably no longer be necessary.
IDLE is inherently a multi-window application. It has windows open for the Python shell, files that you are editing, and support functions such as class browsers. As such, it is not well suited to use under Sugar, where each window appears as a separate item (with generic round disc icon) on the task circle. It works better in a environment that better supports multi-window applications, such as XFCE. See the Xfce page for installation instructions.
Currently, I haven't been able to create at totally successful installation of IDLE. There is a font issue that exists in the current production builds of the XO software and a text navigation and selection issue that exists in the Joyride builds. They are discussed below.
So at this time, IDLE can be enabled and explored on the XO. However, it is not yet a fully satisfactory solution for XO resident Python development.
What's already there
The Python 2.5 distribution that comes on the XO already contains IDLE. The IDLE library is located at /usr/lib/Python2.5/idlelib. The IDLE main module is idle.py.
So in a terminal window you ought to be able to
cd /usr/lib/python2.5/idlelib python idle.py
to fire it up.
This doesn't quite work. You'll get a message that tkinter is missing.
Tk is a platform independent GUI framework.
Tkinter is the Python binding to it. By default this is not installed on the XO.
IDLE requires tkinter for some graphics services.
Tkinter can be installed by doing the following:
su yum install tkinter exit
(If your XO is not connected to the network, you can also install tkinter manually, by going to a mirror like http://ftp.linux.org.uk/pub/distributions/fedora/linux/updates/9/i386.newkey/ and downloading the following packages: tcl-8.5.2-2.fc9.i386.rpm tix-8.4.2-6.fc9.i386.rpm tk-8.5.2-1.fc9.i386.rpm tkinter-2.5.1-26.fc9.i386.rpm then put the USB stick in the XO and use sudo rpm -i *.rpm in that directory.
Tkinter should now be installed at /usr/lib/python2.5/lib-tk.
There are some modules of this that can be run from python that will give you an idea what services are provided.
Under the current production builds of the XO software there is an issue with fonts under tkinter. Tkinter doesn't seem to recognize the fonts that are installed on the XO. It does so so completely that even the size is not selectable for the default font. As a result all text is rendered as what would be 10 point font, except for the tight dot pitch of the XO screen, which causes it to render as about 5 point. This is tight enough that many people will need magnification to use, and not suitable for extensive work.
I asked on the development list about this and received no response. I have not filed a ticket on this, as the problem has been resolved in Joyride, and I expect that current Joyride improvements will soon be incorporated in mainstream XO builds.
Under Joyride the menu and dialog fonts are still small. I believe that this behavior is hard coded in tkinter. I assume tkinter could be modified to enlarge these. I don't consider the menu issue to be major, as this is subsidiary to actually editing and viewing the code.
Mouse click issue in Joyride
However, there seems to be a regression in Joyride with regard to mouse handling. Under Joyride, the insertion point cannot be changed by clicking, and text can not be selected by clicking and dragging. The cursor can still be moved with the cursor keys and selection can be made with shift and cursor keys. However this is a real limitation to the ease of editing. Mouse clicks still work in menus and dialogs.
A ticket has been filed on this issue 7661
This may actually be a problem in IDLE or its underlying libraries rather than the XO. Running IDLE on a Macintosh I sometimes get into a condition where the selection point doesn't follow the I beam cursor. Selection occurs, but starts at the previous selection point, rther than the click point.
IDLE under Sugar
IDLE is inherently a multi-window application. Sugar, at this time, handle multi-window applications windows poorly. The windows show up as separate generic item in the task ring (or bar in Joyride). IDLE can be used, but with limited ease.
An activity wrapper could be made to make IDLE available from the activity list. I haven't done this given IDLE's limitations under Sugar.
To run IDLE under Sugar, I start Terminal, cd to the IDLE directory and start it directly with Python as mentioned above.
IDLE under XFCE
IDLE under XFCE is a more pleasant experience, as XFCE handles multi-window applications.
It is simple to get IDLE working as a button on XFCE's task bar
create a simple script 'startidle.sh' in /home/olpc:
cd /usr/lib/python2.5/idlelib python idle.py
save it and
chmod +x startidle.sh
On the XFCE taskbar
right click on the taskbar select 'Add New Item' select 'Launcher' set Name to IDLE set Command to './startidle.sh' click 'Close'
Now clicking the IDLE taskbar item should start IDLE.