ext/tcltklib/demo/lines1.rb


DEFINITIONS

This source file includes following functions.


   1  #! /usr/local/bin/ruby
   2  
   3  require "tk"
   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  #      TkcLine.new($a, 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        TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
  33      end
  34    end
  35  
  36    print Time.now, "\n"
  37  #  Tk.root.destroy
  38  end
  39  
  40  $a = TkCanvas.new{
  41    height(500)
  42    width(500)
  43  }
  44  
  45  $b = TkButton.new{
  46    text("draw")
  47    command(proc{drawlines()})
  48  }
  49  
  50  TkPack.configure($a, $b, {"side"=>"left"})
  51  
  52  Tk.mainloop
  53  
  54  # eof