* (bug fix) TkEntry#delete
* (bug fix) some widget demos * support <TkVariable object> == <Symbol> ( "coerce TkVariable" add to the TODO list :-) ) * freeze some object for security reason git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d7bdf5df56
commit
4c3328f547
@ -35,6 +35,7 @@ sample/resource.ja
|
|||||||
sample/resource.en
|
sample/resource.en
|
||||||
sample/tktimer.rb
|
sample/tktimer.rb
|
||||||
sample/tktimer2.rb
|
sample/tktimer2.rb
|
||||||
|
sample/tktimer3.rb
|
||||||
sample/demos-en/ChangeLog
|
sample/demos-en/ChangeLog
|
||||||
sample/demos-en/ChangeLog.prev
|
sample/demos-en/ChangeLog.prev
|
||||||
sample/demos-en/README
|
sample/demos-en/README
|
||||||
|
@ -33,7 +33,7 @@ MultiTkIp_OK.freeze
|
|||||||
################################################
|
################################################
|
||||||
# methods for construction
|
# methods for construction
|
||||||
class MultiTkIp
|
class MultiTkIp
|
||||||
SLAVE_IP_ID = ['slave'.freeze, '0']
|
SLAVE_IP_ID = ['slave'.freeze, '0'].freeze
|
||||||
|
|
||||||
@@IP_TABLE = {}
|
@@IP_TABLE = {}
|
||||||
|
|
||||||
@ -234,7 +234,12 @@ class MultiTkIp
|
|||||||
|
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
SAFE_OPT_LIST = ['accessPath', 'statics', 'nested', 'deleteHook']
|
SAFE_OPT_LIST = [
|
||||||
|
'accessPath'.freeze,
|
||||||
|
'statics'.freeze,
|
||||||
|
'nested'.freeze,
|
||||||
|
'deleteHook'.freeze
|
||||||
|
].freeze
|
||||||
def _parse_slaveopts(keys)
|
def _parse_slaveopts(keys)
|
||||||
name = nil
|
name = nil
|
||||||
safe = false
|
safe = false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
#
|
||||||
# tk.rb - Tk interface module using tcltklib
|
# tk.rb - Tk interface module using tcltklib
|
||||||
# $Date$
|
# $Date$
|
||||||
# by Yukihiro Matsumoto <matz@netlab.jp>
|
# by Yukihiro Matsumoto <matz@netlab.jp>
|
||||||
@ -17,7 +17,7 @@ module TkComm
|
|||||||
|
|
||||||
#Tk_CMDTBL = {}
|
#Tk_CMDTBL = {}
|
||||||
#Tk_WINDOWS = {}
|
#Tk_WINDOWS = {}
|
||||||
Tk_IDs = ["00000", "00000"] # [0]-cmdid, [1]-winid
|
Tk_IDs = ["00000", "00000"].freeze # [0]-cmdid, [1]-winid
|
||||||
|
|
||||||
# for backward compatibility
|
# for backward compatibility
|
||||||
Tk_CMDTBL = Object.new
|
Tk_CMDTBL = Object.new
|
||||||
@ -1651,7 +1651,7 @@ class TkBindTag
|
|||||||
|
|
||||||
#BTagID_TBL = {}
|
#BTagID_TBL = {}
|
||||||
BTagID_TBL = TkCore::INTERP.create_table
|
BTagID_TBL = TkCore::INTERP.create_table
|
||||||
Tk_BINDTAG_ID = ["btag".freeze, "00000"]
|
Tk_BINDTAG_ID = ["btag".freeze, "00000"].freeze
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ BTagID_TBL.clear }
|
TkCore::INTERP.init_ip_env{ BTagID_TBL.clear }
|
||||||
|
|
||||||
@ -1726,7 +1726,7 @@ class TkVariable
|
|||||||
#TkVar_ID_TBL = {}
|
#TkVar_ID_TBL = {}
|
||||||
TkVar_CB_TBL = TkCore::INTERP.create_table
|
TkVar_CB_TBL = TkCore::INTERP.create_table
|
||||||
TkVar_ID_TBL = TkCore::INTERP.create_table
|
TkVar_ID_TBL = TkCore::INTERP.create_table
|
||||||
Tk_VARIABLE_ID = ["v".freeze, "00000"]
|
Tk_VARIABLE_ID = ["v".freeze, "00000"].freeze
|
||||||
|
|
||||||
TkCore::INTERP.add_tk_procs('rb_var', 'args',
|
TkCore::INTERP.add_tk_procs('rb_var', 'args',
|
||||||
"ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
"ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
||||||
@ -1839,6 +1839,10 @@ class TkVariable
|
|||||||
string(value).to_s
|
string(value).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_sym
|
||||||
|
value.intern
|
||||||
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
format "#<TkVariable: %s>", @id
|
format "#<TkVariable: %s>", @id
|
||||||
end
|
end
|
||||||
@ -1849,6 +1853,8 @@ class TkVariable
|
|||||||
self.equal?(other)
|
self.equal?(other)
|
||||||
when String
|
when String
|
||||||
self.to_s == other
|
self.to_s == other
|
||||||
|
when Symbol
|
||||||
|
self.to_sym == other
|
||||||
when Integer
|
when Integer
|
||||||
self.to_i == other
|
self.to_i == other
|
||||||
when Float
|
when Float
|
||||||
@ -4630,7 +4636,7 @@ end
|
|||||||
module TkTreatListItemFont
|
module TkTreatListItemFont
|
||||||
include TkTreatItemFont
|
include TkTreatItemFont
|
||||||
|
|
||||||
ItemCMD = ['itemconfigure', TkComm::None]
|
ItemCMD = ['itemconfigure'.freeze, TkComm::None].freeze
|
||||||
def __conf_cmd(idx)
|
def __conf_cmd(idx)
|
||||||
ItemCMD[idx]
|
ItemCMD[idx]
|
||||||
end
|
end
|
||||||
@ -4770,7 +4776,7 @@ end
|
|||||||
module TkTreatMenuEntryFont
|
module TkTreatMenuEntryFont
|
||||||
include TkTreatItemFont
|
include TkTreatItemFont
|
||||||
|
|
||||||
ItemCMD = ['entryconfigure', TkComm::None]
|
ItemCMD = ['entryconfigure'.freeze, TkComm::None].freeze
|
||||||
def __conf_cmd(idx)
|
def __conf_cmd(idx)
|
||||||
ItemCMD[idx]
|
ItemCMD[idx]
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ class TkTimer
|
|||||||
|
|
||||||
TkCommandNames = ['after'.freeze].freeze
|
TkCommandNames = ['after'.freeze].freeze
|
||||||
|
|
||||||
Tk_CBID = ['a'.freeze, '00000']
|
Tk_CBID = ['a'.freeze, '00000'].freeze
|
||||||
Tk_CBTBL = {}
|
Tk_CBTBL = {}
|
||||||
|
|
||||||
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
|
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
|
||||||
@ -311,6 +311,22 @@ class TkTimer
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset(*reset_args)
|
||||||
|
restart() if @running
|
||||||
|
|
||||||
|
if @init_proc
|
||||||
|
@return_value = @init_proc.call(self)
|
||||||
|
else
|
||||||
|
@return_value = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
@current_pos = 0
|
||||||
|
@current_args = @init_args
|
||||||
|
@set_next = false if @in_callback
|
||||||
|
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
def restart(*restart_args)
|
def restart(*restart_args)
|
||||||
cancel if @running
|
cancel if @running
|
||||||
if restart_args == []
|
if restart_args == []
|
||||||
|
@ -11,7 +11,7 @@ require 'tkfont'
|
|||||||
module TkTreatCItemFont
|
module TkTreatCItemFont
|
||||||
include TkTreatItemFont
|
include TkTreatItemFont
|
||||||
|
|
||||||
ItemCMD = ['itemconfigure', TkComm::None]
|
ItemCMD = ['itemconfigure'.freeze, TkComm::None].freeze
|
||||||
def __conf_cmd(idx)
|
def __conf_cmd(idx)
|
||||||
ItemCMD[idx]
|
ItemCMD[idx]
|
||||||
end
|
end
|
||||||
@ -529,7 +529,7 @@ class TkcTag<TkObject
|
|||||||
include TkcTagAccess
|
include TkcTagAccess
|
||||||
|
|
||||||
CTagID_TBL = TkCore::INTERP.create_table
|
CTagID_TBL = TkCore::INTERP.create_table
|
||||||
Tk_CanvasTag_ID = ['ctag', '00000']
|
Tk_CanvasTag_ID = ['ctag'.freeze, '00000'].freeze
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ CTagID_TBL.clear }
|
TkCore::INTERP.init_ip_env{ CTagID_TBL.clear }
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ class TkcTagCurrent<TkcTag
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TkcGroup<TkcTag
|
class TkcGroup<TkcTag
|
||||||
Tk_cGroup_ID = ['tkcg', '00000']
|
Tk_cGroup_ID = ['tkcg'.freeze, '00000'].freeze
|
||||||
def create_self(parent, *args)
|
def create_self(parent, *args)
|
||||||
if not parent.kind_of?(TkCanvas)
|
if not parent.kind_of?(TkCanvas)
|
||||||
fail format("%s need to be TkCanvas", parent.inspect)
|
fail format("%s need to be TkCanvas", parent.inspect)
|
||||||
@ -823,7 +823,7 @@ class TkImage<TkObject
|
|||||||
TkCommandNames = ['image'.freeze].freeze
|
TkCommandNames = ['image'.freeze].freeze
|
||||||
|
|
||||||
Tk_IMGTBL = TkCore::INTERP.create_table
|
Tk_IMGTBL = TkCore::INTERP.create_table
|
||||||
Tk_Image_ID = ['i', '00000']
|
Tk_Image_ID = ['i'.freeze, '00000'].freeze
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
|
TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ class TkEntry<TkLabel
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
def delete(first, last=None)
|
def delete(first, last=None)
|
||||||
tk_send 'insert', first, last
|
tk_send 'delete', first, last
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
def mark(pos)
|
def mark(pos)
|
||||||
|
@ -11,7 +11,7 @@ class TkFont
|
|||||||
|
|
||||||
TkCommandNames = ['font'.freeze].freeze
|
TkCommandNames = ['font'.freeze].freeze
|
||||||
|
|
||||||
Tk_FontID = ["@font".freeze, "00000"]
|
Tk_FontID = ["@font".freeze, "00000"].freeze
|
||||||
Tk_FontNameTBL = TkCore::INTERP.create_table
|
Tk_FontNameTBL = TkCore::INTERP.create_table
|
||||||
Tk_FontUseTBL = TkCore::INTERP.create_table
|
Tk_FontUseTBL = TkCore::INTERP.create_table
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ require 'tkfont'
|
|||||||
module TkTreatTextTagFont
|
module TkTreatTextTagFont
|
||||||
include TkTreatItemFont
|
include TkTreatItemFont
|
||||||
|
|
||||||
ItemCMD = ['tag', 'configure']
|
ItemCMD = ['tag'.freeze, 'configure'.freeze].freeze
|
||||||
def __conf_cmd(idx)
|
def __conf_cmd(idx)
|
||||||
ItemCMD[idx]
|
ItemCMD[idx]
|
||||||
end
|
end
|
||||||
@ -24,7 +24,7 @@ module TkTreatTextTagFont
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TkText<TkTextWin
|
class TkText<TkTextWin
|
||||||
ItemConfCMD = ['tag', 'configure']
|
ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
|
||||||
include TkTreatTextTagFont
|
include TkTreatTextTagFont
|
||||||
include Scrollable
|
include Scrollable
|
||||||
|
|
||||||
@ -767,7 +767,7 @@ class TkTextTag<TkObject
|
|||||||
include TkTreatTagFont
|
include TkTreatTagFont
|
||||||
|
|
||||||
TTagID_TBL = TkCore::INTERP.create_table
|
TTagID_TBL = TkCore::INTERP.create_table
|
||||||
Tk_TextTag_ID = ['tag', '00000']
|
Tk_TextTag_ID = ['tag'.freeze, '00000'].freeze
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ TTagID_TBL.clear }
|
TkCore::INTERP.init_ip_env{ TTagID_TBL.clear }
|
||||||
|
|
||||||
@ -971,7 +971,7 @@ end
|
|||||||
|
|
||||||
class TkTextMark<TkObject
|
class TkTextMark<TkObject
|
||||||
TMarkID_TBL = TkCore::INTERP.create_table
|
TMarkID_TBL = TkCore::INTERP.create_table
|
||||||
Tk_TextMark_ID = ['mark', '00000']
|
Tk_TextMark_ID = ['mark'.freeze, '00000'].freeze
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear }
|
TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear }
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class TkVirtualEvent<TkObject
|
|||||||
|
|
||||||
TkCommandNames = ['event'.freeze].freeze
|
TkCommandNames = ['event'.freeze].freeze
|
||||||
|
|
||||||
TkVirtualEventID = ["<VirtEvent".freeze, "00000", ">".freeze]
|
TkVirtualEventID = ["<VirtEvent".freeze, "00000", ">".freeze].freeze
|
||||||
TkVirtualEventTBL = TkCore::INTERP.create_table
|
TkVirtualEventTBL = TkCore::INTERP.create_table
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear }
|
TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear }
|
||||||
|
@ -53,10 +53,8 @@ class Rmt
|
|||||||
|
|
||||||
# Create text window and scrollbar.
|
# Create text window and scrollbar.
|
||||||
|
|
||||||
@txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {|t|
|
@txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
|
||||||
TkScrollbar.new(root, 'command'=>proc{|*args| t.yview *args}) {
|
yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
|
||||||
pack('side'=>'right', 'fill'=>'both')
|
|
||||||
}
|
|
||||||
pack('side'=>'left')
|
pack('side'=>'left')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +245,7 @@ class Rmt
|
|||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
TkWinfo.interps.sort.each{|ip|
|
TkWinfo.interps.sort.each{|ip|
|
||||||
|
begin
|
||||||
if Tk.appsend(ip, false, 'info commands ruby') == ""
|
if Tk.appsend(ip, false, 'info commands ruby') == ""
|
||||||
mode = 'Tcl'
|
mode = 'Tcl'
|
||||||
else
|
else
|
||||||
@ -254,6 +253,10 @@ class Rmt
|
|||||||
end
|
end
|
||||||
menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
|
menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
|
||||||
'command'=>proc{win.newApp ip, mode})
|
'command'=>proc{win.newApp ip, mode})
|
||||||
|
rescue
|
||||||
|
menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
|
||||||
|
'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
|
||||||
|
end
|
||||||
}
|
}
|
||||||
menu.add('command', 'label'=>format("local (Ruby/Tk)"),
|
menu.add('command', 'label'=>format("local (Ruby/Tk)"),
|
||||||
'command'=>proc{win.newApp 'local', 'Ruby'})
|
'command'=>proc{win.newApp 'local', 'Ruby'})
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This script is a part of Tom LaStrange's rolodex
|
# This script is a part of Tom LaStrange's rolodex
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
||||||
# Time-stamp: "98/07/20 12:00:02 ttate"
|
# Time-stamp: "03/08/02 06:23:06 nagai"
|
||||||
#
|
#
|
||||||
|
|
||||||
require "tk"
|
require "tk"
|
||||||
@ -176,8 +176,8 @@ end
|
|||||||
class Rolodex < TkRoot
|
class Rolodex < TkRoot
|
||||||
attr_reader :frame, :buttons, :menu
|
attr_reader :frame, :buttons, :menu
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@frame = RolodexFrame.new(self)
|
@frame = RolodexFrame.new(self)
|
||||||
@frame.pack("side"=>"top",
|
@frame.pack("side"=>"top",
|
||||||
"fill"=>"y",
|
"fill"=>"y",
|
||||||
@ -314,7 +314,7 @@ Ctrl+S: Search (dummy operation)
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
$helpTopics["version"] = <<EOF
|
$helpTopics["version"] = <<EOF
|
||||||
This is version 1.0.
|
This is version 1.0.1.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
Tk.mainloop
|
Tk.mainloop
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
# このスクリプトは Tom LaStrange の rolodex の一部です。
|
# このスクリプトは Tom LaStrange の rolodex の一部です。
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
||||||
# Time-stamp: "98/07/20 12:00:36 ttate"
|
# Time-stamp: "03/08/02 14:02:04 nagai"
|
||||||
#
|
#
|
||||||
|
|
||||||
require "tk"
|
require "tk"
|
||||||
require 'tkencoding'
|
|
||||||
|
|
||||||
Tk.encoding = "euc-jp"
|
Tk.encoding = "euc-jp"
|
||||||
$font = TkFont.new('k14')
|
$font = TkFont.new('k14')
|
||||||
@ -198,8 +197,8 @@ end
|
|||||||
class Rolodex < TkRoot
|
class Rolodex < TkRoot
|
||||||
attr_reader :frame, :buttons, :menu
|
attr_reader :frame, :buttons, :menu
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@frame = RolodexFrame.new(self)
|
@frame = RolodexFrame.new(self)
|
||||||
@frame.pack("side"=>"top",
|
@frame.pack("side"=>"top",
|
||||||
"fill"=>"y",
|
"fill"=>"y",
|
||||||
@ -318,7 +317,7 @@ Ctrl+S:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
$helpTopics["バージョン情報"] = <<EOF
|
$helpTopics["バージョン情報"] = <<EOF
|
||||||
バージョンは 1.0 です。
|
バージョンは 1.0.1e です。
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
Tk.mainloop
|
Tk.mainloop
|
||||||
|
@ -15,13 +15,20 @@ require 'tkafter'
|
|||||||
|
|
||||||
class TkSquare<TkWindow
|
class TkSquare<TkWindow
|
||||||
def create_self
|
def create_self
|
||||||
|
begin
|
||||||
tk_call 'square', path
|
tk_call 'square', path
|
||||||
|
rescue
|
||||||
|
STDERR.print "\nSorry. Your Tk interpreter does not contain " +
|
||||||
|
'a "square" demonstration widget.' +
|
||||||
|
"\n ( See documents included the Tcl/Tk source archive. )\n\n"
|
||||||
|
exit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def size(amount=nil)
|
def size(amount=nil)
|
||||||
if amount
|
if amount
|
||||||
tk_send 'size', amount
|
tk_send 'size', amount
|
||||||
else
|
else
|
||||||
number(tk_send 'size')
|
number(tk_send('size'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def position(x,y)
|
def position(x,y)
|
||||||
|
@ -30,6 +30,12 @@ $label2 = TkVariable.new("label2")
|
|||||||
$label3 = TkVariable.new("label3")
|
$label3 = TkVariable.new("label3")
|
||||||
|
|
||||||
|
|
||||||
|
# setup the entry of the resourc database
|
||||||
|
if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
|
||||||
|
TkOptionDB.add('*Entry.background', 'white')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# 各イベント用のメソッド
|
# 各イベント用のメソッド
|
||||||
|
|
||||||
def rgbToHsv(red,green,blue)
|
def rgbToHsv(red,green,blue)
|
||||||
@ -132,7 +138,7 @@ def tc_scaleChanged
|
|||||||
scale2 = $root.middle.middle.scale2
|
scale2 = $root.middle.middle.scale2
|
||||||
scale3 = $root.middle.middle.scale3
|
scale3 = $root.middle.middle.scale3
|
||||||
|
|
||||||
case $colorSpace.to_i
|
case $colorSpace.value.intern
|
||||||
when :rgb
|
when :rgb
|
||||||
$red = (scale1.get * 65.535).to_i
|
$red = (scale1.get * 65.535).to_i
|
||||||
$green = (scale2.get * 65.535).to_i
|
$green = (scale2.get * 65.535).to_i
|
||||||
@ -167,7 +173,7 @@ def tc_setScales
|
|||||||
scale2 = $root.middle.middle.scale2
|
scale2 = $root.middle.middle.scale2
|
||||||
scale3 = $root.middle.middle.scale3
|
scale3 = $root.middle.middle.scale3
|
||||||
|
|
||||||
case $colorSpace.to_i
|
case $colorSpace.value.intern
|
||||||
when :rgb
|
when :rgb
|
||||||
scale1.set($red / 65.535)
|
scale1.set($red / 65.535)
|
||||||
scale2.set($green / 65.535)
|
scale2.set($green / 65.535)
|
||||||
@ -289,7 +295,7 @@ class TkColorMenuFrame<TkFrame
|
|||||||
"command" => proc{changeColorSpace(:hsb)}
|
"command" => proc{changeColorSpace(:hsb)}
|
||||||
add "separator"
|
add "separator"
|
||||||
add "radio",
|
add "radio",
|
||||||
"label" => "Qutomatic updates",
|
"label" => "Automatic updates",
|
||||||
"variable" => $autoUpdate,
|
"variable" => $autoUpdate,
|
||||||
"value" => "1",
|
"value" => "1",
|
||||||
"underline" => "0"
|
"underline" => "0"
|
||||||
@ -367,7 +373,7 @@ class TkColorMiddleLeftFrame<TkFrame
|
|||||||
"relief"=>"sunken",
|
"relief"=>"sunken",
|
||||||
"borderwidth"=>"2",
|
"borderwidth"=>"2",
|
||||||
"exportselection"=>"false")
|
"exportselection"=>"false")
|
||||||
@scroll.command(proc{|*args| @names.yview *args})
|
@scroll.command(proc{|*args| @names.yview(*args)})
|
||||||
@names.bind("Double-1",proc{
|
@names.bind("Double-1",proc{
|
||||||
tc_loadNamedColor(@names.get(@names.curselection))})
|
tc_loadNamedColor(@names.get(@names.curselection))})
|
||||||
@names.pack("side"=>"left")
|
@names.pack("side"=>"left")
|
||||||
@ -490,8 +496,8 @@ end
|
|||||||
class TkColor<TkRoot
|
class TkColor<TkRoot
|
||||||
attr_reader :menu, :bottom, :middle
|
attr_reader :menu, :bottom, :middle
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@menu = TkColorMenuFrame.new(self)
|
@menu = TkColorMenuFrame.new(self)
|
||||||
@menu.pack("side"=>"top", "fill"=>"x")
|
@menu.pack("side"=>"top", "fill"=>"x")
|
||||||
|
|
||||||
|
@ -80,12 +80,28 @@ end
|
|||||||
class ButtonFrame < TkFrame
|
class ButtonFrame < TkFrame
|
||||||
def initialize(parent=nil,keys=nil)
|
def initialize(parent=nil,keys=nil)
|
||||||
super(parent,keys)
|
super(parent,keys)
|
||||||
|
=begin
|
||||||
@stop = TkButton.new(self,
|
@stop = TkButton.new(self,
|
||||||
'text'=>'Stop',
|
'text'=>'Stop',
|
||||||
'command'=>proc{timer_stop})
|
'command'=>proc{timer_stop})
|
||||||
@start = TkButton.new(self,
|
@start = TkButton.new(self,
|
||||||
'text'=>'Start',
|
'text'=>'Start',
|
||||||
'command'=>proc{timer_start})
|
'command'=>proc{timer_start})
|
||||||
|
=end
|
||||||
|
@stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
|
||||||
|
@start = TkButton.new(self, :text=>'Start', :state=>:normal)
|
||||||
|
|
||||||
|
@stop.command proc{
|
||||||
|
timer_stop
|
||||||
|
@start.state(:normal)
|
||||||
|
@stop.state(:disabled)
|
||||||
|
}
|
||||||
|
@start.command proc{
|
||||||
|
timer_start
|
||||||
|
@stop.state(:normal)
|
||||||
|
@start.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
@reset = TkButton.new(self,
|
@reset = TkButton.new(self,
|
||||||
'text'=>'Reset',
|
'text'=>'Reset',
|
||||||
'command'=>proc{timer_reset})
|
'command'=>proc{timer_reset})
|
||||||
@ -99,8 +115,8 @@ end
|
|||||||
class Timer < TkRoot
|
class Timer < TkRoot
|
||||||
attr_reader :countframe
|
attr_reader :countframe
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@countframe = CountFrame.new(self)
|
@countframe = CountFrame.new(self)
|
||||||
@buttonframe = ButtonFrame.new(self)
|
@buttonframe = ButtonFrame.new(self)
|
||||||
for f in [@buttonframe,@countframe]
|
for f in [@buttonframe,@countframe]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# browse --
|
# browse --
|
||||||
# This script generates a directory browser, which lists the working
|
# This script generates a directory browser, which lists the working
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# browse --
|
# browse --
|
||||||
# This script generates a directory browser, which lists the working
|
# This script generates a directory browser, which lists the working
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
require 'tk'
|
require 'tk'
|
||||||
|
|
||||||
TkButton.new(nil,
|
TkButton.new(nil,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# ixset --
|
# ixset --
|
||||||
# A nice interface to "xset" to change X server settings
|
# A nice interface to "xset" to change X server settings
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# rmt --
|
# rmt --
|
||||||
# This script implements a simple remote-control mechanism for
|
# This script implements a simple remote-control mechanism for
|
||||||
@ -53,10 +53,8 @@ class Rmt
|
|||||||
|
|
||||||
# Create text window and scrollbar.
|
# Create text window and scrollbar.
|
||||||
|
|
||||||
@txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {|t|
|
@txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
|
||||||
TkScrollbar.new(root, 'command'=>proc{|*args| t.yview *args}) {
|
yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
|
||||||
pack('side'=>'right', 'fill'=>'both')
|
|
||||||
}
|
|
||||||
pack('side'=>'left')
|
pack('side'=>'left')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +245,7 @@ class Rmt
|
|||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
TkWinfo.interps.sort.each{|ip|
|
TkWinfo.interps.sort.each{|ip|
|
||||||
|
begin
|
||||||
if Tk.appsend(ip, false, 'info commands ruby') == ""
|
if Tk.appsend(ip, false, 'info commands ruby') == ""
|
||||||
mode = 'Tcl'
|
mode = 'Tcl'
|
||||||
else
|
else
|
||||||
@ -254,6 +253,10 @@ class Rmt
|
|||||||
end
|
end
|
||||||
menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
|
menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
|
||||||
'command'=>proc{win.newApp ip, mode})
|
'command'=>proc{win.newApp ip, mode})
|
||||||
|
rescue
|
||||||
|
menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
|
||||||
|
'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
|
||||||
|
end
|
||||||
}
|
}
|
||||||
menu.add('command', 'label'=>format("local (Ruby/Tk)"),
|
menu.add('command', 'label'=>format("local (Ruby/Tk)"),
|
||||||
'command'=>proc{win.newApp 'local', 'Ruby'})
|
'command'=>proc{win.newApp 'local', 'Ruby'})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# rolodex --
|
# rolodex --
|
||||||
# This script is a part of Tom LaStrange's rolodex
|
# This script is a part of Tom LaStrange's rolodex
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
||||||
# Time-stamp: "98/07/20 12:00:02 ttate"
|
# Time-stamp: "03/08/02 12:45:21 nagai"
|
||||||
#
|
#
|
||||||
|
|
||||||
require "tk"
|
require "tk"
|
||||||
@ -176,8 +176,8 @@ end
|
|||||||
class Rolodex < TkRoot
|
class Rolodex < TkRoot
|
||||||
attr_reader :frame, :buttons, :menu
|
attr_reader :frame, :buttons, :menu
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@frame = RolodexFrame.new(self)
|
@frame = RolodexFrame.new(self)
|
||||||
@frame.pack("side"=>"top",
|
@frame.pack("side"=>"top",
|
||||||
"fill"=>"y",
|
"fill"=>"y",
|
||||||
@ -314,7 +314,7 @@ Ctrl+S: Search (dummy operation)
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
$helpTopics["version"] = <<EOF
|
$helpTopics["version"] = <<EOF
|
||||||
This is version 1.0.
|
This is version 1.0.1.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
Tk.mainloop
|
Tk.mainloop
|
||||||
|
@ -1,21 +1,14 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# rolodex --
|
# rolodex --
|
||||||
# このスクリプトは Tom LaStrange の rolodex の一部です。
|
# このスクリプトは Tom LaStrange の rolodex の一部です。
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
||||||
# Time-stamp: "98/07/20 12:00:36 ttate"
|
# Time-stamp: "03/08/02 14:01:54 nagai"
|
||||||
#
|
#
|
||||||
|
|
||||||
require "tk"
|
require "tk"
|
||||||
|
Tk.encoding = "euc-jp"
|
||||||
# UTF8への変換を行なう。
|
|
||||||
|
|
||||||
$encoding = "euc-jp"
|
|
||||||
def j(str)
|
|
||||||
Tk.toUTF8(str,$encoding)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def show_help(topic,x=0,y=0)
|
def show_help(topic,x=0,y=0)
|
||||||
if( topic.is_a?(TkWindow) )
|
if( topic.is_a?(TkWindow) )
|
||||||
@ -33,17 +26,17 @@ def show_help(topic,x=0,y=0)
|
|||||||
msg = "このトピックについてのヘルプはまだ使用できません"
|
msg = "このトピックについてのヘルプはまだ使用できません"
|
||||||
end
|
end
|
||||||
TkDialog.new("title"=>"Rolodex Help",
|
TkDialog.new("title"=>"Rolodex Help",
|
||||||
"message"=>j("「#{topic}」\n\n#{msg}"),
|
"message"=>"「#{topic}」\n\n#{msg}",
|
||||||
"default_button"=>0,
|
"default_button"=>0,
|
||||||
"buttons"=>["OK"])
|
"buttons"=>["OK"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def fillCard
|
def fillCard
|
||||||
clearAction
|
clearAction
|
||||||
$root.frame.entry[1].insert(0,j("立石 孝彰"))
|
$root.frame.entry[1].insert(0, "立石 孝彰")
|
||||||
$root.frame.entry[2].insert(0,j("923-1292 石川県"))
|
$root.frame.entry[2].insert(0, "923-1292 石川県")
|
||||||
$root.frame.entry[3].insert(0,j("辰口町 旭台 1-1"))
|
$root.frame.entry[3].insert(0, "辰口町 旭台 1-1")
|
||||||
$root.frame.entry[4].insert(0,j("北陸先端科学技術大学院大学"))
|
$root.frame.entry[4].insert(0, "北陸先端科学技術大学院大学")
|
||||||
$root.frame.entry[5].insert(0,"private")
|
$root.frame.entry[5].insert(0,"private")
|
||||||
$root.frame.entry[6].insert(0,"***-***-****")
|
$root.frame.entry[6].insert(0,"***-***-****")
|
||||||
$root.frame.entry[7].insert(0,"***-***-****")
|
$root.frame.entry[7].insert(0,"***-***-****")
|
||||||
@ -53,7 +46,7 @@ def addAction
|
|||||||
for i in 1..7
|
for i in 1..7
|
||||||
STDERR.print format("%-12s %s\n",
|
STDERR.print format("%-12s %s\n",
|
||||||
RolodexFrame::LABEL[i],
|
RolodexFrame::LABEL[i],
|
||||||
Tk.fromUTF8($root.frame.entry[i].value,$encoding))
|
$root.frame.entry[i].value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,7 +58,7 @@ end
|
|||||||
|
|
||||||
def fileAction
|
def fileAction
|
||||||
TkDialog.new("title"=>"File Selection",
|
TkDialog.new("title"=>"File Selection",
|
||||||
"message"=>j("これはファイル選択ダイアログのダミーです。\n"),
|
"message"=>"これはファイル選択ダイアログのダミーです。\n",
|
||||||
"default_button"=>0,
|
"default_button"=>0,
|
||||||
"buttons"=>["OK"])
|
"buttons"=>["OK"])
|
||||||
STDERR.print "dummy file name\n"
|
STDERR.print "dummy file name\n"
|
||||||
@ -73,9 +66,9 @@ end
|
|||||||
|
|
||||||
def deleteAction
|
def deleteAction
|
||||||
result = TkDialog.new("title"=>"Confirm Action",
|
result = TkDialog.new("title"=>"Confirm Action",
|
||||||
"message"=>j("よろしいですか?"),
|
"message"=>"よろしいですか?",
|
||||||
"default_button"=>0,
|
"default_button"=>0,
|
||||||
"buttons"=>[j("キャンセル")])
|
"buttons"=>["キャンセル"])
|
||||||
if( result.value == 0 )
|
if( result.value == 0 )
|
||||||
clearAction
|
clearAction
|
||||||
end
|
end
|
||||||
@ -90,7 +83,6 @@ class RolodexFrame < TkFrame
|
|||||||
def initialize(parent=nil,keys=nil)
|
def initialize(parent=nil,keys=nil)
|
||||||
super(parent,keys)
|
super(parent,keys)
|
||||||
self["relief"] = "flat"
|
self["relief"] = "flat"
|
||||||
|
|
||||||
@i = []
|
@i = []
|
||||||
@label = []
|
@label = []
|
||||||
@entry = []
|
@entry = []
|
||||||
@ -100,7 +92,7 @@ class RolodexFrame < TkFrame
|
|||||||
"pady"=>2,
|
"pady"=>2,
|
||||||
"anchor"=>"e")
|
"anchor"=>"e")
|
||||||
@label[i] = TkLabel.new(@i[i],
|
@label[i] = TkLabel.new(@i[i],
|
||||||
"text"=>j(LABEL[i]),
|
"text"=>LABEL[i],
|
||||||
"anchor"=>"e")
|
"anchor"=>"e")
|
||||||
@entry[i] = TkEntry.new(@i[i],
|
@entry[i] = TkEntry.new(@i[i],
|
||||||
"width"=>30,
|
"width"=>30,
|
||||||
@ -116,14 +108,10 @@ class RolodexButtons < TkFrame
|
|||||||
|
|
||||||
def initialize(parent,keys=nil)
|
def initialize(parent,keys=nil)
|
||||||
super(parent,keys)
|
super(parent,keys)
|
||||||
@clear = TkButton.new(self,
|
@clear = TkButton.new(self,"text" => "クリアー")
|
||||||
"text" => j("クリアー"))
|
@add = TkButton.new(self, "text" => "追加")
|
||||||
@add = TkButton.new(self,
|
@search = TkButton.new(self, "text" => "検索")
|
||||||
"text" => j("追加"))
|
@delete = TkButton.new(self, "text" => "消去")
|
||||||
@search = TkButton.new(self,
|
|
||||||
"text" => j("検索"))
|
|
||||||
@delete = TkButton.new(self,
|
|
||||||
"text" => j("消去"))
|
|
||||||
for w in [@clear,@add,@search,@delete]
|
for w in [@clear,@add,@search,@delete]
|
||||||
w.pack("side"=>"left", "padx"=>2)
|
w.pack("side"=>"left", "padx"=>2)
|
||||||
end
|
end
|
||||||
@ -139,42 +127,42 @@ class RolodexMenuFrame < TkFrame
|
|||||||
"borderwidth"=>1)
|
"borderwidth"=>1)
|
||||||
|
|
||||||
@file = TkMenubutton.new(self,
|
@file = TkMenubutton.new(self,
|
||||||
"text"=>j("ファイル"),
|
"text"=> "ファイル",
|
||||||
"underline"=>0)
|
"underline"=>0)
|
||||||
@file_menu = TkMenu.new(@file)
|
@file_menu = TkMenu.new(@file)
|
||||||
@file_menu.add("command",
|
@file_menu.add("command",
|
||||||
"label" => j("読み込み ..."),
|
"label" => "読み込み ...",
|
||||||
"command" => proc{fileAction},
|
"command" => proc{fileAction},
|
||||||
"underline" => 0)
|
"underline" => 0)
|
||||||
@file_menu.add("command",
|
@file_menu.add("command",
|
||||||
"label" => j("終了"),
|
"label" => "終了",
|
||||||
"command" => proc{$root.destroy},
|
"command" => proc{$root.destroy},
|
||||||
"underline" => 0)
|
"underline" => 0)
|
||||||
@file.menu(@file_menu)
|
@file.menu(@file_menu)
|
||||||
@file.pack("side"=>"left")
|
@file.pack("side"=>"left")
|
||||||
|
|
||||||
@help = TkMenubutton.new(self,
|
@help = TkMenubutton.new(self,
|
||||||
"text"=>j("ヘルプ"),
|
"text"=> "ヘルプ",
|
||||||
"underline"=>0)
|
"underline"=>0)
|
||||||
@help_menu = TkMenu.new(@help)
|
@help_menu = TkMenu.new(@help)
|
||||||
@help_menu.add("command",
|
@help_menu.add("command",
|
||||||
"label"=>j("コンテキストについて"),
|
"label"=> "コンテキストについて",
|
||||||
"command"=>proc{show_help("コンテキスト")},
|
"command"=>proc{show_help("コンテキスト")},
|
||||||
"underline"=>3)
|
"underline"=>3)
|
||||||
@help_menu.add("command",
|
@help_menu.add("command",
|
||||||
"label"=>j("ヘルプについて"),
|
"label"=> "ヘルプについて",
|
||||||
"command"=>proc{show_help("ヘルプ")},
|
"command"=>proc{show_help("ヘルプ")},
|
||||||
"underline"=>3)
|
"underline"=>3)
|
||||||
@help_menu.add("command",
|
@help_menu.add("command",
|
||||||
"label"=>j("ウィンドウについて"),
|
"label"=> "ウィンドウについて",
|
||||||
"command"=>proc{show_help("ウィンドウ")},
|
"command"=>proc{show_help("ウィンドウ")},
|
||||||
"underline"=>3)
|
"underline"=>3)
|
||||||
@help_menu.add("command",
|
@help_menu.add("command",
|
||||||
"label"=>j("キー操作について"),
|
"label"=> "キー操作について",
|
||||||
"command"=>proc{show_help("キー操作")},
|
"command"=>proc{show_help("キー操作")},
|
||||||
"underline"=>3)
|
"underline"=>3)
|
||||||
@help_menu.add("command",
|
@help_menu.add("command",
|
||||||
"label"=>j("バージョン情報"),
|
"label"=> "バージョン情報",
|
||||||
"command"=>proc{show_help("バージョン情報")},
|
"command"=>proc{show_help("バージョン情報")},
|
||||||
"underline"=>3)
|
"underline"=>3)
|
||||||
@help.menu(@help_menu)
|
@help.menu(@help_menu)
|
||||||
@ -185,8 +173,8 @@ end
|
|||||||
class Rolodex < TkRoot
|
class Rolodex < TkRoot
|
||||||
attr_reader :frame, :buttons, :menu
|
attr_reader :frame, :buttons, :menu
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@frame = RolodexFrame.new(self)
|
@frame = RolodexFrame.new(self)
|
||||||
@frame.pack("side"=>"top",
|
@frame.pack("side"=>"top",
|
||||||
"fill"=>"y",
|
"fill"=>"y",
|
||||||
@ -209,16 +197,16 @@ $root.buttons.add.configure("command"=>proc{addAction})
|
|||||||
$root.buttons.clear.configure("command"=>proc{clearAction})
|
$root.buttons.clear.configure("command"=>proc{clearAction})
|
||||||
$root.buttons.search.configure("command"=>proc{addAction; fillCard})
|
$root.buttons.search.configure("command"=>proc{addAction; fillCard})
|
||||||
|
|
||||||
$root.buttons.clear.configure("text"=>j("クリアー Ctrl+C"))
|
$root.buttons.clear.configure("text"=> "クリアー Ctrl+C")
|
||||||
$root.bind("Control-c",proc{clearAction})
|
$root.bind("Control-c",proc{clearAction})
|
||||||
|
|
||||||
$root.buttons.add.configure("text"=>j("追加 Ctrl+A"))
|
$root.buttons.add.configure("text"=> "追加 Ctrl+A")
|
||||||
$root.bind("Control-a",proc{addAction})
|
$root.bind("Control-a",proc{addAction})
|
||||||
|
|
||||||
$root.buttons.search.configure("text"=>j("検索 Ctrl+S"))
|
$root.buttons.search.configure("text"=> "検索 Ctrl+S")
|
||||||
$root.bind("Control-s",proc{addAction; fillCard})
|
$root.bind("Control-s",proc{addAction; fillCard})
|
||||||
|
|
||||||
$root.buttons.delete.configure("text"=>j("消去 Ctrl+D"))
|
$root.buttons.delete.configure("text"=> "消去 Ctrl+D")
|
||||||
$root.bind("Control-d",proc{deleteAction})
|
$root.bind("Control-d",proc{deleteAction})
|
||||||
|
|
||||||
$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
|
$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
|
||||||
@ -305,7 +293,7 @@ Ctrl+S:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
$helpTopics["バージョン情報"] = <<EOF
|
$helpTopics["バージョン情報"] = <<EOF
|
||||||
バージョンは 1.0 です。
|
バージョンは 1.0.1j です。
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
Tk.mainloop
|
Tk.mainloop
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# square --
|
# square --
|
||||||
# This script generates a demo application containing only
|
# This script generates a demo application containing only
|
||||||
@ -15,13 +15,20 @@ require 'tkafter'
|
|||||||
|
|
||||||
class TkSquare<TkWindow
|
class TkSquare<TkWindow
|
||||||
def create_self
|
def create_self
|
||||||
|
begin
|
||||||
tk_call 'square', path
|
tk_call 'square', path
|
||||||
|
rescue
|
||||||
|
STDERR.print "\nSorry. Your Tk interpreter does not contain " +
|
||||||
|
'a "square" demonstration widget.' +
|
||||||
|
"\n ( See documents included the Tcl/Tk source archive. )\n\n"
|
||||||
|
exit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def size(amount=nil)
|
def size(amount=nil)
|
||||||
if amount
|
if amount
|
||||||
tk_send 'size', amount
|
tk_send 'size', amount
|
||||||
else
|
else
|
||||||
number(tk_send 'size')
|
number(tk_send('size'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def position(x,y)
|
def position(x,y)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# tcolor --
|
# tcolor --
|
||||||
# このスクリプトはRGB,HSB,CYM形式をサポートする
|
# このスクリプトはRGB,HSB,CYM形式をサポートする
|
||||||
@ -30,6 +30,12 @@ $label2 = TkVariable.new("label2")
|
|||||||
$label3 = TkVariable.new("label3")
|
$label3 = TkVariable.new("label3")
|
||||||
|
|
||||||
|
|
||||||
|
# リソースデータベースの設定
|
||||||
|
if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
|
||||||
|
TkOptionDB.add('*Entry.background', 'white')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# 各イベント用のメソッド
|
# 各イベント用のメソッド
|
||||||
|
|
||||||
def rgbToHsv(red,green,blue)
|
def rgbToHsv(red,green,blue)
|
||||||
@ -132,7 +138,7 @@ def tc_scaleChanged
|
|||||||
scale2 = $root.middle.middle.scale2
|
scale2 = $root.middle.middle.scale2
|
||||||
scale3 = $root.middle.middle.scale3
|
scale3 = $root.middle.middle.scale3
|
||||||
|
|
||||||
case $colorSpace.to_i
|
case $colorSpace.value.intern
|
||||||
when :rgb
|
when :rgb
|
||||||
$red = (scale1.get * 65.535).to_i
|
$red = (scale1.get * 65.535).to_i
|
||||||
$green = (scale2.get * 65.535).to_i
|
$green = (scale2.get * 65.535).to_i
|
||||||
@ -167,7 +173,7 @@ def tc_setScales
|
|||||||
scale2 = $root.middle.middle.scale2
|
scale2 = $root.middle.middle.scale2
|
||||||
scale3 = $root.middle.middle.scale3
|
scale3 = $root.middle.middle.scale3
|
||||||
|
|
||||||
case $colorSpace.to_i
|
case $colorSpace.value.intern
|
||||||
when :rgb
|
when :rgb
|
||||||
scale1.set($red / 65.535)
|
scale1.set($red / 65.535)
|
||||||
scale2.set($green / 65.535)
|
scale2.set($green / 65.535)
|
||||||
@ -289,7 +295,7 @@ class TkColorMenuFrame<TkFrame
|
|||||||
"command" => proc{changeColorSpace(:hsb)}
|
"command" => proc{changeColorSpace(:hsb)}
|
||||||
add "separator"
|
add "separator"
|
||||||
add "radio",
|
add "radio",
|
||||||
"label" => "Qutomatic updates",
|
"label" => "Automatic updates",
|
||||||
"variable" => $autoUpdate,
|
"variable" => $autoUpdate,
|
||||||
"value" => "1",
|
"value" => "1",
|
||||||
"underline" => "0"
|
"underline" => "0"
|
||||||
@ -367,7 +373,7 @@ class TkColorMiddleLeftFrame<TkFrame
|
|||||||
"relief"=>"sunken",
|
"relief"=>"sunken",
|
||||||
"borderwidth"=>"2",
|
"borderwidth"=>"2",
|
||||||
"exportselection"=>"false")
|
"exportselection"=>"false")
|
||||||
@scroll.command(proc{|*args| @names.yview *args})
|
@scroll.command(proc{|*args| @names.yview(*args)})
|
||||||
@names.bind("Double-1",proc{
|
@names.bind("Double-1",proc{
|
||||||
tc_loadNamedColor(@names.get(@names.curselection))})
|
tc_loadNamedColor(@names.get(@names.curselection))})
|
||||||
@names.pack("side"=>"left")
|
@names.pack("side"=>"left")
|
||||||
@ -490,8 +496,8 @@ end
|
|||||||
class TkColor<TkRoot
|
class TkColor<TkRoot
|
||||||
attr_reader :menu, :bottom, :middle
|
attr_reader :menu, :bottom, :middle
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@menu = TkColorMenuFrame.new(self)
|
@menu = TkColorMenuFrame.new(self)
|
||||||
@menu.pack("side"=>"top", "fill"=>"x")
|
@menu.pack("side"=>"top", "fill"=>"x")
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# timer --
|
# timer --
|
||||||
# This script generates a counter with start,stop and reset buttons.
|
# This script generates a counter with start,stop and reset buttons.
|
||||||
@ -80,12 +80,28 @@ end
|
|||||||
class ButtonFrame < TkFrame
|
class ButtonFrame < TkFrame
|
||||||
def initialize(parent=nil,keys=nil)
|
def initialize(parent=nil,keys=nil)
|
||||||
super(parent,keys)
|
super(parent,keys)
|
||||||
|
=begin
|
||||||
@stop = TkButton.new(self,
|
@stop = TkButton.new(self,
|
||||||
'text'=>'Stop',
|
'text'=>'Stop',
|
||||||
'command'=>proc{timer_stop})
|
'command'=>proc{timer_stop})
|
||||||
@start = TkButton.new(self,
|
@start = TkButton.new(self,
|
||||||
'text'=>'Start',
|
'text'=>'Start',
|
||||||
'command'=>proc{timer_start})
|
'command'=>proc{timer_start})
|
||||||
|
=end
|
||||||
|
@stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
|
||||||
|
@start = TkButton.new(self, :text=>'Start', :state=>:normal)
|
||||||
|
|
||||||
|
@stop.command proc{
|
||||||
|
timer_stop
|
||||||
|
@start.state(:normal)
|
||||||
|
@stop.state(:disabled)
|
||||||
|
}
|
||||||
|
@start.command proc{
|
||||||
|
timer_start
|
||||||
|
@stop.state(:normal)
|
||||||
|
@start.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
@reset = TkButton.new(self,
|
@reset = TkButton.new(self,
|
||||||
'text'=>'Reset',
|
'text'=>'Reset',
|
||||||
'command'=>proc{timer_reset})
|
'command'=>proc{timer_reset})
|
||||||
@ -99,8 +115,8 @@ end
|
|||||||
class Timer < TkRoot
|
class Timer < TkRoot
|
||||||
attr_reader :countframe
|
attr_reader :countframe
|
||||||
|
|
||||||
def initialize
|
def initialize(*args)
|
||||||
super
|
super(*args)
|
||||||
@countframe = CountFrame.new(self)
|
@countframe = CountFrame.new(self)
|
||||||
@buttonframe = ButtonFrame.new(self)
|
@buttonframe = ButtonFrame.new(self)
|
||||||
for f in [@buttonframe,@countframe]
|
for f in [@buttonframe,@countframe]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# tk 関係ライブラリの読み込み
|
# tk 関係ライブラリの読み込み
|
||||||
require 'tk'
|
require 'tk'
|
||||||
|
@ -32,6 +32,7 @@ cmd = Proc.new{|txt|
|
|||||||
|
|
||||||
timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
|
timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
|
||||||
|
|
||||||
|
=begin
|
||||||
TkButton.new(:text=>'Start') {
|
TkButton.new(:text=>'Start') {
|
||||||
command proc{ timer.continue unless timer.running? }
|
command proc{ timer.continue unless timer.running? }
|
||||||
pack(:side=>:left, :fill=>:both, :expand=>true)
|
pack(:side=>:left, :fill=>:both, :expand=>true)
|
||||||
@ -44,6 +45,30 @@ cmd = Proc.new{|txt|
|
|||||||
command proc{ timer.stop if timer.running? }
|
command proc{ timer.stop if timer.running? }
|
||||||
pack('side'=>'right','fill'=>'both','expand'=>'yes')
|
pack('side'=>'right','fill'=>'both','expand'=>'yes')
|
||||||
}
|
}
|
||||||
|
=end
|
||||||
|
b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
|
||||||
|
pack(:side=>:left, :fill=>:both, :expand=>true)
|
||||||
|
}
|
||||||
|
b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
|
||||||
|
pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
|
||||||
|
}
|
||||||
|
|
||||||
|
b_start.command {
|
||||||
|
timer.continue
|
||||||
|
b_stop.state(:normal)
|
||||||
|
b_start.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
b_stop.command {
|
||||||
|
timer.stop
|
||||||
|
b_start.state(:normal)
|
||||||
|
b_stop.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
TkButton.new(:text=>'Reset', :state=>:normal) {
|
||||||
|
command { timer.reset }
|
||||||
|
pack('side'=>'right', 'fill'=>'both', 'expand'=>'yes')
|
||||||
|
}
|
||||||
|
|
||||||
ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
|
ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
|
||||||
Tk.root.bind(ev_quit, proc{Tk.exit}).focus
|
Tk.root.bind(ev_quit, proc{Tk.exit}).focus
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
if ARGV[0] != '-d'
|
if ARGV[0] != '-d'
|
||||||
unless $DEBUG
|
unless $DEBUG
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# This script generates a directory browser, which lists the working
|
# This script generates a directory browser, which lists the working
|
||||||
# directory and allows you to open files or subdirectories by
|
# directory and allows you to open files or subdirectories by
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
require "tk"
|
require "tk"
|
||||||
|
|
||||||
root = TkFrame.new
|
root = TkFrame.new
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require "parsedate"
|
require "parsedate"
|
||||||
require "base64"
|
require "base64"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
# This script generates a counter with start and stop buttons.
|
# This script generates a counter with start and stop buttons.
|
||||||
|
|
||||||
require "tk"
|
require "tk"
|
||||||
|
59
ext/tk/sample/tktimer3.rb
Normal file
59
ext/tk/sample/tktimer3.rb
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
|
||||||
|
|
||||||
|
require "tk"
|
||||||
|
|
||||||
|
# new notation :
|
||||||
|
# * symbols are acceptable as keys or values of the option hash
|
||||||
|
# * the parent widget can be given by :parent key on the option hash
|
||||||
|
root = TkRoot.new(:title=>'timer sample')
|
||||||
|
label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
|
||||||
|
.pack(:side=>:bottom, :fill=>:both)
|
||||||
|
|
||||||
|
# define the procedure repeated by the TkTimer object
|
||||||
|
tick = proc{|aobj| #<== TkTimer object
|
||||||
|
cnt = aobj.return_value + 5 # return_value keeps a result of the last proc
|
||||||
|
label.text format("%d.%02d", *(cnt.divmod(100)))
|
||||||
|
cnt #==> return value is kept by TkTimer object
|
||||||
|
# (so, can be send to the next repeat-proc)
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
|
||||||
|
# ==> repeat-interval : (about) 50 ms,
|
||||||
|
# repeat : infinite (-1) times,
|
||||||
|
# repeat-procedure : tick (only one, in this case)
|
||||||
|
#
|
||||||
|
# ==> wait-before-call-init-proc : 0 ms,
|
||||||
|
# init_proc : proc{ label.text('0.00'); 0 }
|
||||||
|
#
|
||||||
|
# (0ms)-> init_proc ->(50ms)-> tick ->(50ms)-> tick ->....
|
||||||
|
|
||||||
|
b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
|
||||||
|
pack(:side=>:left, :fill=>:both, :expand=>true)
|
||||||
|
}
|
||||||
|
|
||||||
|
b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
|
||||||
|
pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
|
||||||
|
}
|
||||||
|
|
||||||
|
b_start.command {
|
||||||
|
timer.continue
|
||||||
|
b_stop.state(:normal)
|
||||||
|
b_start.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
b_stop.command {
|
||||||
|
timer.stop
|
||||||
|
b_start.state(:normal)
|
||||||
|
b_stop.state(:disabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
TkButton.new(:text=>'Reset', :state=>:normal) {
|
||||||
|
command { timer.reset }
|
||||||
|
pack(:side=>:right, :fill=>:both, :expand=>:yes)
|
||||||
|
}
|
||||||
|
|
||||||
|
ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
|
||||||
|
Tk.root.bind(ev_quit, proc{Tk.exit}).focus
|
||||||
|
|
||||||
|
Tk.mainloop
|
Loading…
x
Reference in New Issue
Block a user