summaryrefslogtreecommitdiffstats
path: root/ext/tcltklib/demo/lines2.rb
blob: 9f21ae6377989944cdfb2dbe5029780998e5e84f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/local/bin/ruby

require "tcltk"

def drawlines()
  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
#      $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
    end
  end

  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
      $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
    end
  end

  print Time.now, "\n"
#  $ip.commands()["destroy"].e($root)
end

$ip = TclTkInterpreter.new()
$root = $ip.rootwidget()
$a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500")
$c = TclTkCallback.new($ip, proc{drawlines()})
$b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c)

$ip.commands()["pack"].e($a, $b, "-side left")

TclTk.mainloop

# eof