Version 70 of Tcl/Tk on android poll

Updated 2013-11-16 15:28:48 by MH

This page to collect information about the interest of the community to combine development effort to get tcl/tk on Android platform.

Why do we need this tcl/tk on Android?

It's becoming a huge platform:

We have

Mobile phones
Cheap Tablets less then 80 euros
In the near future android in TV-sets
A projector already exists with Android inside.
...

Tcl/Tk isn't available on these platforms.

People have no problems to install apps. So they migrate away from webcentric which is great for tcl/tk.

What is already available to us: We have jtcl and hecl to start from. My feeling is Hecl is the most closely what we need/want but isn't 100% compatible. A wrapper should be added to Hecl to add TK syntax.

Please add yourself to following table if you are interested to help to get development forward.

NicknameJava knowledgetcl knowledgedocstest/feedback
nobelminorgoodminora lot of physical android devices available
RSfew - looked several times, but hated itmuch?1 tablet, 1 phone
...

chw - 2013-03-27 12:41:16

chw: What about porting Tcl/Tk native on Android? There's an SDL port for Android on http://libsdl-android.sourceforge.net and there's a SDL backend for Tk on http://wiki.tcl.tk/4607 .

MG doesn't know exactly what's involved, and certainly lacks the skills to contribute to such an endeavour himself, but would really love to see Tk ported to Android if at all possible.

MiR: Just wanted to support this. I actually have an old EEE PC as my mobile workhorse and I use lot's of little TCL-TK apps for my needs. What keeps me from upgrading is the lack of Tcl/Tk support on Android and I don't want to hack a tablet into Linux. A native port would be great, rewriting all apps /to hecl or jtcl) is near impossible to me.

bwo: MiR is right, native Tcl/Tk support would enable lots of existing tools to be used on android.

RS On my Android tablet (TrekStor Breeze, 69€) I actually have Pat Thoyts' port of Tcl based on ASE (no Tk). I played around with it in May 2013, and of course with the most juicy parts provided by the android package: speech recognition, text to speech...

Crosspost from Google+: "HA!! My Tablet just said "guten Morgen" to me! Using the following Tcl code:

 package require android
 set a [android new]
 proc s args {$::a speak $args}
 s guten morgen

(It is localized to German - attempts at English are forgettable...) Now to plan what I can do with it ;^)"

My plans are mostly to build a tool for my almost-blind father - voice menus, ebook-to-speech (or simpler: just playing audiobook files) and such.. but too many plans, too little time...


chw - 2013-11-05

chw: after lengthy preparation updating the SDL stuff from SDL 1.2 to SDL 2.0 I was able to build Tcl/Tk for Android. An early snapshot can be obtained from http://www.ch-werner.de/sdltk/AndroWish (source tarball and Android ARM debug APK).

Remember, remember, this is Tk natively on Android where the X11 drawing/rendering is replaced by AGG, freetype, and SDL thanks to an earlier effort of Tim Baker who did that some years ago for Win32.

AMG: Looks very promising. But there's a huge problem: the space bar on my Bluetooth keyboard isn't working. This makes it impossible to write anything more than "exit". Before you ask, the space bar works in other apps. Also, outside of using a proper computer to do it, I can't figure out how to save code from the Wiki to a text file suitable to be sourced. The closest I can come is appending ".code" to the URL which shows me the code, but Android browsers lack the ability to save anything they didn't think was a "download" to begin with.

LES: I think that copying and/or editing directly on the phone is very uncomfortable. You should install something like SSHDroid so you can SSH into the phone from your PC over Wifi and do everything in that terminal session. Or, if you insist on relying solely on the phone, you can install TextWarrior, select and copy all the ".code" from the browser view and paste into a new text file with TextWarrior.

EF yes!!!! Fantastic! And the space bar works on my nexus 7 without any problems...

nobel On my samsung note it works also fantastic. Very fast loading indeed! This is very useful. Editing on the device no problem Running as a TCP socket server, no problem. Great! Great! Great........! I tried on a cheaper tablet with only android 2.2 but it cannot parse the apk package after download.

nobel Did another test with canvas. Canvas items are rendered with antialiasing so its beautiful. Binding <B1-motion> on the items doesn't seem to work with touchscreen. But hey, this is already great.

JM it works on my cheap tablet with android 4.1.1

RS 2013-11-06 Seems to work (need more experimenting) on TrekStor Breeze 7" tablet, Android 4.0.4. Same on Huawei Ascend Y300 phone, Android 4.1.1. Wow! Big thanks! Updates:

 DejaVu LGC Sans
 DejaVu LGC Sans Mono
 DejaVu LGC Serif
  • Canvas animations: Toy cars, Postcard from Switzerland trains3.tcl work too (the latter is a bit slow...).
  • Only landscape orientation is available.
  • The virtual keyboard disappears when switching between apps, and I haven't found out yet how to get it back, other than kill and restart AndroWish... :-(

Maybe I should get a Bluetooth keyboard (but test before buying whether <Space> works :^)

