Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main > by-pkgid > e2a5fef11a7f55d2dc803b8b7498c8e5 > files > 677

ruby-tcltk-1.8.5-31.el5_9.x86_64.rpm

#!/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