1## image1.rb
2#
3# This demonstration script displays two image widgets.
4#
5# two image widgets demo (called by 'widget')
6#
7
8# toplevel widget
9if defined?($image1_demo) && $image1_demo
10  $image1_demo.destroy
11  $image1_demo = nil
12end
13
14# demo toplevel widget
15$image1_demo = TkToplevel.new {|w|
16  title('Image Demonstration #1')
17  iconname("Image1")
18  positionWindow(w)
19}
20
21base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true)
22
23# label
24msg = TkLabel.new(base_frame) {
25  font $font
26  wraplength '4i'
27  justify 'left'
28  text "This demonstration displays two images, each in a separate label widget."
29}
30msg.pack('side'=>'top')
31
32# frame
33TkFrame.new(base_frame) {|frame|
34  TkButton.new(frame) {
35    text 'Dismiss'
36    command proc{
37      tmppath = $image1_demo
38      $image1_demo = nil
39      tmppath.destroy
40    }
41  }.pack('side'=>'left', 'expand'=>'yes')
42
43  TkButton.new(frame) {
44    text 'Show Code'
45    command proc{showCode 'image1'}
46  }.pack('side'=>'left', 'expand'=>'yes')
47
48}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
49
50# image
51image1a = \
52TkPhotoImage.new('file'=>[$demo_dir,'..',
53                          'images','earth.gif'].join(File::Separator))
54image1b = \
55TkPhotoImage.new('file'=>[$demo_dir,'..',
56                          'images','earthris.gif'].join(File::Separator))
57
58# label
59#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
60#  TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
61#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
62[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
63  Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
64].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
65
66