Class: TkLabelWatch

Inherits:
TkLabel
  • Object
show all
Defined in:
ext/ae-rad/lib/tk/al-tkcustom.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'ext/ae-rad/lib/tk/al-tkcustom.rb', line 27

def active?
  @active
end

#show(_format = "%I:%M:%S %p") ⇒ Object



9
10
11
12
# File 'ext/ae-rad/lib/tk/al-tkcustom.rb', line 9

def show(_format="%I:%M:%S %p")
  t = Time.now
  configure('text'=>t.strftime(_format))
end

#startObject



14
15
16
17
18
19
20
21
22
# File 'ext/ae-rad/lib/tk/al-tkcustom.rb', line 14

def start
  @active = true
  @t_clock = Thread.new {
    loop {
      show
      sleep 1
    }
  }
end

#stopObject



23
24
25
26
# File 'ext/ae-rad/lib/tk/al-tkcustom.rb', line 23

def stop
  @active = false
  @t_clock.exit if defined? @t_clock
end