diff options
Diffstat (limited to 'ext/tk/sample/demos-jp')
-rw-r--r-- | ext/tk/sample/demos-jp/browse1 | 2 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/browse2 | 2 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/hello | 2 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/ixset | 4 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/rmt | 25 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/rolodex | 10 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/rolodex-j | 78 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/square | 13 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/tcolor | 20 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/timer | 22 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/widget | 2 |
11 files changed, 100 insertions, 80 deletions
diff --git a/ext/tk/sample/demos-jp/browse1 b/ext/tk/sample/demos-jp/browse1 index 6bb8fb35ca..03e251035a 100644 --- a/ext/tk/sample/demos-jp/browse1 +++ b/ext/tk/sample/demos-jp/browse1 @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # browse -- # This script generates a directory browser, which lists the working diff --git a/ext/tk/sample/demos-jp/browse2 b/ext/tk/sample/demos-jp/browse2 index 755afa682c..304a5f547e 100644 --- a/ext/tk/sample/demos-jp/browse2 +++ b/ext/tk/sample/demos-jp/browse2 @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # browse -- # This script generates a directory browser, which lists the working diff --git a/ext/tk/sample/demos-jp/hello b/ext/tk/sample/demos-jp/hello index 94e450899c..859ebd950e 100644 --- a/ext/tk/sample/demos-jp/hello +++ b/ext/tk/sample/demos-jp/hello @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby require 'tk' TkButton.new(nil, diff --git a/ext/tk/sample/demos-jp/ixset b/ext/tk/sample/demos-jp/ixset index 5391012cfb..46c2378073 100644 --- a/ext/tk/sample/demos-jp/ixset +++ b/ext/tk/sample/demos-jp/ixset @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # ixset -- # A nice interface to "xset" to change X server settings @@ -166,7 +166,7 @@ class Xsettings l = TkLabel.new(bell, 'text'=>'Bell Settings') @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200, 'tickinterval'=>20, 'orient'=>'horizontal', - 'label'=>"Volume (%)") + 'label'=>"Volume (%)") f = TkFrame.new(bell) @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6) diff --git a/ext/tk/sample/demos-jp/rmt b/ext/tk/sample/demos-jp/rmt index 64583d714e..73f631180a 100644 --- a/ext/tk/sample/demos-jp/rmt +++ b/ext/tk/sample/demos-jp/rmt @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # rmt -- # This script implements a simple remote-control mechanism for @@ -53,10 +53,8 @@ class Rmt # Create text window and scrollbar. - @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {|t| - TkScrollbar.new(root, 'command'=>proc{|*args| t.yview *args}) { - pack('side'=>'right', 'fill'=>'both') - } + @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) { + yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')}) pack('side'=>'left') } @@ -247,13 +245,18 @@ class Rmt rescue end TkWinfo.interps.sort.each{|ip| - if Tk.appsend(ip, false, 'info commands ruby') == "" - mode = 'Tcl' - else - mode = 'Ruby' + begin + if Tk.appsend(ip, false, 'info commands ruby') == "" + mode = 'Tcl' + else + mode = 'Ruby' + end + menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), + '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("%s (#{mode}/Tk)", ip), - 'command'=>proc{win.newApp ip, mode}) } menu.add('command', 'label'=>format("local (Ruby/Tk)"), 'command'=>proc{win.newApp 'local', 'Ruby'}) diff --git a/ext/tk/sample/demos-jp/rolodex b/ext/tk/sample/demos-jp/rolodex index 9ed1f6d7d1..9f87ae2829 100644 --- a/ext/tk/sample/demos-jp/rolodex +++ b/ext/tk/sample/demos-jp/rolodex @@ -1,10 +1,10 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # rolodex -- # This script is a part of Tom LaStrange's rolodex # # Copyright (C) 1998 by Takaaki Tateishi <[email protected]> -# Time-stamp: "98/07/20 12:00:02 ttate" +# Time-stamp: "03/08/02 12:45:21 nagai" # require "tk" @@ -176,8 +176,8 @@ end class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -314,7 +314,7 @@ Ctrl+S: Search (dummy operation) EOF $helpTopics["version"] = <<EOF -This is version 1.0. +This is version 1.0.1. EOF Tk.mainloop diff --git a/ext/tk/sample/demos-jp/rolodex-j b/ext/tk/sample/demos-jp/rolodex-j index 170f7bb96b..1c482aafb2 100644 --- a/ext/tk/sample/demos-jp/rolodex-j +++ b/ext/tk/sample/demos-jp/rolodex-j @@ -1,21 +1,14 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # rolodex -- # ���Υ�����ץȤ� Tom LaStrange �� rolodex �ΰ����Ǥ��� # # Copyright (C) 1998 by Takaaki Tateishi <[email protected]> -# Time-stamp: "98/07/20 12:00:36 ttate" +# Time-stamp: "03/08/02 14:01:54 nagai" # require "tk" - -# UTF8�ؤ��Ѵ���Ԥʤ��� - -$encoding = "euc-jp" -def j(str) - Tk.toUTF8(str,$encoding) -end - +Tk.encoding = "euc-jp" def show_help(topic,x=0,y=0) if( topic.is_a?(TkWindow) ) @@ -33,17 +26,17 @@ def show_help(topic,x=0,y=0) msg = "���Υȥԥå��ˤĤ��ƤΥإ�פϤޤ����ѤǤ��ޤ���" end TkDialog.new("title"=>"Rolodex Help", - "message"=>j("��#{topic}��\n\n#{msg}"), + "message"=>"��#{topic}��\n\n#{msg}", "default_button"=>0, "buttons"=>["OK"]) end def fillCard clearAction - $root.frame.entry[1].insert(0,j("Ω�� ����")) - $root.frame.entry[2].insert(0,j("923-1292 ���")) - $root.frame.entry[3].insert(0,j("ä��Į ���� 1-1")) - $root.frame.entry[4].insert(0,j("��Φ��ü�ʳص�����ر����")) + $root.frame.entry[1].insert(0, "Ω�� ����") + $root.frame.entry[2].insert(0, "923-1292 ���") + $root.frame.entry[3].insert(0, "ä��Į ���� 1-1") + $root.frame.entry[4].insert(0, "��Φ��ü�ʳص�����ر����") $root.frame.entry[5].insert(0,"private") $root.frame.entry[6].insert(0,"***-***-****") $root.frame.entry[7].insert(0,"***-***-****") @@ -53,7 +46,7 @@ def addAction for i in 1..7 STDERR.print format("%-12s %s\n", RolodexFrame::LABEL[i], - Tk.fromUTF8($root.frame.entry[i].value,$encoding)) + $root.frame.entry[i].value) end end @@ -65,7 +58,7 @@ end def fileAction TkDialog.new("title"=>"File Selection", - "message"=>j("����ϥե�������������������Υ��ߡ��Ǥ���\n"), + "message"=>"����ϥե�������������������Υ��ߡ��Ǥ���\n", "default_button"=>0, "buttons"=>["OK"]) STDERR.print "dummy file name\n" @@ -73,9 +66,9 @@ end def deleteAction result = TkDialog.new("title"=>"Confirm Action", - "message"=>j("��������Ǥ�����"), + "message"=>"��������Ǥ�����", "default_button"=>0, - "buttons"=>[j("�����")]) + "buttons"=>["�����"]) if( result.value == 0 ) clearAction end @@ -90,7 +83,6 @@ class RolodexFrame < TkFrame def initialize(parent=nil,keys=nil) super(parent,keys) self["relief"] = "flat" - @i = [] @label = [] @entry = [] @@ -100,7 +92,7 @@ class RolodexFrame < TkFrame "pady"=>2, "anchor"=>"e") @label[i] = TkLabel.new(@i[i], - "text"=>j(LABEL[i]), + "text"=>LABEL[i], "anchor"=>"e") @entry[i] = TkEntry.new(@i[i], "width"=>30, @@ -116,14 +108,10 @@ class RolodexButtons < TkFrame def initialize(parent,keys=nil) super(parent,keys) - @clear = TkButton.new(self, - "text" => j("���ꥢ��")) - @add = TkButton.new(self, - "text" => j("�ɲ�")) - @search = TkButton.new(self, - "text" => j("����")) - @delete = TkButton.new(self, - "text" => j("�õ�")) + @clear = TkButton.new(self,"text" => "���ꥢ��") + @add = TkButton.new(self, "text" => "�ɲ�") + @search = TkButton.new(self, "text" => "����") + @delete = TkButton.new(self, "text" => "�õ�") for w in [@clear,@add,@search,@delete] w.pack("side"=>"left", "padx"=>2) end @@ -139,42 +127,42 @@ class RolodexMenuFrame < TkFrame "borderwidth"=>1) @file = TkMenubutton.new(self, - "text"=>j("�ե�����"), + "text"=> "�ե�����", "underline"=>0) @file_menu = TkMenu.new(@file) @file_menu.add("command", - "label" => j("�ɤ߹��� ..."), + "label" => "�ɤ߹��� ...", "command" => proc{fileAction}, "underline" => 0) @file_menu.add("command", - "label" => j("��λ"), + "label" => "��λ", "command" => proc{$root.destroy}, "underline" => 0) @file.menu(@file_menu) @file.pack("side"=>"left") @help = TkMenubutton.new(self, - "text"=>j("�إ��"), + "text"=> "�إ��", "underline"=>0) @help_menu = TkMenu.new(@help) @help_menu.add("command", - "label"=>j("����ƥ����ȤˤĤ���"), + "label"=> "����ƥ����ȤˤĤ���", "command"=>proc{show_help("����ƥ�����")}, "underline"=>3) @help_menu.add("command", - "label"=>j("�إ�פˤĤ���"), + "label"=> "�إ�פˤĤ���", "command"=>proc{show_help("�إ��")}, "underline"=>3) @help_menu.add("command", - "label"=>j("������ɥ��ˤĤ���"), + "label"=> "������ɥ��ˤĤ���", "command"=>proc{show_help("������ɥ�")}, "underline"=>3) @help_menu.add("command", - "label"=>j("�������ˤĤ���"), + "label"=> "�������ˤĤ���", "command"=>proc{show_help("�������")}, "underline"=>3) @help_menu.add("command", - "label"=>j("�С���������"), + "label"=> "�С���������", "command"=>proc{show_help("�С���������")}, "underline"=>3) @help.menu(@help_menu) @@ -185,8 +173,8 @@ end class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -209,16 +197,16 @@ $root.buttons.add.configure("command"=>proc{addAction}) $root.buttons.clear.configure("command"=>proc{clearAction}) $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.buttons.add.configure("text"=>j("�ɲ� Ctrl+A")) +$root.buttons.add.configure("text"=> "�ɲ� Ctrl+A") $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.buttons.delete.configure("text"=>j("�õ� Ctrl+D")) +$root.buttons.delete.configure("text"=> "�õ� Ctrl+D") $root.bind("Control-d",proc{deleteAction}) $root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F") @@ -305,7 +293,7 @@ Ctrl+S: ���� EOF $helpTopics["�С���������"] = <<EOF -�С������� 1.0 �Ǥ��� +�С������� 1.0.1j �Ǥ��� EOF Tk.mainloop diff --git a/ext/tk/sample/demos-jp/square b/ext/tk/sample/demos-jp/square index b914b735b2..00bfde59ff 100644 --- a/ext/tk/sample/demos-jp/square +++ b/ext/tk/sample/demos-jp/square @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # square -- # This script generates a demo application containing only @@ -15,13 +15,20 @@ require 'tkafter' class TkSquare<TkWindow def create_self - tk_call 'square', path + begin + 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 def size(amount=nil) if amount tk_send 'size', amount else - number(tk_send 'size') + number(tk_send('size')) end end def position(x,y) diff --git a/ext/tk/sample/demos-jp/tcolor b/ext/tk/sample/demos-jp/tcolor index 5464aebae2..391ce4c446 100644 --- a/ext/tk/sample/demos-jp/tcolor +++ b/ext/tk/sample/demos-jp/tcolor @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # tcolor -- # ���Υ�����ץȤ�RGB,HSB,CYM�����ݡ��Ȥ��� @@ -30,6 +30,12 @@ $label2 = TkVariable.new("label2") $label3 = TkVariable.new("label3") +# ������ǡ����١��������� +if (TkVarAccess.new('tcl_platform')['platform'] == 'unix') + TkOptionDB.add('*Entry.background', 'white') +end + + # �ƥ��٥���ѤΥ�å� def rgbToHsv(red,green,blue) @@ -132,7 +138,7 @@ def tc_scaleChanged scale2 = $root.middle.middle.scale2 scale3 = $root.middle.middle.scale3 - case $colorSpace.to_i + case $colorSpace.value.intern when :rgb $red = (scale1.get * 65.535).to_i $green = (scale2.get * 65.535).to_i @@ -167,7 +173,7 @@ def tc_setScales scale2 = $root.middle.middle.scale2 scale3 = $root.middle.middle.scale3 - case $colorSpace.to_i + case $colorSpace.value.intern when :rgb scale1.set($red / 65.535) scale2.set($green / 65.535) @@ -289,7 +295,7 @@ class TkColorMenuFrame<TkFrame "command" => proc{changeColorSpace(:hsb)} add "separator" add "radio", - "label" => "Qutomatic updates", + "label" => "Automatic updates", "variable" => $autoUpdate, "value" => "1", "underline" => "0" @@ -367,7 +373,7 @@ class TkColorMiddleLeftFrame<TkFrame "relief"=>"sunken", "borderwidth"=>"2", "exportselection"=>"false") - @scroll.command(proc{|*args| @names.yview *args}) + @scroll.command(proc{|*args| @names.yview(*args)}) @names.bind("Double-1",proc{ tc_loadNamedColor(@names.get(@names.curselection))}) @names.pack("side"=>"left") @@ -490,8 +496,8 @@ end class TkColor<TkRoot attr_reader :menu, :bottom, :middle - def initialize - super + def initialize(*args) + super(*args) @menu = TkColorMenuFrame.new(self) @menu.pack("side"=>"top", "fill"=>"x") diff --git a/ext/tk/sample/demos-jp/timer b/ext/tk/sample/demos-jp/timer index 232f4ae5ca..58a41d00c0 100644 --- a/ext/tk/sample/demos-jp/timer +++ b/ext/tk/sample/demos-jp/timer @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # timer -- # This script generates a counter with start,stop and reset buttons. @@ -80,12 +80,28 @@ end class ButtonFrame < TkFrame def initialize(parent=nil,keys=nil) super(parent,keys) +=begin @stop = TkButton.new(self, 'text'=>'Stop', 'command'=>proc{timer_stop}) @start = TkButton.new(self, 'text'=>'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, 'text'=>'Reset', 'command'=>proc{timer_reset}) @@ -99,8 +115,8 @@ end class Timer < TkRoot attr_reader :countframe - def initialize - super + def initialize(*args) + super(*args) @countframe = CountFrame.new(self) @buttonframe = ButtonFrame.new(self) for f in [@buttonframe,@countframe] diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 3d4690d57a..5eb5d5f074 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # tk �ط��饤�֥����ɤ߹��� require 'tk' |