Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AndroWish - start Tcl/Tk scripts

261 views
Skip to first unread message

hae

unread,
Apr 1, 2019, 3:20:53 PM4/1/19
to
Hello,

I have AndroWish on my smartphone. Having th console and playing games is fun. However it feels clumsy to select tcltk files. How do you automatically start tcltk script with androwish.
Is there already a dsecription how to do it? Can you give me a pointer?

Regards,
Rüdiger

Rich

unread,
Apr 1, 2019, 9:25:20 PM4/1/19
to
Read the documenation of the "borg shortcut" subcommand here:

https://www.androwish.org/index.html/wiki?name=Android+facilities

Andreas Leitgeb

unread,
Apr 2, 2019, 3:27:55 AM4/2/19
to
I admit I also rather try stuff than read docs...

Just recently I noticed, that I can open tcl files from file managers
(total commander in my case), picking AndroWish as the app, and it works.

There are still a few "problems", like that AndroWish isn't persistent.
Switch away from AndroWish to e.g. a browser with a couple of tabs open,
then switch back, and Androwish will have suffered full amnesia and just
starts the script anew.

Another problem I saw (but that is probably quite specific) is that if
my app doesn't use entry widgets, but still wants to receive keystrokes,
then I need to activate the console (which makes the keyboard pop up)
and then go back to the application window (which luckily leaves the
keyboard open).

Andreas Leitgeb

unread,
Apr 2, 2019, 3:36:25 AM4/2/19
to
Isn't there a hen&egg problem, if the tcl script needs to run to
create a shortcut, but one wants to tap some shortcut to start
the tcl script? ;-)

It's still good advice for the case that OP just wants to
manually create some shortcuts from console for his own device.

If OP wants to deliver a tcl app to tcl-non-experts, then he
might rather look for documentation about creating a custom
package.

hae

unread,
Apr 2, 2019, 3:59:33 AM4/2/19
to
Am Dienstag, 2. April 2019 03:25:20 UTC+2 schrieb Rich:
Thanks, that is what I wanted.

Gerhard Reithofer

unread,
Apr 2, 2019, 6:32:03 AM4/2/19
to
Hi,
1st you should not forget that Android is not designed to run various
scripts using just a single "executable" from an Android App. An app is
a package which is designed to contain all resources required for the
complete application. How to create this one can be found on Christians
http://www.androwish.org

Of course it is possble to start a single script by "Click to
AndroWish icon", the .wishrc of AndroWish can be used for that.

My solution is similar as shown on:
https://wiki.tcl-lang.org/page/AndroWish%3A+Tips+and+Tricks
where several solutions are described.

What I wanted is to "configure" one script which is started always. This
can be changed if another one should be executed in future.
I also have defined a fixed name for the script which becomes executed
if it exists, the name is "autostart.tcl" on a fixed localtion which is
the directory TCL on the SD-card (EXTERNAL_STORAGE) in my case.

My "setup-script" called setup_wrc.tcl creates the .wishrc file
accordingly:
---
# setup_wrc.tcl
# Create or update $HOME/.wishrc
#
set wishrc_src {
#
# WishRC startup script .wishrc
#
set source_dir [file join $env(EXTERNAL_STORAGE) TCL]
set auto_start [file join $source_dir autostart.tcl]

cd $source_dir
if {[file exist $auto_start]} {
source $auto_start
}
}

#############################################
# source directory and WishRC path
#
set source_dir [file join $env(EXTERNAL_STORAGE) TCL]
set wishrc_dst [file join $env(HOME) .wishrc]

puts -nonewline "Creating new WISHRC $wishrc_dst ... "
set fo [open $wishrc_dst {WRONLY CREAT TRUNC}]
puts $fo $wishrc_src
close $fo
puts "ok.\nContent of $wishrc_dst:"

set fi [open $wishrc_dst {RDONLY}]
puts [read $fi]
close $fi
puts "New WISHRC $wishrc_dst installed."
---

My favourite autostart.tcl is:
---
#
# Autostart script
#

set source_dir [file join $env(EXTERNAL_STORAGE) TCL]
sdltk textinput on
set script [tk_getOpenFile -initialdir $source_dir]

if {$script != ""} {
console hide
source $script
} else {
puts "Hello!\nNo AndroWish start script selected."
}
---

It opens the file browser to select a script from the TCL source
directory (/mnt/sdcard/TCL).

It is up to you to write a program which provides a list of scripts that
can be started on "button click" by autostart.tcl. This could be
dynamically created by scanning a directory which contains a list of all
available start scripts to execute, etc.

Bye,
Gerhard

--
Gerhard Reithofer - Techn. EDV Reithofer - http://www.tech-edv.co.at

Rich

unread,
Apr 2, 2019, 1:48:40 PM4/2/19
to
Andreas Leitgeb <a...@logic.at> wrote:
> Rich <ri...@example.invalid> wrote:
>> hae <r_ha...@gmx.de> wrote:
>>> I have AndroWish on my smartphone. Having th console and playing
>>> games is fun. However it feels clumsy to select tcltk files. How do
>>> you automatically start tcltk script with androwish. Is there
>>> already a dsecription how to do it? Can you give me a pointer?
>> Read the documenation of the "borg shortcut" subcommand here:
>> https://www.androwish.org/index.html/wiki?name=Android+facilities
>
> Isn't there a hen&egg problem, if the tcl script needs to run to
> create a shortcut, but one wants to tap some shortcut to start
> the tcl script? ;-)

One can run the commands from the console of a vanilla androwish app on
the device to setup the 'desktop' link to another script.

Starting the vanallia androwish app, one gets a standard Tcl console
window.

> If OP wants to deliver a tcl app to tcl-non-experts, then he might
> rather look for documentation about creating a custom package.

Very true, if his interest is to eventually deploy, then he will need
to look into how to wrap his scrips into a custom androwish apk to use
to deploy. But if memory serves the OP only wanted to know how to run
a script file.

Rich

unread,
Apr 2, 2019, 1:52:24 PM4/2/19
to
Andreas Leitgeb <a...@logic.at> wrote:
> There are still a few "problems", like that AndroWish isn't persistent.
> Switch away from AndroWish to e.g. a browser with a couple of tabs open,
> then switch back, and Androwish will have suffered full amnesia and just
> starts the script anew.

This might be the OS killing off the androwish app due to memory
pressure. The Android runtime environment is very different than
traditional desktops and apps are assumed to checkpoint their state
such that the OS can kill them off and restart them later without a
user noticing this happening at all.

> Another problem I saw (but that is probably quite specific) is that if
> my app doesn't use entry widgets, but still wants to receive keystrokes,
> then I need to activate the console (which makes the keyboard pop up)
> and then go back to the application window (which luckily leaves the
> keyboard open).

There is a borg or sdk sub-command relating to keyboard management.
To generate keystrokes you need the keyboard on screen. If the borg or
sdk subcommand for keyboards includes an "activate keyboard" option,
that might open up the keyboard for you, without having to jump through
the console.

Gerald Lester

unread,
Apr 2, 2019, 6:50:39 PM4/2/19
to
See:
http://chiselapp.com/user/gwlester/repository/AndroWishApplications/artifact/eb5a543e547cc99c


--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+
0 new messages