DEFINITIONS
This source file includes following functions.
1 #! /usr/local/bin/ruby
2 require "tk"
3
4 root = TkFrame.new
5 top = TkFrame.new(root) {
6 relief 'raised'
7 border 1
8 }
9 msg = TkMessage.new(top) {
10 text "File main.c hasn't been saved to disk since \
11 it was last modified. What should I do?"
12 justify 'center'
13 aspect 200
14 font '-Adobe-helvetica-medium-r-normal--*-240*'
15 pack('padx'=>5, 'pady'=>5, 'expand'=>'yes')
16 }
17 top.pack('fill'=>'both')
18 root.pack
19
20 bot = TkFrame.new(root) {
21 relief 'raised'
22 border 1
23 }
24
25 TkFrame.new(bot) { |left|
26 relief 'sunken'
27 border 1
28 pack('side'=>'left', 'expand'=>'yes', 'padx'=>10, 'pady'=> 10)
29 TkButton.new(left) {
30 text "Save File"
31 command "quit 'save'"
32 pack('expand'=>'yes','padx'=>6,'pady'=> 6)
33 top.bind "Enter", proc{state 'active'}
34 msg.bind "Enter", proc{state 'active'}
35 bot.bind "Enter", proc{state 'active'}
36 top.bind "Leave", proc{state 'normal'}
37 msg.bind "Leave", proc{state 'normal'}
38 bot.bind "Leave", proc{state 'normal'}
39 Tk.root.bind "ButtonRelease-1", proc{quit 'save'}
40 Tk.root.bind "Return", proc{quit 'save'}
41 }
42 }
43 TkButton.new(bot) {
44 text "Quit Anyway"
45 command "quit 'quit'"
46 pack('side'=>'left', 'expand'=>'yes', 'padx'=>10)
47 }
48 TkButton.new(bot) {
49 text "Return To Editor"
50 command "quit 'return'"
51 pack('side'=>'left', 'expand'=>'yes', 'padx'=>10)
52 }
53 bot.pack
54 root.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
55
56 def quit(button)
57 print "aaa\n"
58 print "You pressed the \"#{button}\" button; bye-bye!\n"
59 exit
60 end
61
62 Tk.mainloop