Update: bought a Rapoo E6100 keyboard today. Beautifully designed, but: in AndroWish it does not deliver a single keystroke. In other apps (Terminal Emulator, Jota+ text editor) it works, but assumes US keyboard layout instead of the German QWERTZ I have. It's not only the Z vs. Y, many punctuations are in other places than seen on the keyboard, and it seems to be a black art to fix that... :-O


chw 2013-11-06: a new improved version is available. It now supports screen rotation and has better handling of the onscreen keyboard. Just touch an entry or text widget (which is not disabled, of course) and the onscreen keyboard becomes visible.

The fonts now are full DejaVu incl. Arabic and Hebrew. As per SDL2-2.0.0 the minimum supported Android version is 2.3.3.

The debug APK now contains the shared libaries for x86, too (for you guys having Atom powered phones and tablets :-).

Sadly, the <Space> key on my wireless USB keyboard doesn't work either. And its keymap in my 4.0.1 tablet is weird ... and the SDL clipboard support crashes the entire application (therefore disabled) ... and most likely there are still hundreds other little bugs and annoyances.

There's still much to do ...


RS Please keep up the good work, chw! You made a dream of many Tcl/Tk users come true... :^) Update: the Rapoo keyboard now is recognized by AndroWish, except... for <Space>... but we're getting ahead :-D

Workaround for <Space>: in the new "portrait" format, we can leave the virtual keyboard up (using it only for <space>), and do the rest on the physical Bluetooth thing. Using the "Hacker's Keyboard", one can reduce the height of the keys so it takes up less than 1/4 of the screen.

I can also confirm that the virtual keyboard now comes up reliably whenever I touch an input field. Good job, chw!

chw that went magically, I suppose. I had similar effects with my wireless USB keyboard. It was recognized by the tablet but nothing happened in AndroWish and it suddenly worked (although it had not the proper keymap layout). Still unclear who's the culprit. Maybe some Android magic IME which does not well with SDL2-2.0.0.

JM agrees, as this is bringing fresh air to Tcl/Tk...Thanks.

EF has anyone come any far as to how to access the rest of the android platform? I don't even know if this is possible, but accessing things such as the values of the sensors, or being able to place notifications for example... Or force, follow, be notified of the current orientation.


RS See Android - An Open Handset Alliance Project for links to Pat Thoyts's activities to bring Tcl to Android, including its speech recognition and generation.


chw That ASE piece is IMO a rather complex thing which is required to get around missing Android introspection features (am I correct in this prejudice???). It might have the problem that for each new feature of the Android world someone has to enhance the ASE glue in order to expose that feature to the scripting world (am I correct in this prejudice???).

Parts of the sensors et.al. are right now exposed through SDL functions, thus it might be a task of adding calls to those functions in the C layer of Tk (the "sdltk" command) in order to read out the sensors. Regarding orientation I hope (didn't try that) that a <Configure> event handler on a toplevel with "wm attributes -fullscreen 1" might detect changes in screen orientation.


RS I have one wish: is there, or can there be, a filename which, if existing, is sourced at startup time? For example, androwishrc.tcl? Users could put their initialisation there (change console font size, cd $HOME, whatever) to reduce typing.

And another: how does one associate AndroWish with .tcl files, so it gets called when they are touched in File Explorer?


AM Just hopping on the bandwagon, I suppose, as I am utterly unfamiliar with the Android environment, but am intrigued by the possibilities of smartphones. I installed it, that was no problem at all, I could type some commands in the console and see the result in the main toplevel window, but I could not see the contents of the "data" directory - "permission denied". That made me think: how can you handle (source) files in this environment?


RS Android can be quite paranoid with user rights, and /data is the place where apps are installed. For me, AndroWish starts in /, and I put my scripts in /sdcard/home, where I have all privileges. (Most conveniently by USB-docking the phone to a PC, where its SD cards are mounted as external drives.)

AM Ah, so that is it. I would never have thought of looking there :). Thanks.


chw 2013-11-08 updated the package. It now has the environment variables ($HOME et.al.) set up properly in order to source .wishrc when in interactive mode as on other UN*Xy systems. $HOME happens to be identical with the app's internal storage path ("/data/data/tk.tcl.wish/files" which is writable). And that is also $TMPDIR (important for exec). <Space> now is no final frontier anymore, at least on my space cadet USB wireless keyboard. RS's idea with the .tcl file name extension associated to AndroWish is on my wish list, too, but seems to require heavy patching in SDL2. To exercise adding loadable extensions to AndroWish, the current SQLite 3 version is included in the package (try "package require sqlite3").

Now for the wish list in arbitrary order:

 * port to Tcl/Tk 8.6 (the code base now is 8.4.20)
 * make .tcl file association work (Android intent)
 * fix the SDL clipboard
 * glue to the Android world (ASE or PhoneGap)
 * have an easy day
 * find and hunt down bugs

What is needed to work on it?

 * a Linux development system (mine is CentOS 6) with Android SDK and NDK
 * the source tarball from http://www.ch-werner.de/sdltk/AndroWish/AndroWish-source.tar.bz2
 * optionally a tablet or phone for testing, otherwise the emulators from Android SDK
 * coffee and cigarettes
 * to build the package "ant debug"

