summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
blob: 6c6bfbca3f9c1378e0133fff4d4e84f3166abe54 (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
#!/usr/bin/env ruby
require 'tk'
require 'tkextlib/iwidgets'

mainloop = Thread.new{Tk.mainloop}

#
# Standard question message dialog used for confirmation.
#
md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog', 
                                     :text=>'Are you sure ? ', 
                                     :bitmap=>'questhead', :modality=>:global)

md.buttonconfigure('OK', :text=>'Yes')
md.buttonconfigure('Cancel', :text=>'No')

if TkComm.bool(md.activate)
  md.text('Are you really sure ? ')
  if TkComm.bool(md.activate)
    puts 'Yes'
  else
    puts 'No'
  end
else
  puts 'No'
end

md.destroy

#
# Copyright notice with automatic deactivation.
#
bmp = '@' + File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/text.xbm')

cr = Tk::Iwidgets::Messagedialog.new(:title=>'Copyright', 
                                     :bitmap=>bmp, :imagepos=>:n, 
                                     :text=>"Copyright 200x XXX Corporation\nAll rights reserved")

cr.hide('Cancel')

cr.activate
Tk.after(7000, proc{cr.deactivate; Tk.root.destroy})

mainloop.join