mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
635 lines
23 KiB
Ruby
635 lines
23 KiB
Ruby
|
#! /usr/local/bin/ruby -d
|
|||
|
#! /usr/local/bin/ruby
|
|||
|
# -d <20><><EFBFBD>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>դ<EFBFBD><D5A4><EFBFBD><EFBFBD><EFBFBD>, <20>ǥХå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
|||
|
# tcltk <20>饤<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>
|
|||
|
|
|||
|
# <20>ޤ<EFBFBD>, <20>饤<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD> require <20><><EFBFBD><EFBFBD>.
|
|||
|
require "tcltk"
|
|||
|
|
|||
|
# <20>ʲ<EFBFBD><CAB2><EFBFBD>, Test1 <20>Υ<EFBFBD><CEA5><EFBFBD><F3A5B9A5><EFBFBD> initialize() <20><>,
|
|||
|
# tcl/tk <20>˴ؤ<CBB4><D8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>.
|
|||
|
# ɬ<><C9AC><EFBFBD><EFBFBD><EFBFBD>⤽<EFBFBD>Τ褦<CEA4>ˤ<EFBFBD><CBA4><EFBFBD>ɬ<EFBFBD>פ<EFBFBD>̵<EFBFBD><CCB5>,
|
|||
|
# (<28>⤷, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) class <20>γ<EFBFBD><CEB3><EFBFBD> tcl/tk <20>˴ؤ<CBB4><D8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԤäƤ<C3A4><C6A4>ɤ<EFBFBD>.
|
|||
|
|
|||
|
class Test1
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD>ץ<D7A5><EAA5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>).
|
|||
|
def initialize()
|
|||
|
|
|||
|
#### <20>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>Τ<EFBFBD><CEA4>ޤ<EFBFBD><DEA4>ʤ<EFBFBD>
|
|||
|
|
|||
|
# <20><><EFBFBD>ץ<D7A5><EAA5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ip = TclTkInterpreter.new()
|
|||
|
# <20><><EFBFBD>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD> c <20><><EFBFBD><EFBFBD><EFBFBD>ꤷ<EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD>.
|
|||
|
c = ip.commands()
|
|||
|
# <20><><EFBFBD>Ѥ<EFBFBD><D1A4>륳<EFBFBD>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD>.
|
|||
|
append, bind, button, destroy, incr, info, label, place, set, wm =
|
|||
|
c.indexes(
|
|||
|
"append", "bind", "button", "destroy", "incr", "info", "label", "place",
|
|||
|
"set", "wm")
|
|||
|
|
|||
|
#### tcl/tk <20>Υ<EFBFBD><CEA5>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TclTkCommand)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# <20>¹Ԥ<C2B9><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, e() <20><EFBFBD>åɤ<C3A5><C9A4>Ȥ<EFBFBD>.
|
|||
|
# (<28>ʲ<EFBFBD><CAB2><EFBFBD>, tcl/tk <20>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD><EFBFBD> info command r* <20><><EFBFBD>¹<EFBFBD>.)
|
|||
|
print info.e("command", "r*"), "\n"
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ޤȤʸ<E1A4BF><CAB8><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4>Ƥ<EFBFBD>Ʊ<EFBFBD><C6B1>.
|
|||
|
print info.e("command r*"), "\n"
|
|||
|
# <20>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>Ѥ<EFBFBD><D1A4>ʤ<EFBFBD><CAA4>Ȥ<EFBFBD><C8A4>¹ԤǤ<D4A4><C7A4>뤬, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1A4AC><EFBFBD><EFBFBD>.
|
|||
|
print c["info"].e("command", "r*"), "\n"
|
|||
|
# <20><><EFBFBD>ץ<D7A5>Υ<CEA5>åɤȤ<C9A4><C8A4>Ƥ<EFBFBD><C6A4>¹ԤǤ<D4A4><C7A4>뤬, <20><>Ψ<EFBFBD><CEA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
print ip.info("command", "r*"), "\n"
|
|||
|
|
|||
|
####
|
|||
|
|
|||
|
# <20>ʲ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD>
|
|||
|
# GC <20><><EFBFBD>оݤˤʤäƤ<C3A4><C6A4>ޤ<EFBFBD>.
|
|||
|
|
|||
|
#### tcl/tk <20><><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TclTkVariable)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4><EFBFBD><EFBFBD>ꤹ<EFBFBD><EAA4B9>.
|
|||
|
v1 = TclTkVariable.new(ip, "20")
|
|||
|
# <20>ɤ߽Ф<DFBD><D0A4><EFBFBD> get <20><EFBFBD>åɤ<C3A5><C9A4>Ȥ<EFBFBD>.
|
|||
|
print v1.get(), "\n"
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> set <20><EFBFBD>åɤ<C3A5><C9A4>Ȥ<EFBFBD>.
|
|||
|
v1.set(40)
|
|||
|
print v1.get(), "\n"
|
|||
|
# set <20><><EFBFBD>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4>Ȥä<C8A4><C3A4>ɤ߽Ф<DFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1A4AC><EFBFBD><EFBFBD>.
|
|||
|
# e() <20><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE> TclTkObject <20><><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4>Ƥ<F1A4A4A4><C6A4>ɤ<EFBFBD>.
|
|||
|
set.e(v1, 30)
|
|||
|
print set.e(v1), "\n"
|
|||
|
# tcl/tk <20>Υ<EFBFBD><CEA5>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>.
|
|||
|
incr.e(v1)
|
|||
|
print v1.get(), "\n"
|
|||
|
append.e(v1, 10)
|
|||
|
print v1.get(), "\n"
|
|||
|
|
|||
|
#### tcl/tk <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TclTkWidget)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# <20>롼<EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD>.
|
|||
|
root = ip.rootwidget()
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
root.e("configure -height 300 -width 300")
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>դ<EFBFBD><D5A4><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD> wm <20><><EFBFBD>Ȥ<EFBFBD>.
|
|||
|
wm.e("title", root, $0)
|
|||
|
# <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤȥ<C8A4><C8A5>ޥ<EFBFBD><DEA5>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>ꤷ<EFBFBD><EAA4B7>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
l1 = TclTkWidget.new(ip, root, label, "-text {type `x' to print}")
|
|||
|
# place <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
place.e(l1, "-x 0 -rely 0.0 -relwidth 1 -relheight 0.1")
|
|||
|
# <20><><EFBFBD>ޥ<EFBFBD><DEA5><EFBFBD>̾<EFBFBD><CCBE>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>ꤷ<EFBFBD>Ƥ<EFBFBD><C6A4>ɤ<EFBFBD><C9A4><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1A4AC><EFBFBD><EFBFBD>.
|
|||
|
# (<28><><EFBFBD>ޥ<EFBFBD><DEA5><EFBFBD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD>Ω<EFBFBD><CEA9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥʤ<C7A4><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD>.)
|
|||
|
l2 = TclTkWidget.new(ip, root, "label")
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
l2.e("configure -text {type `q' to exit}")
|
|||
|
place.e(l2, "-x 0 -rely 0.1 -relwidth 1 -relheight 0.1")
|
|||
|
|
|||
|
#### tcl/tk <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TclTkCallback)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
c1 = TclTkCallback.new(ip, proc{sample(ip, root)})
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĥ<EFBFBD><C4A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
b1 = TclTkWidget.new(ip, root, button, "-text sample -command", c1)
|
|||
|
place.e(b1, "-x 0 -rely 0.2 -relwidth 1 -relheight 0.1")
|
|||
|
# <20><><EFBFBD>٥<EFBFBD><D9A5>ȥ롼<C8A5>פ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD> destroy.e(root) <20><><EFBFBD><EFBFBD>.
|
|||
|
c2 = TclTkCallback.new(ip, proc{destroy.e(root)})
|
|||
|
b2 = TclTkWidget.new(ip, root, button, "-text exit -command", c2)
|
|||
|
place.e(b2, "-x 0 -rely 0.3 -relwidth 1 -relheight 0.1")
|
|||
|
|
|||
|
#### <20><><EFBFBD>٥<EFBFBD><D9A5>ȤΥХ<CEA5><D0A5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
# script <20><><EFBFBD>ɲ<EFBFBD> (bind tag sequence +script) <20>Ϻ<EFBFBD><CFBA>ΤȤ<CEA4><C8A4><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4>ʤ<EFBFBD>.
|
|||
|
# (<28><><EFBFBD>ƥ졼<C6A5><ECA1BC><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꤬<EFBFBD><EAA4AC><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD>.)
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD>Ū<EFBFBD>ˤϥ<CBA4><CFA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>Ф<EFBFBD><D0A4>륳<EFBFBD><EBA5B3><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD>Ʊ<EFBFBD><C6B1>.
|
|||
|
c3 = TclTkCallback.new(ip, proc{print("q pressed\n"); destroy.e(root)})
|
|||
|
bind.e(root, "q", c3)
|
|||
|
# bind <20><><EFBFBD>ޥ<EFBFBD><DEA5>ɤ<EFBFBD> % <20>ִ<EFBFBD><D6B4>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD>ѥ<EFBFBD><D1A5><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤿ<EFBFBD><EAA4BF><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>,
|
|||
|
# proc{} <20>θ<EFBFBD><CEB8><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>ꤹ<EFBFBD><EAA4B9><EFBFBD><EFBFBD>,
|
|||
|
# <20>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>̤ƥ졼<C6A5><ECA1BC><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>̤<EFBFBD><CCA4>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4><EFBFBD>.
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> proc{} <20>θ<EFBFBD><CEB8><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
# bind <20><><EFBFBD>ޥ<EFBFBD><DEA5>ɤ<EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD>륳<EFBFBD><EBA5B3><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5>ʳ<EFBFBD><CAB3>ǻ<EFBFBD><C7BB>ꤷ<EFBFBD>ƤϤ<C6A4><CFA4><EFBFBD><EFBFBD>ʤ<EFBFBD>.
|
|||
|
c4 = TclTkCallback.new(ip, proc{|i| print("#{i} pressed\n")}, "%A")
|
|||
|
bind.e(root, "x", c4)
|
|||
|
# TclTkCallback <20><> GC <20><><EFBFBD>оݤˤ<DDA4><CBA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
# dcb() (<28>ޤ<EFBFBD><DEA4><EFBFBD> deletecallbackkeys()) <20><><EFBFBD><EFBFBD>ɬ<EFBFBD>פ<EFBFBD><D7A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
cb = [c1, c2, c3, c4]
|
|||
|
c5 = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, root, w)}, "%W")
|
|||
|
bind.e(root, "<Destroy>", c5)
|
|||
|
cb.push(c5)
|
|||
|
|
|||
|
#### tcl/tk <20>Υ<EFBFBD><CEA5><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>륪<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TclTkImage)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
# <20>ǡ<EFBFBD><C7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤷ<EFBFBD><EAA4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
i1 = TclTkImage.new(ip, "photo", "-file maru.gif")
|
|||
|
# <20><><EFBFBD>٥<EFBFBD><D9A5><EFBFBD>ĥ<EFBFBD><C4A5><EFBFBD>դ<EFBFBD><D5A4>Ƥߤ<C6A4>.
|
|||
|
l3 = TclTkWidget.new(ip, root, label, "-relief raised -image", i1)
|
|||
|
place.e(l3, "-x 0 -rely 0.4 -relwidth 0.2 -relheight 0.2")
|
|||
|
# <20><><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA4B9>.
|
|||
|
i2 = TclTkImage.new(ip, "photo")
|
|||
|
# <20><><EFBFBD><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA4B9>.
|
|||
|
i2.e("copy", i1)
|
|||
|
i2.e("configure -gamma 0.5")
|
|||
|
l4 = TclTkWidget.new(ip, root, label, "-relief raised -image", i2)
|
|||
|
place.e(l4, "-relx 0.2 -rely 0.4 -relwidth 0.2 -relheight 0.2")
|
|||
|
|
|||
|
####
|
|||
|
end
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ץ<EFBFBD><D7A5>Τ<EFBFBD><CEA4><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
def sample(ip, parent)
|
|||
|
bind, button, destroy, grid, toplevel, wm = ip.commands().indexes(
|
|||
|
"bind", "button", "destroy", "grid", "toplevel", "wm")
|
|||
|
|
|||
|
## toplevel
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5><EFBFBD><F2B3ABA4>ˤ<EFBFBD>, toplevel <20><><EFBFBD>Ȥ<EFBFBD>.
|
|||
|
t1 = TclTkWidget.new(ip, parent, toplevel)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>դ<EFBFBD><D5A4>Ƥ<EFBFBD><C6A4><EFBFBD>
|
|||
|
wm.e("title", t1, "sample")
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>줿<EFBFBD>Ȥ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD> GC <20><><EFBFBD>оݤˤʤ<CBA4><CAA4>褦<EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>.
|
|||
|
cb = []
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W"))
|
|||
|
bind.e(t1, "<Destroy>", c)
|
|||
|
|
|||
|
# <20>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
wid = []
|
|||
|
# toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD> destroy <20><><EFBFBD><EFBFBD>.
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text close -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_label(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text label -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_button(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text button -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_checkbutton(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text checkbutton -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_radiobutton(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text radiobutton -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_scale(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text scale -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_entry(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text entry -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_text(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text text -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_raise(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text raise/lower -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_modal(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text message/modal -command",
|
|||
|
c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_menu(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text menu -command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_listbox(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text listbox/scrollbar",
|
|||
|
"-command", c))
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{test_canvas(ip, t1)}))
|
|||
|
wid.push(TclTkWidget.new(ip, t1, button, "-text canvas -command", c))
|
|||
|
|
|||
|
# grid <20><>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ro = co = 0
|
|||
|
wid.each{|w|
|
|||
|
grid.e(w, "-row", ro, "-column", co, "-sticky news")
|
|||
|
ro += 1
|
|||
|
if ro == 7
|
|||
|
ro = 0
|
|||
|
co += 1
|
|||
|
end
|
|||
|
}
|
|||
|
end
|
|||
|
|
|||
|
# inittoplevel(ip, parent, title)
|
|||
|
# <20>ʲ<EFBFBD><CAB2>ν<EFBFBD><CEBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤȤ<DEA4><C8A4>ƹԤ<C6B9>.
|
|||
|
# 1. toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
# 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱդ<D1B0>, toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5>
|
|||
|
# <Destroy> <20><><EFBFBD>٥<EFBFBD><D9A5>Ȥ˥<C8A4><CBA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>.
|
|||
|
# 3. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD>ѿ<EFBFBD>
|
|||
|
# <20><><EFBFBD>֤<EFBFBD>.
|
|||
|
# ip: <20><><EFBFBD>ץ
|
|||
|
# parent: <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD>
|
|||
|
# title: toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤΥ<C8A4><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ȥ<EFBFBD>
|
|||
|
def inittoplevel(ip, parent, title)
|
|||
|
bind, button, destroy, toplevel, wm = ip.commands().indexes(
|
|||
|
"bind", "button", "destroy", "toplevel", "wm")
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5><EFBFBD><F2B3ABA4>ˤ<EFBFBD>, toplevel <20><><EFBFBD>Ȥ<EFBFBD>.
|
|||
|
t1 = TclTkWidget.new(ip, parent, toplevel)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>դ<EFBFBD><D5A4>Ƥ<EFBFBD><C6A4><EFBFBD>
|
|||
|
wm.e("title", t1, title)
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>줿<EFBFBD>Ȥ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD> GC <20><><EFBFBD>оݤˤʤ<CBA4><CAA4>褦<EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>.
|
|||
|
cb = []
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W"))
|
|||
|
bind.e(t1, "<Destroy>", c)
|
|||
|
# close <20>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>äƤ<C3A4><C6A4><EFBFBD>.
|
|||
|
# toplevel <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD> destroy <20><><EFBFBD><EFBFBD>.
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)}))
|
|||
|
b1 = TclTkWidget.new(ip, t1, button, "-text close -command", c)
|
|||
|
|
|||
|
return t1, b1, cb
|
|||
|
end
|
|||
|
|
|||
|
# label <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_label(ip, parent)
|
|||
|
button, global, label, pack = ip.commands().indexes(
|
|||
|
"button", "global", "label", "pack")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "label")
|
|||
|
|
|||
|
## label
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>Υ<EFBFBD><CEA5>٥<EFBFBD>.
|
|||
|
l1 = TclTkWidget.new(ip, t1, label, "-text {default(flat)}")
|
|||
|
l2 = TclTkWidget.new(ip, t1, label, "-text raised -relief raised")
|
|||
|
l3 = TclTkWidget.new(ip, t1, label, "-text sunken -relief sunken")
|
|||
|
l4 = TclTkWidget.new(ip, t1, label, "-text groove -relief groove")
|
|||
|
l5 = TclTkWidget.new(ip, t1, label, "-text ridge -relief ridge")
|
|||
|
l6 = TclTkWidget.new(ip, t1, label, "-bitmap error")
|
|||
|
l7 = TclTkWidget.new(ip, t1, label, "-bitmap questhead")
|
|||
|
|
|||
|
# pack <20><><EFBFBD>Ƥ<EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
pack.e(b1, l1, l2, l3, l4, l5, l6, l7, "-pady 3")
|
|||
|
|
|||
|
## -textvariable
|
|||
|
|
|||
|
# tcltk <20>饤<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD>Ǥ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD> tcl/tk <20><>``<60><>³<EFBFBD><C2B3>''<27><><EFBFBD>̤<EFBFBD><CCA4><EFBFBD>
|
|||
|
# <20>ƤФ<C6A4><D0A4><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ä<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)<29>ѿ<EFBFBD><D1BF>˥<EFBFBD><CBA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>,
|
|||
|
# global <20><><EFBFBD><EFBFBD>ɬ<EFBFBD>פ<EFBFBD><D7A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
# global <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4><EFBFBD><EFBFBD>ꤷ<EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4>ȥ<EFBFBD><C8A5>顼<EFBFBD>ˤʤ<CBA4><CAA4>Τ<EFBFBD>,
|
|||
|
# tcl/tk <20>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ºݤ<C2BA><DDA4>ͤ<EFBFBD><CDA4><EFBFBD><EFBFBD>ꤷ<EFBFBD>ʤ<EFBFBD><CAA4>褦<EFBFBD><E8A4A6>,
|
|||
|
# 2 <20><><EFBFBD>ܤΰ<DCA4><CEB0><EFBFBD><EFBFBD>ˤ<EFBFBD> nil <20><>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>.
|
|||
|
v1 = TclTkVariable.new(ip, nil)
|
|||
|
global.e(v1)
|
|||
|
v1.set(100)
|
|||
|
# -textvariable <20><><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤹ<EFBFBD><EAA4B9>.
|
|||
|
l6 = TclTkWidget.new(ip, t1, label, "-textvariable", v1)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>椫<EFBFBD><E6A4AB><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA4B9>.
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
global.e(v1); v1.set(v1.get().to_i + 10)}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text +10 -command", c)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
global.e(v1); v1.set(v1.get().to_i - 10)}))
|
|||
|
b3 = TclTkWidget.new(ip, t1, button, "-text -10 -command", c)
|
|||
|
pack.e(l6, b2, b3)
|
|||
|
end
|
|||
|
|
|||
|
# button <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_button(ip, parent)
|
|||
|
button, pack = ip.commands().indexes("button", "pack")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "button")
|
|||
|
|
|||
|
## button
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD>.
|
|||
|
b3 = b4 = nil
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{b3.e("flash"); b4.e("flash")}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text flash -command", c)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state normal")}))
|
|||
|
b3 = TclTkWidget.new(ip, t1, button, "-text normal -command", c)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state disabled")}))
|
|||
|
b4 = TclTkWidget.new(ip, t1, button, "-text disable -command", c)
|
|||
|
pack.e(b1, b2, b3, b4)
|
|||
|
end
|
|||
|
|
|||
|
# checkbutton <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_checkbutton(ip, parent)
|
|||
|
checkbutton, global, pack = ip.commands().indexes(
|
|||
|
"checkbutton", "global", "pack")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "checkbutton")
|
|||
|
|
|||
|
## checkbutton
|
|||
|
|
|||
|
v1 = TclTkVariable.new(ip, nil)
|
|||
|
global.e(v1)
|
|||
|
# -variable <20><><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤹ<EFBFBD><EAA4B9>.
|
|||
|
ch1 = TclTkWidget.new(ip, t1, checkbutton, "-onvalue on -offvalue off",
|
|||
|
"-textvariable", v1, "-variable", v1)
|
|||
|
pack.e(b1, ch1)
|
|||
|
end
|
|||
|
|
|||
|
# radiobutton <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_radiobutton(ip, parent)
|
|||
|
global, label, pack, radiobutton = ip.commands().indexes(
|
|||
|
"global", "label", "pack", "radiobutton")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "radiobutton")
|
|||
|
|
|||
|
## radiobutton
|
|||
|
|
|||
|
v1 = TclTkVariable.new(ip, nil)
|
|||
|
global.e(v1)
|
|||
|
# <20>̥륹<CCA5>ȥ<EFBFBD><C8A5><EFBFBD> "{}" <20>ǻ<EFBFBD><C7BB>ꤹ<EFBFBD><EAA4B9>.
|
|||
|
v1.set("{}")
|
|||
|
l1 = TclTkWidget.new(ip, t1, label, "-textvariable", v1)
|
|||
|
# -variable <20><>Ʊ<EFBFBD><C6B1><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꤹ<EFBFBD><EAA4B9><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>롼<EFBFBD>פˤʤ<CBA4>.
|
|||
|
ra1 = TclTkWidget.new(ip, t1, radiobutton,
|
|||
|
"-text radio1 -value r1 -variable", v1)
|
|||
|
ra2 = TclTkWidget.new(ip, t1, radiobutton,
|
|||
|
"-text radio2 -value r2 -variable", v1)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v1.set("{}")}))
|
|||
|
ra3 = TclTkWidget.new(ip, t1, radiobutton,
|
|||
|
"-text clear -value r3 -variable", v1, "-command", c)
|
|||
|
pack.e(b1, l1, ra1, ra2, ra3)
|
|||
|
end
|
|||
|
|
|||
|
# scale <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_scale(ip, parent)
|
|||
|
global, pack, scale = ip.commands().indexes(
|
|||
|
"global", "pack", "scale")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "scale")
|
|||
|
|
|||
|
## scale
|
|||
|
|
|||
|
v1 = TclTkVariable.new(ip, nil)
|
|||
|
global.e(v1)
|
|||
|
v1.set(219)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD>.
|
|||
|
sca1 = nil
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v = v1.get();
|
|||
|
sca1.e("configure -background", format("#%02x%02x%02x", v, v, v))}))
|
|||
|
sca1 = TclTkWidget.new(ip, t1, scale,
|
|||
|
"-label scale -orient h -from 0 -to 255 -variable", v1, "-command", c)
|
|||
|
pack.e(b1, sca1)
|
|||
|
end
|
|||
|
|
|||
|
# entry <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_entry(ip, parent)
|
|||
|
button, entry, global, pack = ip.commands().indexes(
|
|||
|
"button", "entry", "global", "pack")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "entry")
|
|||
|
|
|||
|
## entry
|
|||
|
|
|||
|
v1 = TclTkVariable.new(ip, nil)
|
|||
|
global.e(v1)
|
|||
|
# <20>̥륹<CCA5>ȥ<EFBFBD><C8A5><EFBFBD> "{}" <20>ǻ<EFBFBD><C7BB>ꤹ<EFBFBD><EAA4B9>.
|
|||
|
v1.set("{}")
|
|||
|
en1 = TclTkWidget.new(ip, t1, entry, "-textvariable", v1)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
global.e(v1); print(v1.get(), "\n"); v1.set("{}")}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c)
|
|||
|
pack.e(b1, en1, b2)
|
|||
|
end
|
|||
|
|
|||
|
# text <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_text(ip, parent)
|
|||
|
button, pack, text = ip.commands().indexes(
|
|||
|
"button", "pack", "text")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "text")
|
|||
|
|
|||
|
## text
|
|||
|
|
|||
|
te1 = TclTkWidget.new(ip, t1, text)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
# 1 <20><><EFBFBD>ܤ<EFBFBD> 0 ʸ<><CAB8><EFBFBD>ܤ<EFBFBD><DCA4><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>ޤǤ<DEA4>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
print(te1.e("get 1.0 end")); te1.e("delete 1.0 end")}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c)
|
|||
|
pack.e(b1, te1, b2)
|
|||
|
end
|
|||
|
|
|||
|
# raise/lower <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_raise(ip, parent)
|
|||
|
button, frame, lower, pack, raise = ip.commands().indexes(
|
|||
|
"button", "frame", "lower", "pack", "raise")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "raise/lower")
|
|||
|
|
|||
|
## raise/lower
|
|||
|
|
|||
|
# button <20><EFBFBD><F2B1A3A4>ƥ<EFBFBD><C6A5>ȤΤ<C8A4><CEA4><EFBFBD><EFBFBD><EFBFBD>, frame <20><><EFBFBD>Ȥ<EFBFBD>.
|
|||
|
f1 = TclTkWidget.new(ip, t1, frame)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD>.
|
|||
|
b2 = nil
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{raise.e(f1, b2)}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text raise -command", c)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{lower.e(f1, b2)}))
|
|||
|
b3 = TclTkWidget.new(ip, t1, button, "-text lower -command", c)
|
|||
|
lower.e(f1, b3)
|
|||
|
|
|||
|
pack.e(b2, b3, "-in", f1)
|
|||
|
pack.e(b1, f1)
|
|||
|
end
|
|||
|
|
|||
|
# modal <20>ʥ<EFBFBD><CAA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤΥ<C8A4><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_modal(ip, parent)
|
|||
|
button, frame, message, pack, tk_chooseColor, tk_getOpenFile,
|
|||
|
tk_messageBox = ip.commands().indexes(
|
|||
|
"button", "frame", "message", "pack", "tk_chooseColor",
|
|||
|
"tk_getOpenFile", "tk_messageBox")
|
|||
|
# <20>ǽ<EFBFBD><C7BD><EFBFBD> load <20><><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ʤ<EFBFBD><CAA4>饤<EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD> ip.commands() <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4>ʤ<EFBFBD><CAA4>Τ<EFBFBD>,
|
|||
|
# TclTkLibCommand <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD>פ<EFBFBD><D7A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
tk_dialog = TclTkLibCommand.new(ip, "tk_dialog")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "message/modal")
|
|||
|
|
|||
|
## message
|
|||
|
|
|||
|
mes = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> message <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤΥƥ<CEA5><C6A5>ȤǤ<C8A4>."
|
|||
|
mes += "<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD> modal <20>ʥ<EFBFBD><CAA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤΥƥ<CEA5><C6A5>ȤǤ<C8A4>."
|
|||
|
me1 = TclTkWidget.new(ip, t1, message, "-text {#{mes}}")
|
|||
|
|
|||
|
## modal
|
|||
|
|
|||
|
# tk_messageBox
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
print tk_messageBox.e("-type yesnocancel -message messageBox",
|
|||
|
"-icon error -default cancel -title messageBox"), "\n"}))
|
|||
|
b2 = TclTkWidget.new(ip, t1, button, "-text messageBox -command", c)
|
|||
|
# tk_dialog
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤿<EFBFBD><EBA4BF><EFBFBD>˥<EFBFBD><CBA5>ߡ<EFBFBD><DFA1><EFBFBD> frame <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
print tk_dialog.e(TclTkWidget.new(ip, t1, frame),
|
|||
|
"dialog dialog error 2 yes no cancel"), "\n"}))
|
|||
|
b3 = TclTkWidget.new(ip, t1, button, "-text dialog -command", c)
|
|||
|
# tk_chooseColor
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
print tk_chooseColor.e("-title chooseColor"), "\n"}))
|
|||
|
b4 = TclTkWidget.new(ip, t1, button, "-text chooseColor -command", c)
|
|||
|
# tk_getOpenFile
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
print tk_getOpenFile.e("-defaultextension .rb",
|
|||
|
"-filetypes {{{Ruby Script} {.rb}} {{All Files} {*}}}",
|
|||
|
"-title getOpenFile"), "\n"}))
|
|||
|
b5 = TclTkWidget.new(ip, t1, button, "-text getOpenFile -command", c)
|
|||
|
|
|||
|
pack.e(b1, me1, b2, b3, b4, b5)
|
|||
|
end
|
|||
|
|
|||
|
# menu <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_menu(ip, parent)
|
|||
|
global, menu, menubutton, pack = ip.commands().indexes(
|
|||
|
"global", "menu", "menubutton", "pack")
|
|||
|
tk_optionMenu = TclTkLibCommand.new(ip, "tk_optionMenu")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "menu")
|
|||
|
|
|||
|
## menu
|
|||
|
|
|||
|
# menubutton <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
mb1 = TclTkWidget.new(ip, t1, menubutton, "-text menu")
|
|||
|
# menu <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
me1 = TclTkWidget.new(ip, mb1, menu)
|
|||
|
# mb1 <20><><EFBFBD><EFBFBD> me1 <20><><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>褦<EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>.
|
|||
|
mb1.e("configure -menu", me1)
|
|||
|
|
|||
|
# cascade <20>ǵ<EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> menu <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
me11 = TclTkWidget.new(ip, me1, menu)
|
|||
|
# radiobutton <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
v1 = TclTkVariable.new(ip, nil); global.e(v1); v1.set("r1")
|
|||
|
me11.e("add radiobutton -label radio1 -value r1 -variable", v1)
|
|||
|
me11.e("add radiobutton -label radio2 -value r2 -variable", v1)
|
|||
|
me11.e("add radiobutton -label radio3 -value r3 -variable", v1)
|
|||
|
# cascade <20>ˤ<EFBFBD><CBA4><EFBFBD> mb11 <20><><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>褦<EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>.
|
|||
|
me1.e("add cascade -label cascade -menu", me11)
|
|||
|
|
|||
|
# checkbutton <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
v2 = TclTkVariable.new(ip, nil); global.e(v2); v2.set("none")
|
|||
|
me1.e("add checkbutton -label check -variable", v2)
|
|||
|
# separator <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
me1.e("add separator")
|
|||
|
# command <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
v3 = nil
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
global.e(v1, v2, v3); print "v1: ", v1.get(), ", v2: ", v2.get(),
|
|||
|
", v3: ", v3.get(), "\n"}))
|
|||
|
me1.e("add command -label print -command", c)
|
|||
|
|
|||
|
## tk_optionMenu
|
|||
|
|
|||
|
v3 = TclTkVariable.new(ip, nil); global.e(v3); v3.set("opt2")
|
|||
|
om1 = TclTkWidget.new(ip, t1, tk_optionMenu, v3, "opt1 opt2 opt3 opt4")
|
|||
|
|
|||
|
pack.e(b1, mb1, om1, "-side left")
|
|||
|
end
|
|||
|
|
|||
|
# listbox <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_listbox(ip, parent)
|
|||
|
clipboard, frame, grid, listbox, lower, menu, menubutton, pack, scrollbar,
|
|||
|
selection = ip.commands().indexes(
|
|||
|
"clipboard", "frame", "grid", "listbox", "lower", "menu", "menubutton",
|
|||
|
"pack", "scrollbar", "selection")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "listbox")
|
|||
|
|
|||
|
## listbox/scrollbar
|
|||
|
|
|||
|
f1 = TclTkWidget.new(ip, t1, frame)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD>.
|
|||
|
li1 = sc1 = sc2 = nil
|
|||
|
# <20>¹Ի<C2B9><D4BB><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>˥ѥ<CBA5><D1A5><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD>Ĥ<EFBFBD><C4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Хå<D0A5><C3A5><EFBFBD>,
|
|||
|
# <20><><EFBFBD>ƥ졼<C6A5><ECA1BC><EFBFBD>ѿ<EFBFBD><D1BF>Ǥ<EFBFBD><C7A4>Υѥ<CEA5><D1A5><EFBFBD><E1A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4><EFBFBD>.
|
|||
|
# (ʣ<><CAA3><EFBFBD>Υѥ<CEA5><D1A5><EFBFBD><E1A1BC><EFBFBD>ϤҤȤĤ<C8A4>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD>ˤޤȤ<DEA4><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.)
|
|||
|
cb.push(c1 = TclTkCallback.new(ip, proc{|i| li1.e("xview", i)}))
|
|||
|
cb.push(c2 = TclTkCallback.new(ip, proc{|i| li1.e("yview", i)}))
|
|||
|
cb.push(c3 = TclTkCallback.new(ip, proc{|i| sc1.e("set", i)}))
|
|||
|
cb.push(c4 = TclTkCallback.new(ip, proc{|i| sc2.e("set", i)}))
|
|||
|
# listbox
|
|||
|
li1 = TclTkWidget.new(ip, f1, listbox,
|
|||
|
"-xscrollcommand", c3, "-yscrollcommand", c4,
|
|||
|
"-selectmode extended -exportselection true")
|
|||
|
for i in 1..20
|
|||
|
li1.e("insert end {line #{i} line #{i} line #{i} line #{i} line #{i}}")
|
|||
|
end
|
|||
|
# scrollbar
|
|||
|
sc1 = TclTkWidget.new(ip, f1, scrollbar, "-orient horizontal -command", c1)
|
|||
|
sc2 = TclTkWidget.new(ip, f1, scrollbar, "-orient vertical -command", c2)
|
|||
|
|
|||
|
## selection/clipboard
|
|||
|
|
|||
|
mb1 = TclTkWidget.new(ip, t1, menubutton, "-text edit")
|
|||
|
me1 = TclTkWidget.new(ip, mb1, menu)
|
|||
|
mb1.e("configure -menu", me1)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
# clipboard <20>ꥢ.
|
|||
|
clipboard.e("clear")
|
|||
|
# selection <20><><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɤ߹<C9A4><DFB9><EFBFBD> clipboard <20><><EFBFBD>ɲä<C9B2><C3A4><EFBFBD>.
|
|||
|
clipboard.e("append {#{selection.e(\"get\")}}")}))
|
|||
|
me1.e("add command -label {selection -> clipboard} -command",c)
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{
|
|||
|
# li1 <20>ꥢ.
|
|||
|
li1.e("delete 0 end")
|
|||
|
# clipboard <20><><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD>, 1 <20>Ԥ<EFBFBD><D4A4><EFBFBD>
|
|||
|
selection.e("get -selection CLIPBOARD").split(/\n/).each{|line|
|
|||
|
# li1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
li1.e("insert end {#{line}}")}}))
|
|||
|
me1.e("add command -label {clipboard -> listbox} -command",c)
|
|||
|
|
|||
|
grid.e(li1, "-row 0 -column 0 -sticky news")
|
|||
|
grid.e(sc1, "-row 1 -column 0 -sticky ew")
|
|||
|
grid.e(sc2, "-row 0 -column 1 -sticky ns")
|
|||
|
grid.e("rowconfigure", f1, "0 -weight 100")
|
|||
|
grid.e("columnconfigure", f1, "0 -weight 100")
|
|||
|
f2 = TclTkWidget.new(ip, t1, frame)
|
|||
|
lower.e(f2, b1)
|
|||
|
pack.e(b1, mb1, "-in", f2, "-side left")
|
|||
|
pack.e(f2, f1)
|
|||
|
end
|
|||
|
|
|||
|
# canvas <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ץ<EFBFBD>.
|
|||
|
def test_canvas(ip, parent)
|
|||
|
canvas, lower, pack = ip.commands().indexes("canvas", "lower", "pack")
|
|||
|
t1, b1, cb = inittoplevel(ip, parent, "canvas")
|
|||
|
|
|||
|
## canvas
|
|||
|
|
|||
|
ca1 = TclTkWidget.new(ip, t1, canvas, "-width 400 -height 300")
|
|||
|
lower.e(ca1, b1)
|
|||
|
# rectangle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
idr = ca1.e("create rectangle 10 10 20 20")
|
|||
|
# oval <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create oval 60 10 100 50")
|
|||
|
# polygon <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create polygon 110 10 110 30 140 10")
|
|||
|
# line <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create line 150 10 150 30 190 10")
|
|||
|
# arc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create arc 200 10 250 50 -start 0 -extent 90 -style pieslice")
|
|||
|
# i1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD>Фʤ<D0A4><CAA4>ʤ<EFBFBD><CAA4><EFBFBD>, <20><><EFBFBD>ݤʤΤ<CAA4><CEA4><EFBFBD><EFBFBD>äƤ<C3A4><C6A4><EFBFBD>.
|
|||
|
i1 = TclTkImage.new(ip, "photo", "-file maru.gif")
|
|||
|
# image <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create image 100 100 -image", i1)
|
|||
|
# bitmap <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create bitmap 260 50 -bitmap questhead")
|
|||
|
# text <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("create text 320 50 -text {drag rectangle}")
|
|||
|
# window <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>).
|
|||
|
ca1.e("create window 200 200 -window", b1)
|
|||
|
|
|||
|
# bind <20>ˤ<EFBFBD><CBA4><EFBFBD> rectangle <20><> drag <20>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD>褦<EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>.
|
|||
|
cb.push(c = TclTkCallback.new(ip, proc{|i|
|
|||
|
# i <20><> x <20><> y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ф<EFBFBD>.
|
|||
|
x, y = i.split(/ /); x = x.to_f; y = y.to_f
|
|||
|
# <20><>ɸ<EFBFBD><C9B8><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("coords current #{x - 5} #{y - 5} #{x + 5} #{y + 5}")},
|
|||
|
# x, y <20><>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>ڤä<DAA4><C3A4><EFBFBD><EFBFBD>Τƥ졼<C6A5><ECA1BC><EFBFBD>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4>褦<EFBFBD>˻<EFBFBD><CBBB><EFBFBD>.
|
|||
|
"%x %y"))
|
|||
|
# rectangle <20><> bind <20><><EFBFBD><EFBFBD>.
|
|||
|
ca1.e("bind", idr, "<B1-Motion>", c)
|
|||
|
|
|||
|
pack.e(ca1)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
# test driver
|
|||
|
|
|||
|
if ARGV.size == 0
|
|||
|
print "#{$0} n <20><>, n <20>ĤΥ<C4A4><CEA5>ץ<D7A5><EAA5BF><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD>ޤ<EFBFBD>.\n"
|
|||
|
n = 1
|
|||
|
else
|
|||
|
n = ARGV[0].to_i
|
|||
|
end
|
|||
|
|
|||
|
print "start\n"
|
|||
|
ip = []
|
|||
|
|
|||
|
# <20><><EFBFBD>ץ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
for i in 1 .. n
|
|||
|
ip.push(Test1.new())
|
|||
|
end
|
|||
|
|
|||
|
# <20>Ѱդ<D1B0><D5A4>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD>饤<EFBFBD>٥<EFBFBD><D9A5>ȥ롼<C8A5>פ<EFBFBD><D7A4><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
TclTk.mainloop()
|
|||
|
print "exit from mainloop\n"
|
|||
|
|
|||
|
# <20><><EFBFBD>ץ<D7A5><EAA5BF> GC <20><><EFBFBD><EFBFBD><EFBFBD>뤫<EFBFBD>Υƥ<CEA5><C6A5><EFBFBD>.
|
|||
|
ip = []
|
|||
|
print "GC.start\n" if $DEBUG
|
|||
|
GC.start() if $DEBUG
|
|||
|
print "end\n"
|
|||
|
|
|||
|
exit
|
|||
|
|
|||
|
# end
|