1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
|
#############################################################################
#
# $Id: gis_set.tcl,v 1.11.2.4 2005/10/18 15:36:02 markus Exp $
#
# MODULE: Grass Tcl/Tk Initialization
# AUTHOR(S): Original author unknown - probably CERL
# Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
# Markus Neteler - Germany - neteler@geog.uni-hannover.de
# PURPOSE: The source file for this shell script is in
# src/tcltkgrass/main/gis_set.tcl. It allows the user to choose
# the database, location, and mapset to use with grass by
# presenting a user interface window.
# COPYRIGHT: (C) 2000 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################
source $env(GISBASE)/etc/gtcltk/gmsg.tcl
#############################################################################
#
# part regarding to the creation of a new location using proj and
# the EPSG codes (routines epsgLocCom and infoEpsg)
#
#############################################################################
source $env(GISBASE)/etc/epsg_option.tcl
#fetch GRASS Version number:
set fp [open $env(GISBASE)/etc/VERSIONNUMBER r]
set GRASSVERSION [read -nonewline $fp]
close $fp
#HTML help
source $env(GISBASE)/etc/help.tcl
proc make_help_window { w } {
frame $w
frame $w.f2
frame $w.f1
pack $w -side top -expand 1 -fill both
pack $w.f1 -side top -expand 1 -fill both
pack $w.f2 -side bottom -expand 0 -fill both
}
proc searchGISRC { filename } {
global database
global location
global mapset
global oldDb oldLoc oldMap
global grassrc_list
set grassrc_list ""
set flag 0
if { [file exists $filename] } {
set ifp [open $filename "r"]
set thisline [gets $ifp]
while { [eof $ifp] == 0 } {
lappend grassrc_list "$thisline"
if { [scan $thisline "GISDBASE: %s" env_database] } {
set database $env_database
}
if { [scan $thisline "LOCATION_NAME: %s" env_location] } {
set location $env_location
}
if { [scan $thisline "MAPSET: %s" env_mapset] } {
set mapset $env_mapset
}
set thisline [gets $ifp]
}
set oldDb $database
set oldLoc $location
set oldMap $mapset
close $ifp
if { $database != "" && $location != "" && $mapset != "" } {
set flag 1
}
}
return $flag
}
proc putGRASSRC { filename } {
global database
global location
global mapset
global grassrc_list
set ofp [open $filename "w"]
foreach i $grassrc_list {
if { [regexp {^GISDBASE:} $i] } \
{
puts $ofp "GISDBASE: $database"
} \
elseif { [regexp {^LOCATION_NAME:} $i] } \
{
puts $ofp "LOCATION_NAME: $location"
} \
elseif { [regexp {^MAPSET:} $i] } \
{
puts $ofp "MAPSET: $mapset"
} \
else \
{
puts $ofp $i
}
}
close $ofp
}
proc GetDir {entWidget locList mapList} \
{
global database
toplevel .getDir
wm title .getDir "New Database Directory"
wm resizable .getDir 0 0
frame .getDir.base
pack .getDir.base -side top -fill both -expand 1
listbox .getDir.base.list -selectmode single -height 10 -width 40\
-yscrollcommand ".getDir.base.vertScroll set" \
-xscrollcommand ".getDir.horzScroll set"
pack .getDir.base.list -side left -fill x -expand 1
scrollbar .getDir.base.vertScroll -width 12 \
-command ".getDir.base.list yview"
scrollbar .getDir.horzScroll -width 12 -command ".getDir.base.list xview" \
-orient horizontal
pack .getDir.base.vertScroll -side left -fill y
pack .getDir.horzScroll -side top -fill x
# Create a frame for the pushbuttons
frame .getDir.sepFrame -height 4 -bd 2 -relief raised
pack .getDir.sepFrame -side top -fill x
frame .getDir.buttonFrame
pack .getDir.buttonFrame -side bottom -fill x
# Create the pushbuttons
button .getDir.buttonFrame.add -text "OK" \
-command \
"SetDatabase .getDir.base.list .getDir $entWidget $locList $mapList"
button .getDir.buttonFrame.quit -text "Cancel" -command {destroy .getDir}
pack .getDir.buttonFrame.add .getDir.buttonFrame.quit -side left \
-expand 1 -padx 10 -pady 5
# Bind the double click to change directories
bind .getDir.base.list <Double-Button-1> {ChangeDir %W %y}
GetListItems .getDir.base.list [file dirname $database] \
[file tail $database]
}
proc GetListItems {widget dir default} \
{
set currDir [pwd]
cd $dir
# Insert the parent directory in the list
$widget delete 0 end
set parent $dir
append parent "/.."
$widget insert end $parent
# Set counter to 1 since parent is already in the list
set i 1
set index 0
foreach filename [lsort [glob -nocomplain *]] \
{
if {[file isdirectory $filename]} \
{
if {[string compare $default $filename] == 0} \
{
set index $i
}
set path $dir
append path "/" $filename
set filename $path
$widget insert end $filename
incr i
}
}
$widget see $index
$widget selection set $index
$widget xview moveto 1
cd $currDir
}
proc SetDatabase {widget top entryWidget locList mapList} \
{
global database
set database [$widget get [$widget curselection]]
if {[string compare [file tail $database] ".."] == 0} \
{
set database [file dirname [file dirname $database]]
}
$entryWidget xview moveto 1
cd $database
$locList delete 0 end
$mapList delete 0 end
foreach filename [lsort [glob -nocomplain *]] \
{
if {[file isdirectory $filename]} \
{
$locList insert end $filename
}
}
.frame0.frameBUTTONS.ok configure -state disabled
destroy $top
}
proc ChangeDir {widget y} \
{
set dir [$widget get [$widget nearest $y]]
if {[string compare [file tail $dir] ".."] == 0} \
{
set dir [file dirname [file dirname $dir]]
}
GetListItems $widget $dir ""
}
proc CheckLocation {} \
{
global database location
set found 0
set dir $database
append dir "/$location"
set currDir [pwd]
cd $dir
foreach filename [glob -nocomplain *] \
{
if {[string compare $filename "PERMANENT"] == 0} \
{
set found 1
}
}
if {$found == 0} \
{
set location "##ERROR##"
}
cd $currDir
}
proc gisSetWindow {} {
global GRASSVERSION
# Window manager configurations
wm geometry . +100+100
wm title . "GRASS $GRASSVERSION Data Selection"
global database
global location
global mymapset
global mapset
global oldDb oldLoc oldMap
global grassrc_list
global gisrc_name
# ---------------------------
# build .frame0
# ---------------------------
frame .frame0 \
-borderwidth {2} \
-relief {raised}
frame .frame0.intro -borderwidth 2
text .frame0.intro.msg -relief ridge -height 4 -width 50 \
-font {Helvetica -12 bold}
pack .frame0.intro -side top
pack .frame0.intro.msg -side top
.frame0.intro.msg tag configure all -justify center
.frame0.intro.msg insert end [G_msg "Welcome to GRASS GIS Version $GRASSVERSION\n\n"]
.frame0.intro.msg insert end [G_msg "Please select location and mapset\n"]
.frame0.intro.msg insert end [G_msg "or define a new location\n"]
.frame0.intro.msg tag add all 1.0 end
.frame0.intro.msg configure -state disabled
# -----------------------------------
# build .frame0.frameDB
# -----------------------------------
frame .frame0.frameDB \
-borderwidth {2}
frame .frame0.frameDB.left \
-borderwidth {2}
frame .frame0.frameDB.mid \
-borderwidth {2}
frame .frame0.frameDB.right \
-borderwidth {2}
label .frame0.frameDB.left.label \
-anchor {n} \
-text [G_msg "Database : "]
entry .frame0.frameDB.mid.entry \
-relief {sunken} \
-textvariable database \
-width 40 \
-xscrollcommand { .frame0.frameDB.mid.hscrollbar set}
scrollbar .frame0.frameDB.mid.hscrollbar \
-command { .frame0.frameDB.mid.entry xview} \
-relief {raised} \
-width 12 \
-orient {horizontal}
button .frame0.frameDB.right.button \
-text [G_msg "Browse..."] \
-command {GetDir .frame0.frameDB.mid.entry .frame0.frameLOC.listbox \
.frame0.frameMS.listbox}
pack .frame0.frameDB.left.label -side top
pack .frame0.frameDB.mid.entry -side top -fill x
pack .frame0.frameDB.mid.hscrollbar -side bottom -fill x
pack .frame0.frameDB.right.button -side left -fill x
pack .frame0.frameDB.left -side left -anchor n -fill x
pack .frame0.frameDB.mid -side left -fill x
pack .frame0.frameDB.right -side left -anchor n -fill x
# -----------------------------------
# build .frame0.frameLOC
# -----------------------------------
frame .frame0.frameLOC \
-borderwidth {2}
label .frame0.frameLOC.label \
-anchor {w} \
-text [G_msg "Location"]
listbox .frame0.frameLOC.listbox \
-relief {raised} \
-exportselection false \
-yscrollcommand {.frame0.frameLOC.vscrollbar set} \
-xscrollcommand {.frame0.frameLOC.hscrollbar set}
scrollbar .frame0.frameLOC.vscrollbar -width 12 \
-command {.frame0.frameLOC.listbox yview} \
-relief {raised}
scrollbar .frame0.frameLOC.hscrollbar -width 12 \
-command {.frame0.frameLOC.listbox xview} \
-orient {horizontal} \
-relief {raised}
pack append .frame0.frameLOC \
.frame0.frameLOC.label { top fill } \
.frame0.frameLOC.vscrollbar { right filly } \
.frame0.frameLOC.hscrollbar { bottom fillx } \
.frame0.frameLOC.listbox { left expand fill }
# -----------------------------------
# build .frame0.frameMS
# -----------------------------------
frame .frame0.frameMS \
-borderwidth {2}
label .frame0.frameMS.label \
-anchor {w} \
-text [G_msg "(Accessible) Mapsets"]
listbox .frame0.frameMS.listbox \
-relief {raised} \
-yscrollcommand {.frame0.frameMS.vscrollbar set} \
-xscrollcommand {.frame0.frameMS.hscrollbar set}
scrollbar .frame0.frameMS.vscrollbar -width 12 \
-command {.frame0.frameMS.listbox yview} \
-relief {raised}
scrollbar .frame0.frameMS.hscrollbar -width 12 \
-command {.frame0.frameMS.listbox xview} \
-orient {horizontal} \
-relief {raised}
pack append .frame0.frameMS \
.frame0.frameMS.label { top fill } \
.frame0.frameMS.vscrollbar { right filly } \
.frame0.frameMS.hscrollbar { bottom fillx } \
.frame0.frameMS.listbox { left expand fill }
# -----------------------------------
# build .frame0.frameNMS
# -----------------------------------
frame .frame0.frameNMS \
-borderwidth {2}
frame .frame0.frameNMS.left \
-borderwidth {2}
frame .frame0.frameNMS.mid \
-borderwidth {2}
frame .frame0.frameNMS.right \
-borderwidth {2}
label .frame0.frameNMS.left.label \
-anchor {n} \
-text [G_msg "Create new mapset : "]
entry .frame0.frameNMS.mid.entry \
-relief {sunken} \
-textvariable mymapset \
-width 15
button .frame0.frameNMS.right.button \
-text [G_msg "Create..."] \
-command {
.frame0.frameNMS.right.button configure -state disabled
if { $mymapset != "" } {
CheckLocation
cd $database
cd $location
file mkdir $mymapset
#generate default DB definition, create dbf subdirectory:
set varfp [open $mymapset/VAR "w"]
puts $varfp "DB_DRIVER: dbf"
puts $varfp "DB_DATABASE: \$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/"
close $varfp
file attributes $mymapset/VAR -permissions u+rw,go+r
file mkdir $mymapset/dbf
#copy over the WIND definition:
file copy $mymapset/../PERMANENT/WIND $mymapset
file attributes $mymapset/WIND -permissions u+rw,go+r
.frame0.frameMS.listbox insert end $mymapset
#TODO: select new MAPSET
}
}
pack append .frame0.frameNMS
pack .frame0.frameNMS.left.label -side top
pack .frame0.frameNMS.mid.entry -side top -fill x
pack .frame0.frameNMS.right.button -side left -fill x
pack .frame0.frameNMS.left -side top -anchor n
pack .frame0.frameNMS.mid -side top -expand yes
pack .frame0.frameNMS.right -side bottom -anchor n -expand yes
# ----------------------------------
# build .frame0.frameBUTTONS
# ----------------------------------
frame .frame0.frameBUTTONS \
-borderwidth {2}
button .frame0.frameBUTTONS.ok \
-text [G_msg "Enter GRASS"] \
-relief raised \
-padx 10 \
-command {
if {[file exists "$database/$location/PERMANENT/WIND"] == 0} {
DialogGen .wrnDlg "WARNING: not a mapset" warning "Warning: This is not \
a valid mapset" \
0 OK;
}
if { $mapset != "" && [file exists "$database/$location/PERMANENT/WIND"] != 0} {
CheckLocation
puts stdout "GISDBASE='$database';"
puts stdout "LOCATION_NAME='$location';"
puts stdout "MAPSET='$mapset';"
if {[string compare $location "##ERROR##"] != 0} {
putGRASSRC $gisrc_name
}
destroy .
}
}
button .frame0.frameBUTTONS.newLoc \
-text [G_msg "Create New Location"] \
-relief raised \
-padx 10 \
-command {
puts stdout "OLD_DB='$oldDb';"
puts stdout "OLD_LOC='$oldLoc';"
puts stdout "OLD_MAP='$oldMap';"
puts stdout "GISDBASE='$database';"
puts stdout "LOCATION_NAME='##NONE##';"
puts stdout "MAPSET='';"
set location ""
set mapset ""
putGRASSRC $gisrc_name
destroy .
}
button .frame0.frameBUTTONS.help \
-text [G_msg "Help"] \
-relief raised \
-padx 10 \
-command {
if { [winfo exists .help] } {
puts "Help already opened"
wm deiconify .help
raise .help
return
}
set help [toplevel .help]
help::init $env(GISBASE)/docs/html/helptext.html "" $help 500 400
wm title $help "GRASS Help"
}
button .frame0.frameBUTTONS.cancel \
-text [G_msg "Exit"] \
-relief raised \
-padx 10 \
-command {
puts stdout "exit"
destroy .
}
#############################################################################
button .frame0.frameBUTTONS.newLocEpsg \
-text [G_msg "Create Location From EPSG"] \
-relief raised \
-padx 10 \
-command {epsgLocCom}
pack append .frame0.frameBUTTONS \
.frame0.frameBUTTONS.ok { left expand } \
.frame0.frameBUTTONS.newLoc {left expand } \
.frame0.frameBUTTONS.newLocEpsg {left expand } \
.frame0.frameBUTTONS.help { left expand } \
.frame0.frameBUTTONS.cancel { right expand }
# ----------------------------------
# packed it all
# ----------------------------------
# pack widget .frame0
pack append .frame0 \
.frame0.frameDB { top expand fill } \
.frame0.frameBUTTONS { bottom expand fill } \
.frame0.frameLOC { left expand } \
.frame0.frameMS { left expand } \
.frame0.frameNMS { right expand fill }
.frame0.frameNMS.right.button configure -state disabled
pack append . \
.frame0 { top frame center expand fill }
.frame0.frameDB.mid.entry xview moveto 1
if { ! [file exists $database] } \
{
DialogGen .wrnDlg "WARNING: Invalid Database" warning "WARNING: \
Invalid database. Finding first valid directory in parent tree" \
0 OK
while { ! [file exists $database] } \
{
set database [file dirname $database]
}
}
cd $database
foreach i [exec ls -a [exec pwd]] {
if { [string compare $i "."] != 0 && \
[string compare $i ".."] != 0 && \
[file isdirectory $i] } {
.frame0.frameLOC.listbox insert end $i
}
}
set i 0
set curSelected 0
set length [.frame0.frameLOC.listbox size]
while { $i < $length } {
if { $location == [.frame0.frameLOC.listbox get $i] } {
set curSelected $i
break
}
incr i 1
}
.frame0.frameLOC.listbox select set $curSelected
cd $database
if { [file exists $location] } \
{
cd $location
foreach i [exec ls -a [exec pwd]] {
if { [string compare $i "."] != 0 && \
[string compare $i ".."] != 0 && \
[file isdirectory $i] && [file owned $i] } {
.frame0.frameMS.listbox insert end $i
}
}
set i 0
set curSelected 0
set length [.frame0.frameMS.listbox size]
while { $i < $length } {
if { $mapset == [.frame0.frameMS.listbox get $i] } {
set curSelected $i
break
}
incr i 1
}
.frame0.frameMS.listbox yview $curSelected
.frame0.frameMS.listbox select set $curSelected
}
bind .frame0.frameDB.mid.entry <Return> {
set new_path [%W get]
if { "$new_path" != "" \
&& [file exists $new_path] && [file isdirectory $new_path] } {
%W delete 0 end
%W insert 0 $new_path
cd $new_path
.frame0.frameLOC.listbox delete 0 end
foreach i [exec ls -a [exec pwd]] {
if { [string compare $i "."] != 0 && \
[string compare $i ".."] != 0 && \
[file isdirectory $i] } {
.frame0.frameLOC.listbox insert end $i
}
}
.frame0.frameMS.listbox delete 0 end
set database [exec pwd]
}
.frame0.frameBUTTONS.ok configure -state disabled
.frame0.frameNMS.right.button configure -state disabled
}
bind .frame0.frameLOC.listbox <Double-ButtonPress-1> {
%W select set [%W nearest %y]
cd $database
set location [%W get [%W nearest %y]]
cd $location
.frame0.frameMS.listbox delete 0 end
foreach i [exec ls -a [exec pwd]] {
if { [string compare $i "."] != 0 && \
[string compare $i ".."] != 0 && \
[file isdirectory $i] && [file owned $i] } {
.frame0.frameMS.listbox insert end $i
}
}
set mapset ""
.frame0.frameBUTTONS.ok configure -state disabled
}
bind .frame0.frameLOC.listbox <ButtonPress-1> {
%W select set [%W nearest %y]
cd $database
set location [%W get [%W nearest %y]]
cd $location
.frame0.frameMS.listbox delete 0 end
foreach i [exec ls -a [exec pwd]] {
if { [string compare $i "."] != 0 && \
[string compare $i ".."] != 0 && \
[file isdirectory $i] && [file owned $i] } {
.frame0.frameMS.listbox insert end $i
}
}
set mapset ""
.frame0.frameBUTTONS.ok configure -state disabled
}
bind .frame0.frameMS.listbox <Double-ButtonPress-1> {
%W select set [%W nearest %y]
set mapset [%W get [%W nearest %y]]
.frame0.frameBUTTONS.ok configure -state normal
}
bind .frame0.frameMS.listbox <ButtonPress-1> {
%W select set [%W nearest %y]
set mapset [%W get [%W nearest %y]]
.frame0.frameBUTTONS.ok configure -state normal
}
bind .frame0.frameNMS.mid.entry <KeyRelease> {
.frame0.frameNMS.right.button configure -state active
}
grab .
tkwait window .
}
#############################################################################
#
# proc DialogGen {widget title bitmap text default buttons}
#
# PURPOSE: This function simply pops up a dialog box with a given message.
# Note that it is similar to tk_dialog but has a slightly
# different look to the dialog.
# Example call:
# set val [DialogGen .warnDlg "WARNING: List Changed" \
# warning "WARNING: You have changed the current list.\
# Do you want to discard the changes and open a new \
# file?" 0 OK Cancel]
# if { $val == 0 } { puts stderr "OK button pressed" }
# if { $val == 1 } { puts stderr "Cancel button pressed" }
# INPUT VARS: widget => name of the dialog box starting with . eg .errDlg
# title => title to display in window border
# bitmap => bitmap icon to display - must be one of
# error gray12
# gray50 hourglass
# info questhead
# question warning
# text => text of the message to be displayed
# default => index of default button (0, 1, 2...) must be less
# than number of buttons
# buttons => text to be used for each button eg OK Cancel
# RETURN VAL: index of button that was clicked - can be ignored if only one
# button is defined
#
#############################################################################
# Procedure to generate the dialog box
proc DialogGen {widget title bitmap text default buttons} \
{
global buttonNum
# Create a popup window to warn the user
toplevel $widget
wm title $widget $title
wm resizable $widget 0 0
wm protocol $widget WM_DELETE_WINDOW "CancelDialog $widget"
# Create a label for the bitmap and a message for the text
frame $widget.dlgFrame
pack $widget.dlgFrame -side top -fill both
label $widget.dlgFrame.icon -bitmap $bitmap
message $widget.dlgFrame.text -text $text -width 10c
pack $widget.dlgFrame.icon $widget.dlgFrame.text -side left -fill x \
-padx 10
# Create a frame for the pushbuttons
frame $widget.sepFrame -height 4 -bd 2 -relief raised
frame $widget.buttonFrame
pack $widget.buttonFrame $widget.sepFrame -side bottom -fill x
# Create the pushbuttons
set i 0
foreach buttonLabel $buttons \
{
button $widget.buttonFrame.$i -text $buttonLabel \
-command "set buttonNum $i"
pack $widget.buttonFrame.$i -side left -expand 1 -padx 10 -pady 5
incr i
}
# Position the top left corner of the window over the root window
wm withdraw $widget
update idletasks
wm geometry $widget +[expr [winfo rootx .] + ([winfo width .] \
-[winfo width $widget]) / 2]+[expr [winfo rooty .] + ([winfo \
height .] - [winfo height $widget]) / 2]
wm deiconify $widget
# Grab the pointer to make sure this window is closed before continuing
grab set $widget
if {$default >= 0} \
{
focus $widget.buttonFrame.$default
}
tkwait variable buttonNum
# Destroy the popup window
destroy $widget
# Return the number of the button that was pushed
return "$buttonNum"
}
# Procedure to cancel the dialog
proc CancelDialog {widget} \
{
global buttonNum
# Set the wait variable so that the dialog box can cancel properly
set buttonNum 999
}
global database
global location
global mapset
global grassrc_list
global gisrc_name
set ver [info tclversion]
if { [string compare $ver "8.0"] < 0} \
{
puts stderr "Sorry your version of the Tcl/Tk libraries is $ver and is too"
puts stderr "old for GRASS which requires a Tcl/Tk library version of 8.0 or later."
puts stderr "Reverting default settings back to GRASS text mode interface."
exit 1
}
set database ""
set location ""
set mapset ""
set gisrc_name ""
if { [info exists env(GISRC)] } {
set gisrc_name $env(GISRC)
}
if { [searchGISRC $gisrc_name] } {
gisSetWindow
}
|