ラベル Tcl 関連 の投稿を表示しています。 すべての投稿を表示
ラベル Tcl 関連 の投稿を表示しています。 すべての投稿を表示

2019-06-24

Apache Rivet 3.1.1

Apache Rivet は Apache HTTP Server のモジュールで、PHP のようにサーバ・サイドで動的な Web ページを作成できる Tcl システムです[1]。現バージョンの Rivet 3.x 系は Apache 2.2.x と 2.4.x に対応しています。Tcl はバージョン 8.6 以上が推奨されています。

しばらく Rivet の RPM パッケージを更新していませんでしたが、Rivet の方は着々と更新を重ねてバージョン 3 系 (3.1.1) になっていました。気が付いた時に RPM パッケージを更新しないと、と思い立ち、Fedora 30 向けに更新した RPM パッケージを公開しました[2]。Rivet 3.1 は Tcl 8.5.10 以上が必要ですが、RPM パッケージを作成するときに 8.5 と 8.6 の場合分けが面倒だったので依存パッケージで Tcl 8.6 以上必要としてしまいました。ご了承下さい。

※ Tcl のバージョンに対応したものに差し替えました。 mod_rivet-3.1.1-2.fc30.x86_64.rpm [2019-07-01]

参考サイト [3] で紹介されているカレンダーを表示するサンプルを紹介します。実行には Tcl の他に Incr Tcl (itcl) がインストールされている必要があります。

カレンダーを表示するサンプル 
<? set hello_message "Calendar" ?>
<html>
  <head>
    <title><? puts $hello_message ?></title>
  </head>
  <body><?
package require Calendar

proc ::cal_cell_attributes {day month year weekday} {
    if {$weekday == 3} {
        return [list class curr_wkday]
    }
}

