Changeset 5662 for trunk/gui/apps
- Timestamp:
- Jun 5, 2015, 2:41:12 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/apps/table
r2415 r5662 1 1 # -*- mode: Tcl -*- 2 2 3 package require Rappture 3 4 package require RapptureGUI 4 5 5 6 #####TK code ##### 6 # TK code 7 7 package require fileutil 8 8 proc is_xml {name} {return [string match *.xml $name]} 9 9 10 ######Starting main tk code ###### 11 12 ################## 10 # Starting main tk code 11 13 12 package require BLT 14 13 if { $tcl_version >= 8.0 } { 15 namespace import blt::* 16 namespace import -force blt::tile::* 17 } 14 namespace import blt::* 15 namespace import -force blt::tile::* 16 } 17 18 18 proc SortColumn { column } { 19 set old [.t sort cget -column] 20 set decreasing 0 21 if { "$old" == "$column" } { 22 set decreasing [.t sort cget -decreasing] 23 set decreasing [expr !$decreasing] 24 } 25 .t sort configure -decreasing $decreasing -column $column -mode integer 26 if { ![.t cget -flat] } { 27 .t configure -flat yes 28 } 29 .t sort auto yes 30 blt::busy hold .t 31 update 32 blt::busy release .t 33 } 19 set old [.t sort cget -column] 20 set decreasing 0 21 if { "$old" == "$column" } { 22 set decreasing [.t sort cget -decreasing] 23 set decreasing [expr !$decreasing] 24 } 25 .t sort configure -decreasing $decreasing -column $column -mode integer 26 if { ![.t cget -flat] } { 27 .t configure -flat yes 28 } 29 .t sort auto yes 30 blt::busy hold .t 31 update 32 blt::busy release .t 33 } 34 34 35 proc resulttable {cmpfiles} { 35 #/////////////creating xml tables for each xml run files go here///////////////// 36 set tree2 [tree create] 37 treeview .k \ 38 -width 0 \ 39 -yscrollcommand { .vvvs set } \ 40 -xscrollcommand { .hhhs set } \ 41 -selectmode single \ 42 -tree $tree2 43 .k column configure treeView -text "" 44 .k column configure treeView -hide no -edit no -icon blt::tv::normalOpenFolder 45 focus .k 46 scrollbar .vvvs -orient vertical -command { .k yview } 47 scrollbar .hhhs -orient vertical -command { .k xview } 48 49 table . \ 50 0,0 .k -fill both \ 51 0,1 .vvvs -fill y \ 52 1,0 .hhhs -fill x 53 table configure . c1 r1 -resize none 54 55 ################################################################################### 56 set flags [list] 57 #$cmpfiles 58 set filelen [llength $cmpfiles] 59 set biglist [list] 60 61 set memberlist [list] 62 set contentlist [list] 63 #set inputmemberlist [list] 64 #set outputmemberlist [list] 65 set counter 0 66 foreach filename $cmpfiles { 67 set temp [list] 68 set tempfile [list] 69 set filetail [file tail $filename] 70 lappend temp $filetail 71 #lappend biglist $filetail 72 lappend tempfile $filetail 73 unset filetail 74 set lib [Rappture::library $filename] 75 set input1 [$lib children -as component "input"] 76 set temp1 ".current" 77 set ttemp "input." 78 foreach eachinputline $input1 { 79 set temp2 $eachinputline$temp1 80 set ttemp2 $ttemp$temp2 81 if {$counter==0} { 82 lappend memberlist $ttemp2 83 } 84 set temp3 [$lib get $ttemp2] 85 #puts hello 86 #puts $temp2 87 puts value 88 puts $temp3 89 lappend contentlist $temp3 90 #lappend biglist $temp3 91 #lappend temp $temp3 92 #unset temp3 93 #unset temp2 94 } 95 unset ttemp 96 set ttemp "output." 97 set output1 [$lib children -as component "output"] 98 foreach eachoutputline $output1 { 99 set temp2 $eachoutputline$temp1 100 set ttemp2 $ttemp$temp2 101 set temp3 [$lib get $ttemp2] 102 if {"" != $temp3} { 103 puts output 104 # puts $temp2 105 puts value 106 107 # puts $temp3 108 # lappend temp $temp3 109 #lappend biglist $temp3 110 lappend contentlist $temp3 111 unset temp3 112 unset temp2 113 if {$counter ==0} { 114 lappend memberlist $ttemp2 115 } 116 } 117 } 118 lappend tempfile $contentlist 119 unset contentlist 120 lappend biglist $tempfile 121 incr counter; 122 } 123 puts memberlist 124 puts $memberlist 125 puts bigliststarthere 36 # creating xml tables for each xml run files go here 37 set tree2 [tree create] 38 treeview .k \ 39 -width 0 \ 40 -yscrollcommand { .vvvs set } \ 41 -xscrollcommand { .hhhs set } \ 42 -selectmode single \ 43 -tree $tree2 44 .k column configure treeView -text "" 45 .k column configure treeView -hide no -edit no \ 46 -icon blt::tv::normalOpenFolder 47 focus .k 48 scrollbar .vvvs -orient vertical -command { .k yview } 49 scrollbar .hhhs -orient horizontal -command { .k xview } 50 51 table . \ 52 0,0 .k -fill both \ 53 0,1 .vvvs -fill y \ 54 1,0 .hhhs -fill x 55 table configure . c1 r1 -resize none 56 57 puts "resulttable: $cmpfiles" 58 59 set flags [list] 60 set numfiles [llength $cmpfiles] 61 set biglist [list] 62 63 set memberlist [list] 64 set contentlist [list] 65 set counter 0 66 foreach filepath $cmpfiles { 67 set filename [file tail $filepath] 68 set lib [Rappture::library $filepath] 69 set inputs [$lib children -as component "input"] 70 foreach input $inputs { 71 set path "input.${input}.current" 72 if {$counter == 0} { 73 lappend memberlist $path 74 } 75 set value [$lib get $path] 76 puts "$path: $value" 77 lappend contentlist $value 78 unset value 79 } 80 set outputs [$lib children -as component "output"] 81 foreach output $outputs { 82 set path "output.${output}" 83 set value [$lib get $path] 84 if {"" != $value} { 85 if {$counter == 0} { 86 lappend memberlist $path 87 } 88 puts "$path: $value" 89 lappend contentlist $value 90 unset value 91 } 92 } 93 set temp [list] 94 lappend temp $filename $contentlist 95 unset contentlist 96 lappend biglist $temp 97 unset temp 98 incr counter; 99 } 100 #puts memberlist 101 #puts $memberlist 102 puts "START_BIG_LIST [llength $biglist]" 126 103 puts $biglist 127 ################Adding columns to table########################################### 128 set memberlen [llength $memberlist] 129 # .k column insert end "filename" -text "File Name" 130 for { set j 0} {$j < $memberlen} {incr j} { 131 set temp [lindex $memberlist $j] 132 puts memberlist 133 puts $memberlist 134 puts temp 135 puts $temp 136 puts len 137 puts $memberlen 138 if { "" == $temp } { 139 #.k column insert end $temp -text $temp 140 continue 141 } 142 .k column insert end $temp -text $temp 143 } 144 #######Comparing XML Tree comes here####### 145 set count 0 146 set element1 [lindex $biglist 0] 147 set name1 [lindex $element1 0] 148 set content1 [lindex $element1 1] 149 foreach element2 $biglist { 150 if {$count !=0} { 151 foreach {name2 content2} $element2 { 152 set contentlen [llength $content2] 153 for {set i 0} {$i < $contentlen} {incr i} { 154 puts insideforloop 155 set similarexisted 0 156 if {[lindex $content1 $i] eq [lindex $content2 $i]} { 157 puts insidesame 158 } else { 159 puts insidediff 160 lappend flags 1 161 continue 162 } 163 if { $similarexisted == 0 } { 164 lappend flags 0 165 } 166 } 167 } 168 } 169 incr count 170 } 171 ################################ 172 foreach element1 $biglist { 173 set list_content [list] 174 set name [lindex $element1 0] 175 set id [.k insert end $name] 176 set content [lindex $element1 1] 177 foreach ele1 $memberlist ele2 $content flag $flags { 178 lappend list_content $ele1 179 180 if { $flag == 0} { 181 lappend list_content "Same" 182 } else { 183 lappend list_content $ele2 184 } 185 } 186 puts [llength $list_content] 187 puts $list_content 188 .k entry configure $id -data $list_content 189 } 190 # set templist [list] 191 # lappend templist "input.number(n1).current" 192 # lappend templist "h" 193 # lappend templist "input.number(n2).current" 194 # lappend templist "i" 195 # lappend templist "output.number(sum).current" 196 # lappend templist "k" 197 # .k entry configure $id -data $templist 198 #.k entry configure $id -data [list input.number(n1).current "h" input.number(n2).current "i" output.number(sum).current "k"] 199 104 puts END_BIG_LIST 105 # Adding columns to table 106 #.k column insert end "filename" -text "File Name" 107 foreach path $memberlist { 108 puts "add column: $path" 109 if { "" == $path } { 110 continue 111 } 112 .k column insert end $path -text $path 113 } 114 # Comparing XML Tree 115 set count 0 116 set element1 [lindex $biglist 0] 117 set name1 [lindex $element1 0] 118 set content1 [lindex $element1 1] 119 foreach element2 $biglist { 120 if {$count != 0} { 121 foreach {name2 content2} $element2 { 122 set contentlen [llength $content2] 123 for {set i 0} {$i < $contentlen} {incr i} { 124 #puts insideforloop 125 set similarexisted 0 126 if {[lindex $content1 $i] eq [lindex $content2 $i]} { 127 #puts insidesame 128 } else { 129 #puts insidediff 130 lappend flags 1 131 continue 132 } 133 if { $similarexisted == 0 } { 134 lappend flags 0 135 } 136 } 137 } 138 } 139 incr count 140 } 141 142 foreach element $biglist { 143 set name [lindex $element 0] 144 set content [lindex $element 1] 145 set id [.k insert end $name] 146 set list_content [list] 147 foreach path $memberlist value $content flag $flags { 148 lappend list_content $path 149 150 if { $flag == 0} { 151 lappend list_content "Same" 152 } else { 153 lappend list_content $value 154 } 155 } 156 puts [llength $list_content] 157 puts $list_content 158 .k entry configure $id -data $list_content 159 } 160 161 #set templist [list] 162 #lappend templist "input.number(n1).current" 163 #lappend templist "h" 164 #lappend templist "input.number(n2).current" 165 #lappend templist "i" 166 #lappend templist "output.number(sum).current" 167 #lappend templist "k" 168 #.k entry configure $id -data $templist 169 #.k entry configure $id \ 170 # -data [list input.number(n1).current "h" input.number(n2).current "i" output.number(sum).current "k"] 200 171 } 201 172 202 173 proc newtable {appname} { 203 global twofiles tree1 204 set twofiles [list] 205 #set length [llength $twofiles] 206 #puts $length 207 puts $twofiles 208 set tree1 [tree create] 209 treeview .h \ 210 -width 0 \ 211 -yscrollcommand { .vvs set } \ 212 -xscrollcommand { .hhs set } \ 213 -selectmode single \ 214 -tree $tree1 215 .h column configure treeView -text "" 216 .h column configure treeView -hide yes -edit no -icon blt::tv::normalOpenFolder 217 focus .h 218 scrollbar .vvs -orient vertical -command { .h yview } 219 scrollbar .hhs -orient horizontal -command { .h xview } 220 221 .h style checkbox mycheck -onvalue "yes" -offvalue "no" -showvalue yes 222 .h column insert end select -text "Select" -edit yes -style mycheck 223 224 225 table . \ 226 0,0 .h -fill both \ 227 0,1 .vvs -fill y \ 228 1,0 .hhs -fill x 229 table configure . c1 r1 -resize none 230 231 ###Starting tk code 232 .h column insert end "tname" -text "Tool Name" 233 .h column insert end "date" -text "Date" 234 set files [fileutil::find /home/nanohub/wwinthan/data/results is_xml] 235 if {$files == ""} { 236 } else { 237 foreach line $files { 238 ######### 239 set fileone [open $line] 240 set content [read $fileone] 241 close $fileone 242 regexp {<title>(.*)</title>} $content junk answer 243 regexp {<time>(.*)</time>} $content junk1 answer1 244 ######### 245 # if {($params(-title) == "") || ($params(-title) == $answer)} { 246 # set id [.t insert end $line] 247 # .t entry configure $id -data [list tname $answer date $answer1] 248 # } 249 # 250 # set id [.h insert end $line] 251 if { $appname == $answer } { 252 set id [.h insert end $line] 253 .h entry configure $id -data [list tname $answer date $answer1 select yes] 254 } 255 unset fileone 256 unset content 257 # unset answer 258 # unset answer1 259 unset junk 260 unset junk1 261 unset line 262 263 if {"" == $answer} { 264 set answer "no title" 265 } 266 if {"" == $answer1} { 267 set answer1 "no found" 268 } 269 } 270 unset answer 271 unset answer1 272 } 273 .h bind all <ButtonRelease-1> { 274 } 275 276 277 278 279 button .compare -text "Compare" -command compare 280 blt::table . \ 281 2,0 .compare -anchor e -columnspan 2 282 283 proc compare {} { 284 global tree1 285 #declaring lists 286 set filename [list] 287 288 foreach node [$tree1 children root] { 289 set label [$tree1 label $node] 290 set select [$tree1 get $node "select"] 291 set tname [$tree1 get $node "tname"] 292 #set filetail [file tail $label] 293 #puts FileTail 294 #puts $filetail 295 puts stderr "found at node $node: select=$select tname=$tname" 296 if { $select == "yes" } { 297 puts $label 298 lappend filename $label 299 } 300 } 301 set cmpfileslen [llength $filename] 302 resulttable $filename 303 304 } 305 ########l########### 306 #foreach column [.h column names] { 307 # .h column configure $column -command [list SortColumn $column] 308 #} 309 } 310 ########################### 311 package require fileutil 312 proc is_xml {name} { return [string match *.xml $name]} 313 314 315 316 ############################ 317 #proc passtitle {title} { 174 global tree1 175 176 set tree1 [tree create] 177 treeview .h \ 178 -width 0 \ 179 -yscrollcommand { .vvs set } \ 180 -xscrollcommand { .hhs set } \ 181 -selectmode single \ 182 -tree $tree1 183 .h column configure treeView -text "" 184 .h column configure treeView -hide yes -edit no \ 185 -icon blt::tv::normalOpenFolder 186 focus .h 187 scrollbar .vvs -orient vertical -command { .h yview } 188 scrollbar .hhs -orient horizontal -command { .h xview } 189 190 .h style checkbox mycheck -onvalue "yes" -offvalue "no" -showvalue yes 191 .h column insert end select -text "Select" -edit yes -style mycheck 192 193 table . \ 194 0,0 .h -fill both \ 195 0,1 .vvs -fill y \ 196 1,0 .hhs -fill x 197 table configure . c1 r1 -resize none 198 199 # Starting tk code 200 .h column insert end "tname" -text "Tool Name" 201 .h column insert end "date" -text "Date" 202 global env 203 set files [fileutil::find $env(HOME)/data/results is_xml] 204 if {$files == ""} { 205 } else { 206 foreach line $files { 207 set fileone [open $line] 208 set content [read $fileone] 209 close $fileone 210 regexp {<title>(.*)</title>} $content junk title 211 if {![info exists title]} { 212 continue 213 } 214 set title [string trim $title] 215 set time "" 216 regexp {<time>(.*)</time>} $content junk time 217 set time [string trim $time] 218 #if {($params(-title) == "") || ($params(-title) == $title)} { 219 # set id [.t insert end $line] 220 # .t entry configure $id -data [list tname $title date $time] 221 #} 222 # 223 #set id [.h insert end $line] 224 if { $appname == $title } { 225 set id [.h insert end $line] 226 .h entry configure $id \ 227 -data [list tname $title date $time select yes] 228 } 229 unset fileone 230 unset content 231 unset title 232 unset time 233 if {[info exists junk]} { unset junk } 234 unset line 235 } 236 } 237 .h bind all <ButtonRelease-1> { 238 } 239 240 button .compare -text "Compare" -command compare 241 blt::table . \ 242 2,0 .compare -anchor e -columnspan 2 243 244 proc compare {} { 245 global tree1 246 # declaring lists 247 set filename [list] 248 249 foreach node [$tree1 children root] { 250 set label [$tree1 label $node] 251 set select [$tree1 get $node "select"] 252 set tname [$tree1 get $node "tname"] 253 puts stderr "found at node $node: select=$select tname=$tname" 254 if { $select == "yes" } { 255 puts $label 256 lappend filename $label 257 } 258 } 259 set cmpfileslen [llength $filename] 260 resulttable $filename 261 } 262 #foreach column [.h column names] { 263 # .h column configure $column -command [list SortColumn $column] 264 #} 265 } 266 318 267 proc startupcode {} { 319 set tree [tree create] 320 treeview .t \ 321 -width 0 \ 322 -yscrollcommand { .vs set } \ 323 -xscrollcommand { .hs set } \ 324 -selectmode single \ 325 -tree $tree 326 .t column configure treeView -text "" 327 .t column configure treeView -hide yes -edit no -icon blt::tv::normalOpenFolder 328 focus .t 329 scrollbar .vs -orient vertical -command { .t yview } 330 scrollbar .hs -orient horizontal -command { .t xview } 331 table . \ 332 0,0 .t -fill both \ 333 0,1 .vs -fill y \ 334 1,0 .hs -fill x 335 table configure . c1 r1 -resize none 336 .t column insert end "appname" -text "Application Name" 337 .t column insert end "xmlfilename" -text "File Name" 338 set files [fileutil::find /home/nanohub/wwinthan/data/results is_xml] 339 set appnamelist [list] 340 if {$files == ""} { 341 } else { 342 foreach line $files { 343 set existed "false" 344 set fileone [open $line] 345 set content [read $fileone] 346 close $fileone 347 regexp {<title>(.*)</title>} $content junk answer 348 puts rreturnrrr: 349 puts $answer 350 351 foreach listcontent $appnamelist { 352 puts Appname: 353 puts $listcontent 354 if {$answer == $listcontent} { set existed "true"} 355 356 # puts $listcontent 357 # puts answeris 358 # puts $answer 359 } 360 puts $existed 361 if { $existed == "false" } { 362 set temp [file tail $line] 363 set id [.t insert end $line] 364 .t entry configure $id -data [list appname $answer xmlfilename $temp] 365 lappend appnamelist $answer 366 #puts listlistare 367 #puts $appnamelist 368 } 369 unset existed 370 unset fileone 371 unset content 372 unset answer 373 unset line 374 } 375 puts $appnamelist 376 } 377 378 .t bind all <ButtonRelease-1> { 379 set ids [.t curselection] 380 set name [eval .t get -full $ids] 381 set fileone [open $name] 382 set content [read $fileone] 383 close $fileone 384 regexp {<title>(.*)</title>} $content junk answer 385 #pass title and display the result in new page 386 newtable $answer 387 } 388 } 268 set tree [tree create] 269 treeview .t \ 270 -width 0 \ 271 -yscrollcommand { .vs set } \ 272 -xscrollcommand { .hs set } \ 273 -selectmode single \ 274 -tree $tree 275 .t column configure treeView -text "" 276 .t column configure treeView -hide yes -edit no \ 277 -icon blt::tv::normalOpenFolder 278 focus .t 279 scrollbar .vs -orient vertical -command { .t yview } 280 scrollbar .hs -orient horizontal -command { .t xview } 281 table . \ 282 0,0 .t -fill both \ 283 0,1 .vs -fill y \ 284 1,0 .hs -fill x 285 table configure . c1 r1 -resize none 286 .t column insert end "appname" -text "Application Name" 287 .t column insert end "xmlfilename" -text "File Name" 288 global env 289 set files [fileutil::find $env(HOME)/data/results is_xml] 290 set appnamelist [list] 291 if {$files == ""} { 292 } else { 293 foreach line $files { 294 set existed false 295 set fileone [open $line] 296 set content [read $fileone] 297 close $fileone 298 regexp {<title>(.*)</title>} $content junk title 299 if {![info exists title]} { 300 puts stderr "ERROR: No title found in $line" 301 continue 302 } 303 set title [string trim $title] 304 #puts "found title: $title" 305 306 foreach app $appnamelist { 307 if {$title == $app} { 308 set existed true 309 break 310 } 311 } 312 if { ! $existed } { 313 set temp [file tail $line] 314 set id [.t insert end $line] 315 .t entry configure $id \ 316 -data [list appname $title xmlfilename $temp] 317 lappend appnamelist $title 318 } 319 unset existed 320 unset fileone 321 unset content 322 unset title 323 unset line 324 } 325 #puts $appnamelist 326 } 327 328 .t bind all <ButtonRelease-1> { 329 set ids [.t curselection] 330 set name [eval .t get -full $ids] 331 set fileone [open $name] 332 set content [read $fileone] 333 close $fileone 334 regexp {<title>(.*)</title>} $content junk title 335 set title [string trim $title] 336 # pass title and display the result in new page 337 newtable $title 338 } 339 } 340 389 341 startupcode 390 342 391 ############################392 343 #blt::treeview .t 393 344 #set node [.t insert end root "one"] … … 395 346 #.h configure -background "green" 396 347 #set id [.h insert end "myEntry"] 397
Note: See TracChangeset
for help on using the changeset viewer.