]> git.zerfleddert.de Git - micropolis/blob - src/tk/library/demos/dialog
Import Micropolis from http://www.donhopkins.com/home/micropolis/
[micropolis] / src / tk / library / demos / dialog
1 #!/usr/local/bin/wish -f
2 #
3 # This script generates a sample dialog box that waits for one of three
4 # buttons to be pressed, then prints a message and exits.
5
6 # Create two frames in the main window. The top frame will hold the
7 # message and the bottom one will hold the buttons. Arrange them
8 # on above the other, with any extra vertical space split between
9 # them.
10
11 frame .top -relief raised -border 1
12 frame .bot -relief raised -border 1
13 pack append . .top {top fill expand} .bot {top fill expand}
14
15 # Create the message widget and arrange for it to be centered in the
16 # top frame.
17
18 message .top.msg -text "File main.c hasn't been saved to disk since \
19 it was last modified. What should I do?" -justify center \
20 -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200
21 pack append .top .top.msg {top padx 5 pady 5 expand}
22
23 # Create the buttons and arrange them from left to right in the bottom
24 # frame. Embed the left button in an additional sunken frame to indicate
25 # that it is the default button.
26
27 frame .bot.left -relief sunken -border 1
28 pack append .bot .bot.left {left expand padx 20 pady 20}
29 button .bot.left.button -text "Save File" -command "quit save"
30 pack append .bot.left .bot.left.button {expand padx 12 pady 12}
31 button .bot.middle -text "Quit Anyway" -command "quit quit"
32 pack append .bot .bot.middle {left expand padx 20}
33 button .bot.right -text "Return To Editor" -command "quit return"
34 pack append .bot .bot.right {left expand padx 20}
35
36 # The procedure below is invoked as the action for each of the buttons.
37 # It prints a message and exits by destroying the application's main
38 # window.
39
40 proc quit button {
41 puts stdout "You pressed the \"$button\" button; bye-bye!"
42 destroy .
43 }
44
45 bind .top <Enter> {.bot.left.button activate}
46 bind .top.msg <Enter> {.bot.left.button activate}
47 bind .bot <Enter> {.bot.left.button activate}
48 bind .top <Leave> {.bot.left.button deactivate}
49 bind .top.msg <Leave> {.bot.left.button deactivate}
50 bind .bot <Leave> {.bot.left.button deactivate}
51 bind . <1> {.bot.left.button config -relief sunken}
52 bind . <ButtonRelease-1> {quit save}
53 focus .
54 bind . <Return> {quit save}
Impressum, Datenschutz