Changeset 168 for trunk


Ignore:
Timestamp:
Oct 12, 2012, 3:41:14 PM (12 years ago)
Author:
demin
Message:

add "Read file" button to histogram and counter views

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MultiChannelUSB/UserInterface.tcl

    r167 r168  
    77package require zlib
    88
    9 wm minsize . 990 660
     9wm minsize . 990 680
    1010
    1111namespace eval ::mca {
     
    513513        frame ${config}.spc6 -width 170 -height 30
    514514
    515 
    516515        button ${config}.register -text Register \
    517516            -bg lightblue -activebackground lightblue -command [myproc register]
     517
     518        frame ${config}.spc7 -width 170 -height 30
     519
     520        button ${config}.recover -text {Read file} \
     521            -bg lightblue -activebackground lightblue -command [myproc recover]
    518522
    519523        grid ${config}.axis_check -sticky w
     
    533537        grid ${config}.spc6
    534538        grid ${config}.register -sticky ew -pady 3 -padx 5
     539        grid ${config}.spc7
     540        grid ${config}.recover -sticky ew -pady 3 -padx 5
    535541
    536542        grid ${graph} -row 0 -column 0 -sticky news
     
    871877# -------------------------------------------------------------------------
    872878
     879    HstDisplay instproc open_data {} {
     880        set types {
     881            {{Data Files}       {.dat}     }
     882            {{All Files}        *             }
     883        }
     884
     885        set fname [tk_getOpenFile -filetypes $types]
     886        if {[string equal $fname {}]} {
     887            return
     888        }
     889
     890        set x [catch {
     891            set fid [open $fname r+]
     892            fconfigure $fid -translation binary -encoding binary
     893            [myvar yvec] set [split [read $fid] \n]
     894            close $fid
     895        }]
     896
     897        if { $x || ![file exists $fname] || ![file isfile $fname] || ![file readable $fname] } {
     898            tk_messageBox -icon error \
     899                -message "An error occurred while reading \"$fname\""
     900        } else {
     901            tk_messageBox -icon info \
     902                -message "File \"$fname\" read successfully"
     903        }
     904    }
     905
     906# -------------------------------------------------------------------------
     907
    873908    HstDisplay instproc register {} {
    874909        my save_data [join [[myvar yvec] range 0 4095] \n]
     910    }
     911
     912# -------------------------------------------------------------------------
     913
     914    HstDisplay instproc recover {} {
     915        my open_data
    875916    }
    876917
     
    10011042        button ${config}.register -text Register \
    10021043            -bg lightblue -activebackground lightblue -command [myproc register]
     1044
     1045        frame ${config}.spc8 -width 170 -height 30
     1046
     1047        button ${config}.recover -text {Read file} \
     1048            -bg lightblue -activebackground lightblue -command [myproc recover]
    10031049
    10041050        grid ${config}.axis_check -sticky w
     
    10191065        grid ${config}.spc7
    10201066        grid ${config}.register -sticky ew -pady 3 -padx 5
     1067        grid ${config}.spc8
     1068        grid ${config}.recover -sticky ew -pady 3 -padx 5
    10211069
    10221070        grid ${graph} -row 0 -column 0 -sticky news
     
    13311379# -------------------------------------------------------------------------
    13321380
     1381    CntDisplay instproc open_data {} {
     1382        set types {
     1383            {{Data Files}       {.dat}     }
     1384            {{All Files}        *             }
     1385        }
     1386
     1387        set fname [tk_getOpenFile -filetypes $types]
     1388        if {[string equal $fname {}]} {
     1389            return
     1390        }
     1391
     1392        set x [catch {
     1393            set fid [open $fname r+]
     1394            fconfigure $fid -translation binary -encoding binary
     1395            [myvar yvec] set [split [read $fid] \n]
     1396            close $fid
     1397        }]
     1398
     1399        if { $x || ![file exists $fname] || ![file isfile $fname] || ![file readable $fname] } {
     1400            tk_messageBox -icon error \
     1401                -message "An error occurred while reading \"$fname\""
     1402        } else {
     1403            tk_messageBox -icon info \
     1404                -message "File \"$fname\" read successfully"
     1405        }
     1406    }
     1407
     1408# -------------------------------------------------------------------------
     1409
    13331410    CntDisplay instproc register {} {
    13341411        my save_data [join [[myvar yvec] range 0 9999] \n]
     1412    }
     1413
     1414# -------------------------------------------------------------------------
     1415
     1416    CntDisplay instproc recover {} {
     1417        my open_data
    13351418    }
    13361419
     
    14641547            -bg yellow -activebackground yellow
    14651548
    1466         frame ${config}.spc6 -width 170 -height 10
     1549        frame ${config}.spc6 -width 170 -height 30
    14671550
    14681551        button ${config}.recover -text {Read file} \
Note: See TracChangeset for help on using the changeset viewer.