ext/tcltklib/demo/lines2.rb


DEFINITIONS

This source file includes following functions.


   1  #! /usr/local/bin/ruby
   2  
   3  require "tcltk"
   4  
   5  def drawlines()
   6    print Time.now, "\n"
   7  
   8    for j in 0 .. 99
   9      print "*"
  10      $stdout.flush
  11      if (j & 1) != 0
  12        col = "blue"
  13      else
  14        col = "red"
  15      end
  16      for i in 0 .. 99
  17  #      $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
  18      end
  19    end
  20  
  21    print Time.now, "\n"
  22  
  23    for j in 0 .. 99
  24      print "*"
  25      $stdout.flush
  26      if (j & 1) != 0
  27        col = "blue"
  28      else
  29        col = "red"
  30      end
  31      for i in 0 .. 99
  32        $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
  33      end
  34    end
  35  
  36    print Time.now, "\n"
  37  #  $ip.commands()["destroy"].e($root)
  38  end
  39  
  40  $ip = TclTkInterpreter.new()
  41  $root = $ip.rootwidget()
  42  $a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500")
  43  $c = TclTkCallback.new($ip, proc{drawlines()})
  44  $b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c)
  45  
  46  $ip.commands()["pack"].e($a, $b, "-side left")
  47  
  48  TclTk.mainloop
  49  
  50  # eof