]> git.zerfleddert.de Git - micropolis/blame - src/tk/library/demos/dialog
add .gitignore to ignore build-products
[micropolis] / src / tk / library / demos / dialog
CommitLineData
6a5fa4e0
MG
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
11frame .top -relief raised -border 1
12frame .bot -relief raised -border 1
13pack 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
18message .top.msg -text "File main.c hasn't been saved to disk since \
19it was last modified. What should I do?" -justify center \
20-font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200
21pack 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
27frame .bot.left -relief sunken -border 1
28pack append .bot .bot.left {left expand padx 20 pady 20}
29button .bot.left.button -text "Save File" -command "quit save"
30pack append .bot.left .bot.left.button {expand padx 12 pady 12}
31button .bot.middle -text "Quit Anyway" -command "quit quit"
32pack append .bot .bot.middle {left expand padx 20}
33button .bot.right -text "Return To Editor" -command "quit return"
34pack 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
40proc quit button {
41 puts stdout "You pressed the \"$button\" button; bye-bye!"
42 destroy .
43}
44
45bind .top <Enter> {.bot.left.button activate}
46bind .top.msg <Enter> {.bot.left.button activate}
47bind .bot <Enter> {.bot.left.button activate}
48bind .top <Leave> {.bot.left.button deactivate}
49bind .top.msg <Leave> {.bot.left.button deactivate}
50bind .bot <Leave> {.bot.left.button deactivate}
51bind . <1> {.bot.left.button config -relief sunken}
52bind . <ButtonRelease-1> {quit save}
53focus .
54bind . <Return> {quit save}
Impressum, Datenschutz