~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/sample/demos-en/image1.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

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