What about making your standalone app?

 * add a directory below "assets" in the unpacked source tree called "app"
 * put your Tcl source code in "assets/app", the initial file sourced is "main.tcl"
 * replace "AndroWish" by the app name in various places I don't exactly remember
 * "ant debug" and test

RS Good news! Can't wait to test... but for your URL, T-online reports it is "currently not available". Have you been slashdotted/heised? :) You could directly upload the .apk to this Wiki. Create a new page like AndroWish 0.3 (just click on one of the blue brackets), don't write in the edit window, but click on "Upload" below.

Big progress... .apk downloaded and running, Bluetooth keyboard works as announced (space, alphanumerics and all), cd ~ goes to the announced directory, package require sqlite3 reports 3.8.1.. now to write a .wishrc... :D

More progress.. wrote a trivial .wishrc ("puts hello") in /sdcard/home (because Jota+ doesn't let me edit in /data), let AndroWish copy it to $HOME, restarted.. and got "hello" :D Excellent.

For file transfer, I'd prefer my $HOME on sdcard0 or sdcard1 (those get mounted on netbook when USB-connected - but not /data and below that). Solution: I have a small file .wishrc in /data/data... which contains

 set env(HOME) /sdcard/home
 cd ~
 source wishrc.tcl

And that latter file will contain the real customizing code. Ah, AndroWish surely is a beautiful thing :^D

  • sqlite3 is operable - tested with the "hello world" example at http://paste.tclers.tk/2947
  • changing the geometry of the console window seems not to work - I set it to 480x800, it reports 6269x16808 ...
  • adapting the console size seems not to work with
 console eval {.console config -width 40}

JM Nov-9-2013, Wow! Turtleshell also works nicely. squared buttons probably needed. - RS Thanks for testing it! I had forgotten it myself... ;^)

BTW, tcl_platform(platform) contains "unix", could we add the adjustment of this to the wish list? - RS Well, Android is based on a Linux (and hence Unix) kernel. As the tcl_platform page shows, there seem to be only three values for tcl_platform(platform): "macintosh" (ancient), "unix", "windows". More detailed is tcl_platform(os), where AndroWish has "Linux" (likewise in the Tclkit for Android from Roy Keene' nightly builds). Maybe "Android" would be clearer there.

nobel This great port of tickle to android deserves its own page now. I guess that's the way to go. For tcl/tk 8.6 will the themeing widget be like an android look-alike or will it be the widget themes from the unix port. I'm installing the android development tools so I can help in the development for the best I can. Socket programming without threads needed... Heaven! Even Hecl needed a threads. Thanks again for the great native port!


AMG: I'm using a Samsung Note 10.1 running Android 4.1.2. Don't know why my space bar doesn't work.

AMG, update 9 Nov, 2013: Now my space bar works, but all the alphanumerics are ignored! Backspace, left, right, enter, and space work, but nothing else, as far as I can tell. I should mention that I'm using a Logitech K810 . Also, using Windows 7 Bluetooth Device Control works perfectly as a keyboard and mouse.


chw 2013-11-16: the package is updated again. Some bugs are fixed ("wm attribute -fullscreen" handling, crashes when windows were closed before all pointer events were handled) and hopefully most of SDL2's APIs exposing Android specifics are available now (app life-cycle, accelerometer, finger events, power management info).

As a proof of concept these are available through "sdltk powerinfo", "sdltk accelerometer on|off" and a bunch of virtual events which get reported to toplevel widgets when bound. For a demo see the file "/assets/sdl2tk8.4/demos/ademo.tcl" in the http://www.ch-werner.de/sdltk/AndroWish/AndroWish-debug.apk (yes, it is a ZIP file).

Additionally I've added the 8.4 dict backport, tcllib1.15, SDL2_mixer and the TclMixer extension. Try "source /assets/tclmixer1.2.3/test.tcl" and you should hear your tablet playing music from Tcl/Tk.

I now own this kool K810 Logitech illuminati keyboard, too, but with German keyboard layout and it unfortunately works flawlessly with both a cheap rooted ARM tablet and an ASUS Fonepad with Atom processor. I'm still unable to reproduce AMG's problems.

RS Of course I had to download it immediately. sdltk powerinfo seems to work. I'm not sure what the accelerometer does. Very helpful: one can resize the console via

 console eval {wm geometry . 60x32}

Now to tweak its font a little bigger... {DejaVu LGC Sans Mono} 20 does the job for my old eyes on the 4" phone, with a geometry of 37x20. (That is character unitts - shouldn't wm geometry deal in pixel units?

MH2 May be it would be possible to integrate Hecl (http://hecl.org ) with AndroWish??? hecl is a tcl-like interpreter written in Java (for android), it can use ALL Java classes; there could be a sub-intepreter called "hecl", and we could use it in this way:

 hecl eval {
  set i1 [intent -new [list ACTION_SENDTO]]
  set u1 [uri parse "mailto:[email protected]"]
  $i1 setdata $u1
  [activity] startActivity $i1
 }