set htmlc [HtmlCalendar #auto]
set html_txt [$htmlc emit \
        -container {table class calendar} \
        -current_weekday 3 \
        -cell_function cal_cell_attributes]
puts $html_txt
?></body>
</html>

これを calendar.rvt というように、拡張子 rvt のついたファイル名で保存し、保存したファイルを Web サーバー (Apache) からブラウザで読み込むと以下のようになります。


参考 サイト

  1. Rivet - Webscripting for Tcl'ers
  2. Apache Rivet RPM Wiki - OSDN
  3. Examples and Usage

 

ブログランキング・にほんブログ村へにほんブログ村

2015-04-17

JTcl/Swank を試す

Swank1. は、Tk Toolkit の機能を Java で実装および拡張した GUI ツールキットで、同じく Tcl の機能を Java で実装した JTcl と一緒に利用します。むかしむかし、Jacl という、Tcl を Java で実装したものがあったのですが、機能が貧弱だったのと、C の代わりに Java で実装することに興味が無くて、すっかり忘れていました。最近、ひょんなことから JTcl を知り、Tk に相当する Swank にたどり着きました。

JTcl の開発プロジェクト2. は、Google Summaer of Code 2009 に Jacl をフォークして現代風にコードを書き直すプロジェクトとして応募されて始まりました3.。最初のリリースは翌年の 2010 年 11 月 17 日です4.。現在入手可能な JTcl は、Tcl 8.4 に準拠しています。

ちなみに swank とは、Vocabulary.com によると imposingly fashionable and elegant あるいは elegance by virtue of being fashionable という意味でつかわれる形容詞、名詞です。

Swank の配布パッケージは、参考サイト[5] からダウンロードします。Windows 用には、Swank Executable _batteries included_ (swank-3.0.0-bin.zip) をダウンロードして、適当な場所に展開します。

動作環境は次の通りです。

  • OS: Windows 8.1 (64bit)
  • Java: Java SE 1.8.0_45-b14

展開したファルダーの中の wisk.bat をダブルクリクリックすると、コマンドプロントと、ウィジェットのトップレベルが開きます。

バッチファイルを実行して上のようなメッセージが表示される場合は「詳細情報」をクリックして、「実行」ボタンをクリックしてください。

最近、Tcl/Tk を使っておらず複雑なことができないので、簡単に動作確認をしてみました。

swkcon.bat をダブルクリックすると Swank 版 tkcon-2.4 が開きます。

いろいろ試してみたのですが、少なくとも Windows 上では日本語フォントは正常に表示されないようです。今後、もう少し機能を調べて紹介していく予定です。

関連サイト

  1. Swank - Swank Project
  2. JTcl Project
  3. Accepted projects - Google Summer of Code 2009
  4. Tcl/Java - Wikipedia, the free encyclopedia
  5. Swank: Tk-like GUI Toolkit in Java/Swing: Downloads — Project Kenai

2013-10-12

Tcl/Tk 8.6.1 for Windows (32bit)

9 月 20 日に Tcl/Tk 8.6.1 がリリースされましたので、遅ればせながら Windows 用 Tcl/Tk パッケージを、Linux 上でクロスコンパイルしてビルドしました。最近 Tcl/Tk のスクリプトを業務で少々利用しているので、少し遅れましたが、それでもパッケージの更新はしっかりやらなければならないという責任感みたいなものを感じています。とは言っても、ダウンロードカウンタを見る限り、自分がビルドしたパッケージをダウンロードして利用されている方はほとんどいないように思えるので、単なる自己満足に過ぎませんが…。

ビルドした環境は下記の通りです。ダウンロードは、下記関連サイト 1. からです。

tcltk8.6.1-025-20131012.exe

Tcl/Tk for Windows, bitWalk build #025
released on 2013-10-12

1. Available version of Tcl/Tk and extensions in this package
    - Tcl/Tk 8.6.1
      (cvs)Tcl_Source_Code_2013-10-11_102635_5c6379ab2b
      (cvs)Tk_Source_Code_2013-10-04_112739_a8a2cbf090
      ftp://tcl.tk/pub/tcl/nightly-cvs/
      http://sourceforge.net/projects/tcl

2. build environment for compiling binaries 
    - MinGW64 Cross Compiler on Fedora 19
      mingw32-binutils-2.23.52.0.1-1.fc19.x86_64
      mingw32-cpp-4.8.1-1.fc19.x86_64
      mingw32-filesystem-99-1.fc19.noarch
      mingw32-gcc-4.8.1-1.fc19.x86_64
      mingw32-crt-2.0.999-0.32.trunk.r5969.20130721.fc19.noarch
      mingw32-headers-2.0.999-0.30.trunk.r5969.20130721.fc19.noarch
      http://mingw-w64.sourceforge.net/

3. packaging environment
    - Inno Setup Compiler 5.5.3
      wine-1.6-0.1.rc2.fc19.x86_64 / Fedora Linux 19
      http://www.jrsoftware.org/isinfo.php

下記は、Fedora の Wine でインストーラを起動した例です。

関連サイト

  1. Tcl/Tk for Windows Wiki - SourceForge.JP
  2. Tcl/Tk 8.6.1 Release Announcement

2013-07-11

Tcl/Tk 8.6 for Windows (32bit)

Windows 用 Tcl/Tk パッケージを、Linux 上でクロスコンパイルしてビルドしました。本当に久しぶりです。

もう二年以上前になりますが、とある自社工場の検査装置のオペレーションでポカミスが発生して、その時に簡単な整合性確認用プログラムを作って、自分でビルドした Tcl/Tk のパッケージとともに提供したことがあります。最近、他工場の同種の検査装置で同じ問題が発生したので、その時作ったプログラムを導入しようということになり、久しぶりに Tcl/Tk のパッケージを更新することになったのでした。

Tcl/Tk のパッケージには会社で使っているプログラムを含めていないので、ビットワークビルドのパッケージとして公開します。

ビルドした環境は下記の通りです。Fedora の MinGW-w64 でクロスコンパイルした Windows 32bit 用のパッケージはこれが初めてです。ダウンロードは、下記関連サイト 1. からです。

tcltk8.6-024-20130710.exe

Tcl/Tk for Windows, bitWalk build #024
released on 2013-07-10

1. Available version of Tcl/Tk and extensions in this package
    - Tcl/Tk 8.6
      (cvs)Tcl_Source_Code_2013-07-08_185613_d369017148
      (cvs)Tk_Source_Code_2013-07-07_092653_e8359b0f65
      ftp://tcl.tk/pub/tcl/nightly-cvs/
      http://sourceforge.net/projects/tcl

2. build environment for compiling binaries 
    - MinGW64 Cross Compiler on Fedora 19
      mingw32-binutils-2.23.52.0.1-1.fc19.x86_64
      mingw32-cpp-4.8.1-1.fc19.x86_64
      mingw32-filesystem-99-1.fc19.noarch
      mingw32-gcc-4.8.1-1.fc19.x86_64
      mingw32-crt-2.0.999-0.27.trunk.r5904.20130614.fc19.noarch
      mingw32-headers-2.0.999-0.27.trunk.r5904.20130614.fc19.noarch
      http://mingw-w64.sourceforge.net/

3. packaging environment
    - Inno Setup Compiler 5.5.3
      wine-1.6-0.1.rc2.fc19.x86_64 / Fedora Linux 19
      http://www.jrsoftware.org/isinfo.php

下記は、Fedora の Wine でインストーラを起動した例です。

関連サイト

  1. Tcl/Tk for Windows Wiki - SourceForge.JP
  2. MinGW-w64 で Tcl/Tk をコンパイル(32bit 用)

2011-04-15

NaTcl を試す

NaTcl -- Native Client Tcl Module は、Chrome の Native Client (NaCl) サンドボックス で Tcl スクリプトを走らせ、HTML5 の canvas に直接アクセスすることができます[1]。

Google の Native Client (NaCl)[2]を利用すると、Webブラウザからネイティブコードを安全に実行することができるのだそうです。そういえば、Chrome でネイティブコードが実行できるようになるなんて話が確かにありましたが、恥ずかしながら、すっかり忘却の彼方です。そういうわけで仕組みが解っていないのですが、とにかくインストラクションにしたがって動かしてみました。

使用した環境は、Fedora 14 (x86_64) 上の Google Chrome 11.0.696.43 beta です。

まず、Google Chrome で URL に about:flags を入力して「試験運用機能」の画面を表示します。そこで、ネイティブ クライアントを有効にします。

一旦、Google Chrome を全て終了し、コンソール上で google-chrome を --no-sandbox オプションをつけて起動します。

起動した Google Chrome で、参考サイト[1] をサクセスすると、以下のように Google の図形が表示され、マウスのポインタを近づけると、それに応じたアニメーションを見ることができます。

まだ NaTcl を使いこなすことはできませんが、ちゃんと使いこなせばおもしろいことができそうです。今後、Tk widget が動く NaTk というのも使えるようになるということで、第二の Tcl Plugin とも呼べる環境で Web プログラミングが楽しめるようになりそうです。

参考サイト

[1] NaTcl : Tcl in Nacl
[2] Native Client SDK - Google Code
[3] Tcl Announces NaTcl: Native Client Tcl - Slashdot

2011-02-12

MinGW-w64 で Tcl/Tk をコンパイル(32bit 用)

Cygwin を、用事があって Windows に久しぶりにインストールしたところ、 MinGW-w64 (GCC for both x64 & x86 Windows!)[1] を利用できることを知りました。

そこで、(当初は Fedora 15 からとアナウンスされましたが)Fedora 16 では、MinGW のクロスコンパイル環境が、MinGW-w64 のプロジェクトの成果を利用することになるようなので、それに備えて、Tcl/Tk については比較用に Cygwin/MinGW-w64 でビルドしたものをリファレンスパッケージとして公開していこうと考えています。

とりあえず nightly-CVS からダウンロードした Tcl と Tk のソースをコンパイルしたものを Inno Setup[2] でインストールパッケージ (tcltk8.6b1-020-20110212.exe) にして、SourceForge.jp の作業部屋へアップしました[3]。


参考サイト

[1] GCC for both x64 & x86 Windows! - MinGW-w64
[2] Inno Setup
[3] 作業部屋: bitwalk / Tcl/Tk for Windows - SourceForge.JP

2011-01-22

Apache Rivet

Apache Rivet は Apache HTTP Server のモジュールで、PHP のようにサーバ・サイドで動的な Web ページを作成できる Tcl システムです[1]。Tcl を応用した他の Apache のモジュールには、mod_tcl と Websh がありますが、Rivet の最新パッケージのリリースが 25-Oct-2010 と一番新しく、もっとも活動が活発なように感じたので試用してみました。現バージョンの Rivet 2.0 系は Apache 1.3 と 2.x に対応しています。Tcl はバージョン 8.5 あるいは 8.4 を必要とします。
Linux の RPM パッケージを作成するのに必要な spec ファイルが下の参考サイト [1] のダウンロードページにあったので、最新の Rivet-2.0.2 に対応できるように編集して Fedora 14 用のパッケージを作成し、インストールしてみたところ、簡単にローカルの Web サーバの環境で動作確認ができました。

[2] の Example のページで紹介されている、カレンダーを表示するサンプルを紹介します。
<? set hello_message "Calendar" ?>
<html>
  <head>
    <title><? puts $hello_message ?></title>
  </head>
  <body><?
package require Calendar

proc ::cal_cell_attributes {day month year weekday} {
    if {$weekday == 3} {
        return [list class curr_wkday]
    }
}

set htmlc [HtmlCalendar #auto]
set html_txt [$htmlc emit \
        -container {table class calendar} \
        -current_weekday 3 \
        -cell_function cal_cell_attributes]
puts $html_txt
?></body>
</html>
これを calendar.rvt というように、拡張子 rvt のついたファイル名で保存し、保存したファイルを Web サーバー (Apache) からブラウザで読み込むと以下のようになります。

最近、SourceForge.jp では、個人向け開発支援ツール「PersonalForge」がリリースされたので[2]、早速、自分のアカウントで「Apache Rivet RPM」という作業部屋を作成し、作成した RPM パッケージを公開しました[3]。
 

参考サイト

[1] Rivet - Webscripting for Tcl'ers
[2] SourceForge.JP、個人向けGitリポジトリ/ストレージサービス「PersonalForge」をリリース
[3] 作業部屋: bitwalk / Apache Rivet RPM のファイルダウンロード
[4] Apache 関連書籍

2010-12-31

Tcl and the Tk Toolkit (2nd Edition)

以前から購入しようと思っていたままだった書籍ですが、遅ればせながらやっと購入しました。この第二版は、John Ousterhout 氏と Ken Jones 氏の共著になっています。が、しかし preface(序文)は Ken Jones 氏が書いているので、実質的には彼が執筆した本のような雰囲気です。

普通の Tcl/Tk 8.5 の入門書といった内容で丁寧に解説されており、Tcl、Tk の入門的内容から、Tcl_Obj (C API) や TEA に基づいた拡張パッケージの作成までカバーされています。700 頁を越える量ですが、わかりやすくまとめられている良書だと思います。製本はペーパーバック(並製本)で、背に頁を糊付けしただけのものです。そのため、永く使い込めば、背が折れて頁が剥がれることになり、もう一冊購入なんてことになりそうです。

2010-10-31

統計解析ツール ~ 歩き始め ~

一元配置の分散分析ができたからといって、全て見通しが立ったわけではありません。しかし、自分が納得できる統計解析ツール、特に実験計画法の為の解析ツールを作りたいという欲求を抑えることができず、少しずつ GUI の部分を作り始めています。

GUI では、かゆいところに手が届くような操作性と柔軟性を実現したいので、じっくり時間をかけて作り込む予定です。若いころに BBN RS/1 というツールを VAX Station 上で使っていましたが、実験計画用のモジュール (Discover とか Explorer という名前でした)の使い心地が忘れられません。今なら GUI でもっともっと使い易く出来るはずです。



実は、むかしむかしも同じようなツールを自分で作りたいと考えていました。その時は応答曲面法 (RSM) を全面に出していましたが、行列計算の量が多く、手許の PC で実用的な処理速度を得られず、挫折してしまいました。

そもそも Tcl/Tk を使い続けている理由も、こういうツールを自分で作りたいという欲求があるからです。かつての人気はすっかり無くなってしまいましたが、Tcl/Tk の開発は止まっていません。Tktable も BLT (RBC) も利用できます。Eclipse などの統合開発環境が利用出来るので、ソフトウェアの開発が格段に楽になってきてもいます。

今回は、オーソドックスに一元配置の分散分析からはじめて、直交表までをカバーして、その次に中心複合計画やコンピュータの計算応力を駆使する最適計画など応答曲面法までを目指したいと考えています。

さて、完成はいつになるやら…。まずはアルファ版を公開することを目指します。とりあえずは決意表明をしておこう。

参考/引用文献

[1] 岩崎 学 著, 統計的データ解析入門 実験計画法 (東京図書)ISBN4-489-00725-6
 

2010-10-16

RBC - Refactored BLT Component

Fedora では Tcl/Tk 8.5 で BLT パッケージ(2.4z にパッチをあてたもの)が利用できますが、nightly-cvs の Tcl/Tk8.6 を自分でコンパイルして使用している環境では、同サイトで入手できる blt (3.0) をどうしてもうまくビルドできません。なんとかならないかとインターネット上で情報をあさっていたところ、古い記事ですが BLT 2.4z を リファクタリングした RBC についての議論を見つけました[1]。どうやら Mayo SPPDG - Mayo Clinic and Foundation の Robert W Techentin 氏が、院生のチームと一緒になって取り組んだ成果のようです。

SourceForge.net にサイト[2] が開設されているので、早速ダウンロードしてビルドしてみました。試行錯誤の後、結局、以下のようにしてビルドしました。ビルドした環境は Fedora 14 (beta) x86_64 です。
$ tar zxvf rbc0.1.src.tar.gz
$ cd rbc
$ CFLAGS="-DUSE_INTERP_RESULT" \
> ./configure --prefix=$HOME --with-tcl=../tcl/unix --with-tk=../tk/unix
$ make
$ make install
コンパイルフラグ USE_INTERP_RESULT は、Tcl 8.6 ではレガシーな (Tcl_Interp) interp->result にアクセスする際に必要になります[3]。
テスト用に BLT 用の以前用意したサンプルを RBC 用に書き換えて実行してみました。
#!/bin/sh
# the next line restarts using wish \
exec wish8.6 "$0" "$@"
 
package require rbc

proc init_x {} {
    set xList {}
    for {set i 0} {$i <= 200} {incr i} {
        lappend xList [expr $i / 5.]
    }
    return $xList
}

proc init_y {xList} {
    set yList {}
    foreach x $xList {
        lappend yList [expr sqrt($x) * sin($x)]
    }
    return $yList
}
 
# ----------------------------------------------------------------------------
# メイン
# ----------------------------------------------------------------------------
wm title . "rbc::graph"

set grp ".grp"
rbc::graph $grp \
        -title           "Sample Graph" \
        -font            "helvetica 16" \
        -rightmargin     15 \
        -plotbackground  "light cyan" \
        -plotpadx        0 \
        -plotpady        0 \
        -plotborderwidth 0
pack .grp

# ズームスタックを有効にする
#Blt_ZoomStack $grp

# X と Y 軸
$grp axis configure x \
        -subdivisions 10 \
        -tickfont     "courier 8" \
        -title        "X Axis" \
        -titlefont    "helvetica 12"
$grp axis configure y \
        -subdivisions 10 \
        -tickfont     "courier 8" \
        -title        "Y Axis" \
        -titlefont    "helvetica 12"

# グリッド
$grp grid configure \
        -color "turquoise" \
        -mapx  x \
        -mapy  y
$grp grid on

# 凡例
$grp legend configure \
        -font     "helvetica 10" \
        -ipadx    10 \
        -position bottom \
        -relief   ridge

# データ
set xList [init_x]
set yList [init_y $xList]
$grp element create func \
        -label        "sqrt(x) * sin(x)" \
        -xdata        $xList \
        -ydata        $yList \
        -smooth       quadratic \
        -linewidth    1 \
        -color        blue \
        -symbol       circle \
        -pixels       0.0625i \
        -scalesymbols yes \
        -outline      red \
        -fill         green

# ---
# sample_graph.tcl
実行例を以下に示しました。日本語フォントが表示できないし、 BLT のすべての機能が使えるわけでもなく制限はありますが、Tcl/Tk 8.6 の環境で手軽に(そこそこの)グラフを作成できそうです。

参考サイト

[1] RBC - Refactored BLT Components - Initial Release - Rhinocerus
[2] The RBC Toolkit | Download The RBC Toolkit software for free at SourceForge.net
[3] DIRECT ACCESS TO INTERP->RESULT - Tcl_SetResult manual page
 

2010-10-10

ちょっと分散分析(2)

p 値の計算をするためにガンマ関数やらベータ関数を計算するルーチンを C で作成し、Tcl の拡張パッケージ上の拡張された算術関数として利用できるようにして、その上で P 値を計算するルーチンを作ってはみましたが、計算した値が合いません。きっと自分の理解不足によるもののと考え、とりあえず諦めてしまいました(泣)。

そのかわり近似計算をしているサイトをいろいろ探し、サイト[1] を参考にして P 値を与えるルーチンを追加しました。悔しいのでもっと勉強して、自分で納得できるルーチンを作成していきます。

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh8.6 "$0" "$@"
# 分散分析
# $Id: anova_1way.tcl,v 1.6 2010/10/10 05:15:34 bitwalk Exp bitwalk $

# サンプルデータ1
set a [list {3.42  3.84  3.96  3.76}]
set b [list {3.17  3.63  3.47  3.44  3.39}]
set c [list {3.64  3.72  3.91}]

# サンプルデータ2
#set a [list {25 30 20 32}]
#set b [list {30 33 29 40 36}]
#set c [list {32 39 35 41 44}]

# データ
set data [list $a $b $c]

# -----------------------------------------------------------------------------
#  クラス anova
# -----------------------------------------------------------------------------
oo::class create anova {
    constructor {a} {
        my variable x way

        # データリスト
        set x $a
        # 分散分析の対象フラグのリセット
        set way ""
    }
    # -------------------------------------------------------------------------
    # 一元配置
    # -------------------------------------------------------------------------
    method oneway {} {
        my variable x way
        my variable n k
        my variable SSb SSw SSt
        my variable df_b df_w df_t
        my variable MSb MSw
        my variable F p

        # Sum of Squared Deviations
        # SSt (TOTAL)
        set x_simple [my list_simple $x]
        set n [llength $x_simple]
        set x_mean [my mean $x_simple $n]
        set SSt [my var $x_simple $x_mean]
        # SSb (BETWEEN GROUPS)
        set k [llength $x]
        set SSb 0
        for {set i 0} {$i < $k} {incr i} {
            set x_b($i) [my list_simple [lindex $x $i]]
            set n_b($i) [llength $x_b($i)]
            set x_mean_b($i) [my mean $x_b($i) $n_b($i)]
            set SSb [expr $SSb + $n_b($i) \
                * ($x_mean_b($i) - $x_mean) \
                * ($x_mean_b($i) - $x_mean)]           
        }
        # SSw (WITHIN GROUPS)
        # set SSw [expr $SSt - $SSb]
        set SSw 0
        for {set i 0} {$i < $k} {incr i} {
            set x_w($i) [my list_simple [lindex $x $i]]
            set n_w($i) [llength $x_w($i)]
            set x_mean_w($i) [my mean $x_w($i) $n_w($i)]
            set SSw [expr $SSw + [my var $x_w($i) $x_mean_w($i)]]
        }
        # Degree of Freedom
        set df_b [expr $k - 1]
        set df_w [expr $n - $k]
        set df_t [expr $n - 1]
        # Mean Square
        set MSb [expr $SSb / $df_b]
        set MSw [expr $SSw / $df_w]
        # F value, the ratio of the two variance estimates
        set F [expr $MSb / $MSw]
        set p [my f_pval $F $df_b $df_w]
        # flag
        set way "One Way"
        return 1
     }
    # -------------------------------------------------------------------------
    # result
    # 結果の表示
    # -------------------------------------------------------------------------
    method result {} {
        my variable way

        switch $way {
            "One Way" {
                my result_1way
            }
            default {
                puts "No result yet!"
            }
        }
    }
    # -------------------------------------------------------------------------
    # result_1way
    # 結果の表示(一元配置)
    # -------------------------------------------------------------------------
    method result_1way {} {
        my variable x
        my variable n k
        my variable SSb SSw SSt
        my variable df_b df_w df_t
        my variable MSb MSw
        my variable F p

        puts "ANOVA (1way)"
        puts "Source        SS       df       MS    F val    P Val"
        puts -nonewline "Between"
        puts -nonewline [format " %8.3f" $SSb]
        puts -nonewline [format " %8d" $df_b]
        puts -nonewline [format " %8.3f" $MSb]
        puts -nonewline [format " %8.3f" $F]
        puts -nonewline [format " %8.6f" $p]
        if {$p < 0.001} {
            puts " ***"
        } elseif {$p < 0.01} {
            puts " **"
        } elseif {$p < 0.05} {
            puts " *"
        } else {
            puts ""
        }
        puts -nonewline "Within "
        puts -nonewline [format " %8.3f" $SSw]
        puts -nonewline [format " %8d" $df_w]
        puts -nonewline [format " %8.3f" $MSw]
        puts ""
        puts -nonewline "Total  "
        puts -nonewline [format " %8.3f" $SSt]
        puts -nonewline [format " %8d" $df_t]
        puts ""
    }
    # -------------------------------------------------------------------------
    # mean
    # 平均値の計算
    # -------------------------------------------------------------------------
    method mean {xList num} {
        set sum [my sum $xList]
        return [expr $sum / $num]
    }
    # -------------------------------------------------------------------------
    # sum
    # 合計の計算
    # -------------------------------------------------------------------------
    method sum {xList} {
        set total 0.0
        foreach x $xList {
            set total [expr $total + $x]
       }
        return $total
    }
    # -------------------------------------------------------------------------
    # var
    # 分散の計算
    # -------------------------------------------------------------------------
    method var {xList xMean} {
        set var 0.0
        foreach x $xList {
            set var [expr $var + ($x - $xMean) * ($x - $xMean)]
        }
        return $var
    }
    # -------------------------------------------------------------------------
    # f_pval
    # P値(F分布の上側確率の算出)
    # -------------------------------------------------------------------------
    method f_pval {f df1 df2} {
        set m2pi 0.636619772367581343076
        set m_pi 3.14159265358979323846
        set i1 [expr 2 - ($df1%2)]
        set i2 [expr 2 - ($df2%2)]
        set w [expr $df2/($df2 + $df1*$f)]
        set y [expr 1.0 - $w]
        set p [expr sqrt($w)]
        set s [expr sqrt($y)]

        if {[expr 2*$i1 - $i2] == 0} {
            set p [expr 1.0 - $s]
            set c [$s*$w/2.0]
        } elseif {[expr 2*$i1 - $i2] == 1} {
            set c [expr $s*$p/$m_pi]
            set p [expr 1.0 - atan2($s, $p) * $m2pi]
        } elseif {[expr 2*$i1 - $i2] == 2} {
            set p $w
            set c [expr $w*$y]
        } else {
            set c [expr $y*$p/2.0]
        }
        for {set i2 $i2} {$df2 > $i2} {incr i2 2} {
            set p [expr $p - 2.0/$i2*$c]
            set c [expr $c*$w*($i1 + $i2)/$i2]
        }
        for {set i1 $i1} {$df1 > $i1} {incr i1 2} {
            set p [expr $p + 2.0/$i1*$c]
            set c [expr $c*$y*($i1 + $i2)/$i1]
        }
        return [expr ($p < 0.0 && abs($p) < 1e-10) ? 0.0 : $p]
    }
    # -------------------------------------------------------------------------
    # list_simple
    # 入れ子になっているリストをシンプルなリストに変換
    # -------------------------------------------------------------------------
    method list_simple {xList} {
        regsub -all {[\{\}]} $xList {} foo
        regsub -all {\s{2,}} $foo { } baa
        return $baa
    }
}
# -----------------------------------------------------------------------------
#  メイン
# -----------------------------------------------------------------------------
set obj [anova new $data]
if {[$obj oneway]} {
    $obj result
} else {
    puts "failed"
}
# ---
# END PROGRAM
実行例を以下に示しました。
$ ./anova_1way.tcl
ANOVA (1way)
Source        SS       df       MS    F val    P Val
Between    0.318        2    0.159    4.615 0.041749 *
Within     0.310        9    0.034
Total      0.628       11

参考サイト

[1] 統計関数の確率計算
[2] The Free Statistics Calculators Website - Home (算出値の検証用)
 

追記

この記事を書いた後、なぜ用意した関数でうまくできなかったのかが突然判ってしまいました。長年 Tcl を使っているのに、Tcl 特有の計算の落とし穴にすっかりハマっていたのです。

以下は、用意していた規格化された不完全ベータ関数 betai を使って書き直したメソッド f_pval です。Tcl では、整数÷整数の結果は自動的に整数になってしまいます。浮動小数の結果が必要な場合は、分母分子のどちらか一方を浮動小数の値に明示にしておく必要があります。
    # -------------------------------------------------------------------------
    # f_pval
    # P値(F分布の上側確率の算出)
    # -------------------------------------------------------------------------
    method f_pval {f df1 df2} {
        set x [expr $df1 * $f / ($df2 + $df1*$f)]
        return [expr 1 - betai($df1/2.0, $df2/2.0, $x)]
    }
実行例を以下に示しましたが、上記と同じ結果が得られています。
$ ./anova_1way.tcl
ANOVA (1way)
Source        SS       df       MS    F val    P Val
Between    0.318        2    0.159    4.615 0.041749 *
Within     0.310        9    0.034
Total      0.628       11

今のところ規格化された不完全ベータ関数 betai の算出には、下記の GSL の関数を利用しています。
double gsl_sf_beta_inc (double a, double b, double x)
以下のようなルーチンを使って Tcl の拡張パッケージを作成しています。
/*****************************************************************************
 * int func_betai
 * 規格化された不完全ベータ関数の処理部
 *
 * Tcl 側のコマンド
 *   expr betai($a, $b, $x)
 *****************************************************************************/
int
func_betai (ClientData clientData, Tcl_Interp * interp,
        Tcl_Value * args, Tcl_Value * resultPtr)
{
  double a, b, x;

  a = args->doubleValue;
  args++;
  b = args->doubleValue;
  args++;
  x = args->doubleValue;

  /* 計算結果 */
  resultPtr->type = TCL_DOUBLE;
  resultPtr->doubleValue = gsl_sf_beta_inc (a, b, x);

  return TCL_OK;
}
ただ、GSL の配布ライセンスは GPLv3 (GNU General Public License) に従っているので、扱い難いと感じています。計算方法の検証ができたので、他に BSD などの配布ライセンスで良いライブラリがあれば乗り換えようと思っています。オープンソースを推進したい者としては矛盾した考えですが、しかたがありません。
 

2010-10-02

ちょっと分散分析

前々から作りたいと思っていて、なかなか重い腰を上げて取り組もうとしなかった分散分析のライブラリについて、ようやく少しずつ作り始めました。

本当は C# で作りたかったのですが、GUI 化の手間と、ゆくゆくは超越関数(Γ関数など)を扱う統計値の計算ルーチンを作ることを考えれば、慣れている Tcl/Tk (+ Tktable) と C の組み合わせで作る方が現実的と考えました。

また、TclOO を利用したかったので、Tcl の nightly-cvs のサイトから Tcl/Tk の最新のソース (8.6b1.2) をダウンロード、Fedora 上でビルドして利用しています。

まずは一元配置の簡単なルーチンを作ってみました。参考サイト [1] と [2] で検算をしています。
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh8.6 "$0" "$@"
# 分散分析
# $Id: anova_1way.tcl,v 1.4 2010/10/02 15:00:00 bitwalk Exp bitwalk $

# サンプルデータ1
set a [list {3.42  3.84  3.96  3.76}]
set b [list {3.17  3.63  3.47  3.44  3.39}]
set c [list {3.64  3.72  3.91}]

# サンプルデータ2
#set a [list {25 30 20 32}]
#set b [list {30 33 29 40 36}]
#set c [list {32 39 35 41 44}]

# データ
set data [list $a $b $c]

# -----------------------------------------------------------------------------
#  クラス anova
# -----------------------------------------------------------------------------
oo::class create anova {
    constructor {a} {
        my variable x way

        # データリスト
        set x $a
        # 分散分析の対象フラグのリセット
        set way ""
    }
    # -------------------------------------------------------------------------
    # 一元配置
    # -------------------------------------------------------------------------
    method oneway {} {
        my variable x way
        my variable n k
        my variable SSb SSw SSt
        my variable df_b df_w df_t
        my variable MSb MSw
        my variable F

        # Sum of Squared Deviations
        # SSt (TOTAL)
        set x_simple [my list_simple $x]
        set n [llength $x_simple]
        set x_mean [my mean $x_simple $n]
        set SSt [my var $x_simple $x_mean]
        # SSb (BETWEEN GROUPS)
        set k [llength $x]
        set SSb 0
        for {set i 0} {$i < $k} {incr i} {
            set x_b($i) [my list_simple [lindex $x $i]]
            set n_b($i) [llength $x_b($i)]
            set x_mean_b($i) [my mean $x_b($i) $n_b($i)]
            set SSb [expr $SSb + $n_b($i) \
                * ($x_mean_b($i) - $x_mean) \
                * ($x_mean_b($i) - $x_mean)]           
        }
        # SSw (WITHIN GROUPS)
        # set SSw [expr $SSt - $SSb]
        set SSw 0
        for {set i 0} {$i < $k} {incr i} {
            set x_w($i) [my list_simple [lindex $x $i]]
            set n_w($i) [llength $x_w($i)]
            set x_mean_w($i) [my mean $x_w($i) $n_w($i)]
            set SSw [expr $SSw + [my var $x_w($i) $x_mean_w($i)]]
        }
        # Degree of Freedom
        set df_b [expr $k - 1]
        set df_w [expr $n - $k]
        set df_t [expr $n - 1]
        # Mean Square
        set MSb [expr $SSb / $df_b]
        set MSw [expr $SSw / $df_w]
        # F value, the ratio of the two variance estimates
        set F [expr $MSb / $MSw]
        # flag
        set way "One Way"
        return 1
     }
    # -------------------------------------------------------------------------
    # result
    # 結果の表示
    # -------------------------------------------------------------------------
    method result {} {
        my variable way

        switch $way {
            "One Way" {
                my result_1way
            }
            default {
                puts "No result yet!"
            }
        }
    }
    # -------------------------------------------------------------------------
    # result_1way
    # 結果の表示(一元配置)
    # -------------------------------------------------------------------------
    method result_1way {} {
        my variable x
        my variable n k
        my variable SSb SSw SSt
        my variable df_b df_w df_t
        my variable MSb MSw
        my variable F

        puts "ANOVA (1way)"
        puts "Source        SS       df       MS    F val"
        puts -nonewline "Between"
        puts -nonewline [format " %8.3f" $SSb]
        puts -nonewline [format " %8d" $df_b]
        puts -nonewline [format " %8.3f" $MSb]
        puts -nonewline [format " %8.3f" $F]
        puts ""
        puts -nonewline "Within "
        puts -nonewline [format " %8.3f" $SSw]
        puts -nonewline [format " %8d" $df_w]
        puts -nonewline [format " %8.3f" $MSw]
        puts ""
        puts -nonewline "Total  "
        puts -nonewline [format " %8.3f" $SSt]
        puts -nonewline [format " %8d" $df_t]
        puts ""
    }
    # -------------------------------------------------------------------------
    # mean
    # 平均値の計算
    # -------------------------------------------------------------------------
    method mean {xList num} {
        set sum [my sum $xList]
        return [expr $sum / $num]
    }
    # -------------------------------------------------------------------------
    # sum
    # 合計の計算
    # -------------------------------------------------------------------------
    method sum {xList} {
        set total 0.0
        foreach x $xList {
            set total [expr $total + $x]
       }
        return $total
    }
    # -------------------------------------------------------------------------
    # var
    # 分散の計算
    # -------------------------------------------------------------------------
    method var {xList xMean} {
        set var 0.0
        foreach x $xList {
            set var [expr $var + ($x - $xMean) * ($x - $xMean)]
        }
        return $var
    }
    # -------------------------------------------------------------------------
    # list_simple
    # 入れ子になっているリストをシンプルなリストに変換
    # -------------------------------------------------------------------------
    method list_simple {xList} {
        regsub -all {[\{\}]} $xList {} foo
        regsub -all {\s{2,}} $foo { } baa
        return $baa
    }
}
# -----------------------------------------------------------------------------
#  メイン
# -----------------------------------------------------------------------------
set obj [anova new $data]
if {[$obj oneway]} {
    $obj result
} else {
    puts "failed"
}
# ---
# END PROGRAM
実行例を以下に示しました。
$ ./anova_1way.tcl
ANOVA (1way)
Source        SS       df       MS    F val
Between    0.318        2    0.159    4.615
Within     0.310        9    0.034
Total      0.628       11
まだ、p値の計算はできていません。この部分は C で Tcl のライブラリを作成する予定です。あとは、すこしずつ GUI を作りながら、二元配置、直交表の分散分析にも対応させていく予定です。

参考サイト

[1] 一元配置分散分析
[2] One Way ANOVA
 

2010-09-10

Tcl/Tk 8.5.9 リリース


Tcl/Tk 8.5.9 が 9 月 8 日付けでリリースされました。Tcl/Tk 8.5 の 9 番目のパッチリリースです。バグフィックスが中心で、付属パッケージのバージョンアップもされています。
最近のリリース周期はすっかり穏やかなペースになり、今回は、8.5.8 から約 10 ヶ月ぶりのリリースになりました。
Date: Wed, 08 Sep 2010 16:42:34 -0400
From: Donald G Porter <donald.porter at nist.gov>
To: Tcl List Core <tcl-core at lists.sourceforge.net>
Subject: [TCLCORE] Tcl/Tk 8.5.9 RELEASED
Tcl/Tk 8.5.9 Release Announcement
September 8, 2010

The Tcl Core Team is pleased to announce the 8.5.9 releases of the Tcl
dynamic language and the Tk toolkit.  This is the ninth patch release
of Tcl/Tk 8.5.  More details can be found below.  We would like to
express our gratitude to all those who submit bug reports and patches.
This information is invaluable in enabling us to identify and eliminate
problems in the core.

Where to get the new releases:
------------------------------

Tcl/Tk 8.5.9 sources are freely available as open source from the
Tcl Developer Xchange web site at:

         http://www.tcl.tk/software/tcltk/8.5.html

This web page also contains additional information about the releases,
including new features and notes about installing and compiling the
releases.  Sources are always available from the Tcl SourceForge
project's file distribution area:

         http://sourceforge.net/project/showfiles.php?group_id=10894

Binaries for most major platforms are available from:

         http://www.activestate.com/Tcl

For additional information:
---------------------------

Please visit the Tcl Developer Xchange web site:

         http://www.tcl.tk/

This site contains a variety of information about Tcl/Tk in general, the
core Tcl and Tk distributions, Tcl development tools, and much more.

Summary of Changes since Tcl/Tk 8.5.8:
--------------------------------------

The following were the main changes in Tcl/Tk 8.5.9.  A complete list
can be found in the changes file at the root of the source tree.  The
more complete ChangeLog is also included with each source release.  This
is a patch release, so it primarily includes bug fixes and corrections
to erratic behavior.  Below are only the most notable changes.

    * TIP 359: new X11 option: [wm attributes -type]
 - stops inappropriate Compiz animation of Tk menu & combobox.

    * TIP 360: modernize menus on X11.

    * New widget [ttk::spinbox].

    * [lappend arr(elem)] no longer fires read traces as it inconsistently
      has in some situations, but not in others.
         *** POTENTIAL INCOMPATIBILITY ***

    * [tk_getOpenFile] on Windows: unlimited multiple-file selection.

    * [load] uses LOAD_WITH_ALTERED_SEARCH_PATH for fewer surprises when
      bringing in DLLs via dependencies on Windows.
         *** POTENTIAL INCOMPATIBILITY ***

    * Updated [send] security rules to current Ubuntu/Fedora conventions.

    * Fixed [wm iconphoto] on LP64 unix systems.

    * [chan copy] of more than 2**31 bytes is now possible.

    * min() and max() functions now work in safe interps.

    * [$menu delete $tooBig end] now properly a no-op.

    * canvas items now properly updated when canvas state changes.

    * Revised [ttk::sizegrip] to accommodate Compiz.

    * Revised default Text bindings for  and  to account
      for insertion point relationship to the selection.

    * Corrected result of [tcl::mathfunc::abs 0.0].

    * New version 1.432 of msgcat package.

    * New version 1.0.9 of platform package.

    * New version 0.8.6 of tile package.

    * Changes to support building with MSVC++ 2010.

    * Prevent race condition in some XIM implementations.

    * Fixed bad results from [file rootname].

    * Prevent consumption of all memory when [chan copy] copies to slow channel.

    * [wm transient] now works even with withdrawn windows.

    * $DISPLAY can now contain "::".

    * Restored compatibility of [entry] validation with Itcl variable scope.

    * Fixed line-sensitive matching by [regexp].

    * Fixed memory corruption in complex canvas tag searches.

    * Fixed crash in encoding finalization.

    * Fixed crashes in widget destruction.

    * Fixed crash in GetFontFamilyName().

    * Fixed crash in menu deletion.

    * Fixed crash in peer text dump.

    * Fixed crash when bind scripts are empty.

    * Fixed crash in unset traces during [array unset].

    * Fixed crash deleting vars during callframe pop.

    * Fixed crash in [open |noSuchFile rb].

    * Fixed crash in [chan postevent].

    * Fixed programming error in [clock format] in he_IL locale.

    * Safe Base and Safe Tk rewrites

--
Tcl Core Team and Maintainers
Don Porter, Tcl Core Release Manager



-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter at nist.gov          Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Tcl-Core mailing list
Tcl-Core at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

2009-05-02

R で GUI プログラミング(2)


GUI プログラミングの部分を最初に用意するなんて、本末転倒な気がしますが、ごく基本的なウィジェットについて紹介するページを、まだ未完成ではありますが、作ってしまいました。

・R で GUI プログラミング

とりあえず、以下のような基本的なウィジェットを紹介しています。具体的な利用例についても用意していこうと考えています。

肝心の統計解析の部分は、すでに偉い先生方がいろいろと紹介されているので、こちらの方は、じっくりと準備していきます。
 

2009-04-29

R で GUI プログラミング


R は、データ解析のために仕事で毎日のように使っています。あるプログラムを他の人にも使ってもらう可能性が出てきたので、GUI 化に取り組んでいます。GUI 用のライブラリには tcltk を使っています。理由は、慣れているので一番簡単だったからです。とはいえ、R 特有の書式があるので、戸惑うところもあります。意外と情報が少ないので、試行錯誤を繰り返しています。

R のプログラミング情報は、いずれまとめたいと考えていましたので、この際、R の GUI プログラミングの情報からまとめ始めようか検討中です。

仕事で使うので、モザイクで一部隠しての紹介ですが、結構いい感じのインターフェイスができあがりそうです。

2009-04-16

Tcl/Tk 8.5.7 リリース


Tcl/Tk 8.5.7 が 4 月 15 日付けでリリースされました。8.6 の β2 は、まだ RC 版が出ていないので、このタイミングではリリースされないみたいです。

Date: Thu, 16 Apr 2009 00:55:45 -0400
From: dgp at nist.gov
To: tcl-core at lists.sf.net
Subject: [TCLCORE] Tcl/Tk 8.5.7 RELEASED

Tcl/Tk 8.5.7 Release Announcement
April 15, 2009

The Tcl Core Team is pleased to announce the 8.5.7 releases of the Tcl
dynamic language and the Tk toolkit. This is the seventh patch release
of Tcl/Tk 8.5. More details can be found below. We would like to
express our gratitude to all those who submit bug reports and patches.
This information is invaluable in enabling us to identify and eliminate
problems in the core.

Where to get the new releases:
------------------------------

Tcl/Tk 8.5.7 sources are freely available as open source from the
Tcl Developer Xchange web site at:

http://www.tcl.tk/software/tcltk/8.5.html

This web page also contains additional information about the releases,
including new features and notes about installing and compiling the
releases. Sources are always available from the Tcl SourceForge
project's file distribution area:

http://sourceforge.net/project/showfiles.php?group_id=10894

Binaries for most major platforms are available from:

http://www.activestate.com/Tcl

For additional information:
---------------------------

Please visit the Tcl Developer Xchange web site:

http://www.tcl.tk/

This site contains a variety of information about Tcl/Tk in general, the
core Tcl and Tk distributions, Tcl development tools, and much more.

Summary of Changes since Tcl/Tk 8.5.6:
--------------------------------------

The following were the main changes in Tcl/Tk 8.5.7. A complete list
can be found in the changes file at the root of the source tree. The
more complete ChangeLog is also included with each source release. This
is a patch release, so it primarily includes bug fixes and corrections
to erratic behavior. Below are only the most notable changes.

* Embeddable CoreFoundation notifier on Darwin.

* Improved compatibility support in [load] on Darwin.

* Restored Tk_CreatePhotoImageFormat compat with aMSN.

* Stopped blurry large fonts on Vista.

* New version 1.0.3 of platform package:
- more details in identifiers for Darwin

* New version 2.7.3 of http package:
- fixes connect failure when partial lines returned

* New version 2.3.1 of tcltest package:
- removes several unsafe [eval]s

* Menu image display fixes.

* Fixed crash in Tk_MakeWindowExist() seen with gitk.

* Fixed [file pathtype] on volumerelative paths.

* Extended virtual events to work when Caps Lock is on.

* Stopped memory leak in [file normalize].

* Fixed crash on exit with [chan create]d channels.

* Prevent crashes overflowing max string lengths.

* Improved support for MSVC builds on _WIN64 systems.

--
Tcl Core Team and Maintainers
Don Porter, Tcl Core Release Manager

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Tcl-Core mailing list
Tcl-Core at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

2009-01-14

Incr Tcl も?


どうやら Incr Tcl が Tcl のコアパッケージにバンドルされるらしい。

ずいぶん前のことになりますが、TIP 6 で、Incr Tcl を Tcl のコアに取り込もうと Mark Harrison 氏が提案した時、Tcl/Tk の考案者 John K. Ousterhout 氏の反対で棄却されています。バンドルということは、コアには含まれないが、モジュールとして一緒に配布されるということなのだろうか?まずは pkgs とは何なのか確認しなくては…。

TclOO が既にコアに取り込まれていると思っていましたが、別のバージョン番号が付いているし、扱いはバンドルなんだろうか?深く考えていなかったので混乱してきました。今夜にでも CVS からソースを持ってきて確認をしよう。

Date: Tue, 13 Jan 2009 16:49:29 -0500
From: dgp at nist.gov
To: tcl-core at lists.sourceforge.net
Subject: [TCLCORE] TIP 50: Final

I've just imported the source code for
Itcl 4.0b2 into our cvs repository as
the new module "itcl". I've also revised
the "pkgs" module to include it, so now
fresh checkouts of the "tcl" modules will
include it in the pkgs directory as a
bundled package. (The "tcl-only" module
should be unchanged).

I think this completes TIP 50.

Big thanks to Arnulf Wiedemann for the
work getting things ready.

DGP

参考情報


[1] バンドルとは 【bundle】 - 意味・解説 : IT用語辞典
 

2009-01-13

R で Tcl/Tk パッケージを試す


R で Tcl/Tk パッケージを使ってみました。以前から試してみたかったのですが、(自前の R スクリプトを使った)目の前の作業に追われて、ゆっくりと GUI を検討する暇がありませんでした。

で、今更なんですが R: Tk widgets で説明されている例を Fedora 上で実行してみてびっくり。簡単に Tk ウィジェットが R で利用できます。Ttk ウィジェットなど、最新の Tcl/Tk のウィジェットにも対応しているようです。これだったら、業務用に作った R スクリプトを GUI 化するために時間を割くことを検討する余地が十分ありそう。GUI 化できれば、作業を他の人に移管できる…。

$ R

R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

Rはフリーソフトウェアであり、「完全に無保証」です。
...
(省略)
...
[以前にセーブされたワークスペースを復帰します]

> library(tcltk)
Tcl/Tkインターフェースのロード 終了済
> ls("package:tcltk")
[1] "addTclPath" "as.tclObj" "getTkProgressBar"
[4] "is.tclObj" "is.tkwin" "setTkProgressBar"
[7] "tcl" "tclArray" "tclObj"
[10] "tclObj<-" "tclObj<-.tclVar" "tclRequire"
...
(省略)
...
[241] "ttkbutton" "ttkcheckbutton" "ttkcombobox"
[244] "ttkentry" "ttkframe" "ttkimage"
[247] "ttklabel" "ttklabelframe" "ttkmenubutton"
[250] "ttknotebook" "ttkpanedwindow" "ttkprogressbar"
[253] "ttkradiobutton" "ttkscrollbar" "ttkseparator"
[256] "ttksizegrip" "ttktreeview"
> tt <- tktoplevel()
> label.widget <- tklabel(tt, text="Hello, World!")
> button.widget <- tkbutton(tt, text="Push",
+ command=function()cat("OW!\n"))
> tkpack(label.widget, button.widget)
<Tcl>
>


 

2008-12-28

Tcl and the Tk Toolkit (2nd Edition)


もっとTcl/Tk のサイトを運営されている、いまいさんのブログ、つれづれなるままに − つれづれブログ を久しぶりに読んでいたら、耳寄りな情報を発見!

2008年12月06日の記事によると、Tcl/Tk を考案した John Ousterhout 氏が、Tcl and the Tk Toolkit を 15年ぶりに改訂するらしいのです。なんと 600 ページもあるらしい。発売予定が来年の 6 月ということで、ずいぶん先ですが、Amazon.com に予約を入れておきました。

Order #: XXX-XXXXXXX-XXXXXXX
Shipping Method: Expedited International Shipping
Shipping Preference: Group my items into as few shipments as possible
Subtotal of Items: $42.70
Shipping & Handling: $13.98
------
Total for this Order: $56.68

Delivery estimate: June 18, 2009 - June 30, 2009
Shipping estimate for these items: June 8, 2009
1 "Tcl and the Tk Toolkit (2nd Edition) (Addison-Wesley Professional Computing Series)"
John K. Ousterhout; Paperback; $42.70

Sold by: Amazon.com, LLC


 

2008-12-24

Tcl/Tk 8.6b1 リリース


Tcl/Tk 8.6 の最初の β 版が 12 月 23 日付けでリリースされました。TIP #234(Zlib の圧縮サポート)は、このリリースに間に合うように取り込まれましたが、TIP #244(PNG Photo Image のサポート)の方は、このリリースには含まれませんでした。TIP #329 の Try/Catch/Finally ロジックの機能が取り込まれたことも大きな変更/拡張点でしょう。良いサンプルがあれば紹介をしていきたいと思います。

なお、Tcl/Tk 8.5.6 も同日付けでリリースされました。

Date: Tue, 23 Dec 2008 09:38:33 -0500
From: Donald G Porter <dgp at nist.gov>
To: Tcl List Core <tcl-core at lists.sourceforge.net>
Subject: [TCLCORE] Tcl/Tk 8.6b1 RELEASED

Tcl/Tk 8.6b1 Release Announcement
December 23, 2008

The Tcl Core Team is pleased to announce the 8.6b1 releases of the Tcl
dynamic language and the Tk toolkit. This is the first beta release
of Tcl/Tk 8.6. More details can be found below. We would like to
express our gratitude to all those who submit bug reports and patches.
This information is invaluable in enabling us to identify and eliminate
problems in the core.

Where to get the new releases:
------------------------------

Tcl/Tk 8.6b1 sources are freely available as open source from the
Tcl Developer Xchange web site at:

http://www.tcl.tk/software/tcltk/8.6.html

This web page also contains additional information about the releases,
including new features and notes about installing and compiling the
releases. Sources are always available from the Tcl SourceForge
project's file distribution area:

http://sourceforge.net/project/showfiles.php?group_id=10894

Binaries for most major platforms are available from:

http://www.activestate.com/Tcl

For additional information:
---------------------------

Please visit the Tcl Developer Xchange web site:

http://www.tcl.tk/

This site contains a variety of information about Tcl/Tk in general, the
core Tcl and Tk distributions, Tcl development tools, and much more.

Summary of Changes since Tcl/Tk 8.6a3:
--------------------------------------

The following were the main changes in Tcl/Tk 8.6b1. A complete list
can be found in the changes file at the root of the source tree. The
more complete ChangeLog is also included with each source release.

This is a beta release of 8.6. The beta designation means that the
feature set for 8.6 is believed to be complete, and the focus is now
on testing and bug fixing moving quickly toward an 8.6.0 release.
All relevant bug fixes (and some more) up to and including 8.5.6 changes
are included in 8.6b1. This release is a development release, and should
only be considered for deployment use after considerable testing.

* [TIP 329] New commands: [try], [throw]

* [TIP 234] New command: [zlib]

* [TIP 343] Enhanced commands: [format], [scan] add %b specifier.

* [TIP 332] Enhanced command: [close $chan read|write].

* New widget: [ttk::spinbox].

* [TIP 210] New subcommand: [file tempfile].

* [TIP 321] New subcommand: [tk busy].

* [TIP 324] New subcommand (dialog box): [tk fontchooser].

* [TIP 97] New subcommands: [$canvas imove], [$canvas rchars].

* [TIP 341] Enhanced subcommand: [dict filter] takes multiple patterns.

* [TIP 119] New canvas option: -angle for text items.

* [TIP 197] New text option: -insertunfocussed.

* New ttk theme: vista -- uses new "hover" state.

* [TIP 308] New package: tdbc 1.0b1 .

* [TIP 322] New routines: Tcl_NR*(): non-recursive eval for extensions.

* [TIP 336] New routines: Tcl_*ErrorLine().
*** POTENTIAL INCOMPATIBILITY in interp->errorline access ***
*** Define USE_INTERP_ERRORLINE for legacy code support ***

* [TIP 307] New routine: Tcl_TransferResult().

* [TIP 335] New routine: Tcl_InterpActive().

* [TIP 337] New routine: Tcl_BackgroundException().

* [TIP 338] New routines: Tcl_*StartupScript()
*** POTENTIAL INCOMPATIBILITY for callers of Tcl*Startup*() ***

* New feature: build script support for bundled packages.

* System encoding during initialization now iso8859-1, not identity.
*** POTENTIAL INCOMPATIBILITY ***

* [oo::define] revised context for name resolution, includes caller.
*** POTENTIAL INCOMPATIBILITY with earlier TclOO ***

* [event generate] support for events.

* Fixed broken [for $start $end $incr continue].

* New demos: ctext.tcl, fontchoose.tcl .

--
Tcl Core Team and Maintainers
Don Porter, Tcl Core Release Manager


--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter at nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

------------------------------------------------------------------------------
_______________________________________________
Tcl-Core mailing list
Tcl-Core at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core