Changeset 924 for trunk/gsascmds.tcl


Ignore:
Timestamp:
Dec 4, 2009 5:14:24 PM (11 years ago)
Author:
toby
Message:

# on 2008/07/14 01:19:02, toby did:
change Set to Continue for getstring (so that initial window has Continue)
use variable to hold disagl window name
add code to export a phase to clipboard for Andrew Will's VaList? program

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 2008/04/15 17:20:39 to 2008/07/14 01:19:02
    • Property rcs:lines changed from +404 -12 to +73 -18
    • Property rcs:rev changed from 1.64 to 1.65
    r910 r924  
    485485    set expgui(temp) $initvalue
    486486    pack [frame $w.b -bg beige] -side top -fill x -expand yes
    487     pack [button $w.b.2 -text Set -command "destroy $w"] -side left
     487    pack [button $w.b.2 -text Continue -command "destroy $w"] -side left
    488488    if $quit {
    489489        pack [button $w.b.3 -text Quit \
     
    15061506        # open a new window
    15071507        catch {toplevel .disagl}
     1508        eval destroy [winfo child .disagl]
     1509        set txt .disagl.txt
    15081510        catch {eval grid forget [grid slaves .disagl]}
    1509         text .disagl.txt -width 100 -wrap none \
     1511        text $txt -width 100 -wrap none \
    15101512                -yscrollcommand ".disagl.yscroll set" \
    15111513                -xscrollcommand ".disagl.xscroll set"
    1512         scrollbar .disagl.yscroll -command ".disagl.txt yview"
    1513         scrollbar .disagl.xscroll -command ".disagl.txt xview" -orient horizontal
     1514        scrollbar .disagl.yscroll -command "$txt yview"
     1515        scrollbar .disagl.xscroll -command "$txt xview" -orient horizontal
    15141516        grid .disagl.xscroll -column 0 -row 2 -sticky ew
    1515         grid .disagl.txt -column 0 -row 1 -sticky nsew
     1517        grid $txt -column 0 -row 1 -sticky nsew
    15161518        grid .disagl.yscroll -column 1 -row 1 -sticky ns
    15171519        grid [frame .disagl.f] -column 0 -columnspan 2 -row 3 -sticky ew
     
    15261528        # allow font changes on the fly
    15271529        if {$tcl_version >= 8.0} {
    1528             .disagl.txt config -font $txtvw(font)
     1530            $txt config -font $txtvw(font)
    15291531            set fontbut [tk_optionMenu .disagl.f.font txtvw(font) ""]
    15301532            grid .disagl.f.font -column 1 -row 0 -sticky w
     
    15341536                $fontbut add command -label "Courier $f" -font "Courier $f"\
    15351537                        -command "set txtvw(font) \"Courier $f\"; \
    1536                         .disagl.txt config -font \$txtvw(font)"
     1538                        $txt config -font \$txtvw(font)"
    15371539            }
    15381540        }
     
    15431545        wm iconname .disagl "DISAGL $root"
    15441546        set in [open $root.tmp r]
    1545         .disagl.txt insert end [read $in]
     1547        $txt insert end [read $in]
    15461548        close $in
    15471549        bind all  {destroy .disagl}
    1548         bind .disagl  ".disagl.txt yview scroll -1 page"
    1549         bind .disagl  ".disagl.txt yview scroll 1 page"
    1550         bind .disagl  ".disagl.txt xview scroll 1 unit"
    1551         bind .disagl  ".disagl.txt xview scroll -1 unit"
    1552         bind .disagl  ".disagl.txt yview scroll -1 unit"
    1553         bind .disagl  ".disagl.txt yview scroll 1 unit"
    1554         bind .disagl  ".disagl.txt yview 0"
    1555         bind .disagl  ".disagl.txt yview end"
     1550        bind .disagl  "$txt yview scroll -1 page"
     1551        bind .disagl  "$txt yview scroll 1 page"
     1552        bind .disagl  "$txt xview scroll 1 unit"
     1553        bind .disagl  "$txt xview scroll -1 unit"
     1554        bind .disagl  "$txt yview scroll -1 unit"
     1555        bind .disagl  "$txt yview scroll 1 unit"
     1556        bind .disagl  "$txt yview 0"
     1557        bind .disagl  "$txt yview end"
    15561558        # don't disable in Win as this prevents the highlighting of selected text
    15571559        if {$tcl_platform(platform) != "windows"} {
    1558             .disagl.txt config -state disabled
     1560            $txt config -state disabled
    15591561        }
     1562        # find the beginning of the disagl text
     1563
     1564        set pos 1.0
     1565        set nph 0
     1566        while {[set loc [$txt search "Program DISAGL Version" $pos end]] != ""} {
     1567            set pos [expr {$loc + 1}]
     1568            incr nph
     1569        }
     1570        #puts "Found $nph DISAGL run(s)"
     1571        # count phases
     1572        set l {}
     1573        while {[set loc [$txt search "Lattice constants are" $pos end]] != ""} {
     1574            lappend l $loc
     1575            set pos [expr {$loc + 1}]
     1576}
     1577        catch {unset phaseloc}
     1578       
     1579        set j 0
     1580        foreach pos $l {
     1581            if {$j == 0} {
     1582                set prev $pos
     1583                incr j
     1584                continue
     1585            }
     1586            set phaseloc($j) [list $prev $pos]
     1587            incr j
     1588        }
     1589        set phaseloc($j) [list $pos end]
     1590        if {$nph >= 1 && $j >= 2} {
     1591            grid [menubutton .disagl.f.copy \
     1592                      -menu .disagl.f.copy.menu \
     1593                      -text "Copy phase..." -bd 2 -relief raised] \
     1594                -column 2 -row 0 -sticky nse
     1595            menu .disagl.f.copy.menu
     1596            for {set i 1} {$i <= $j} {incr i} {
     1597                .disagl.f.copy.menu add command \
     1598                    -command "seldisaglphase $txt [list $phaseloc($i)]" \
     1599                    -label "Copy phase $i to clipboard"
     1600            }
     1601        } elseif {$nph >= 1} {
     1602            grid [button .disagl.f.copy \
     1603                      -command "seldisaglphase $txt [list $phaseloc($j)]" \
     1604                -text "Copy phase $j to clipboard"] \
     1605                -column 2 -row 0 -sticky e
     1606        }
    15601607    } else {
    15611608        runGSASwEXP disagl
     
    15631610}
    15641611
     1612proc seldisaglphase {txt phaselist} {
     1613    # clear selection
     1614    $txt tag remove sel 1.1 end
     1615    eval $txt tag add sel $phaselist
     1616    clipboard clear
     1617    clipboard append "               |         Program DISAGL Version MacOSX        |\n"
     1618    clipboard append [eval $txt get [$txt tag ranges sel]]
     1619}
    15651620#------------------------------------------------------------------------------
    15661621# file conversions
Note: See TracChangeset for help on using the changeset viewer.