LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-19-2012, 12:06 PM   #1
menylea
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Rep: Reputation: Disabled
tcl/tx progree bar question


Guys,

Im writing a simple widgth in tcl/tk that will have 3 area: command line entry, log , and progrees bar ( pai chart style). with two button : run &quit.

it all work great but the progress bar ( I didnt wrote this part..:-) ).
could you please help me here to connect the progree bar to the main program?
now, it start automaticlly when the main window comes up. what I need is that the progree bar will start work when the user press the button "Run", and the progrees bar should reflect the real progrresion of the run. ( I attached at the end of the program the log file that I get- I guess by pharsing spacific words from it the progress bar can get update ?)

thx

#!/usr/local/bin/wish



global command; set command $env(command)

#excelog - run a program with exec and log the output

# Set window tiltle

wm title . "Status Window"



# Create a frame for buttons and entry.

frame .top -borderwidth 10
pack .top -side top -fill x



#Create the command buttons

button .top.quit -text Quit -command exit
set but [button .top.run -text "Run it" -command Run ]
pack .top.quit .top.run -side right



# Create a labeled entry for the command

label .top.1 -text Command: -padx 0
entry .top.cmd -width 20 -relief sunken -textvariable command
pack .top.1 -side left
pack .top.cmd -side left -fill x -expand true



#set up key binding equivalents to the buttons

bind .top.cmd <Return> Run
bind .top.cmd <Control-c> Stop
focus .top.cmd



#Create a text widget to the log output

frame .t

set log [text .t.log -width 80 -height 10 -borderwidth 2 -relief raised -setgrid true \

-yscrollcommand {.t.scroll set}]

scrollbar .t.scroll -command {.t.log yview}
pack .t.scroll -side right -fill y
pack .t.log -side left -fill both -expand true
pack .t -side top -fill both -expand true



# Run the program and arrange to read its input

proc Run {} {

global command input log but
if [catch {open "|$command |& cat"} input] {

$log insert end $input\n

} else {



fileevent $input readable Log
$log insert end $command\n
$but config -text Stop -command Stop

}


}


#Read and log output from the program





proc Log {} {
global input log

if [eof $input ] {

Stop

} else {



gets $input line
$log insert end $line\n
$log see end


}

}



#Stop the program and fix up the button

proc Stop {} {



global input but

catch {close $input }

$but config -text "Run it" -command Run



}





# this is the progree pi chart





canvas .c -width 50 -height 50 -highlightt 0

.c create oval 2 2 48 48 -tags t1 -fill red -outline ""

.c create arc 2 2 48 48 -tags t2 -fill green -extent 0 -outline ""

.c create text 25 25 -tags t3

pack .c -padx 60 -pady 5

proc run {percent} \

{

.c itemconfig t3 -text $percent%

.c itemconfig t2 -extent [expr {round($percent * 3.6)}]

}

# run

focus -force .c

raise .c

for {set i 0} {$i <= 100} {incr i} \

{

run $i

after 100

update

}

.c itemconfig t1 -fill green










******************************************************************************

XTR INFO: Creating of lib defs file ./lib_defs_starrc ...

*************************************************************************************

XTR INFO: Executing CCI-STAR flow: corner: typical, operation temperature: 25
PDV WARNING: .anytool file doesn't exists in cds directory
XTR INFO: Run directory: /home/dtmp/RF55LP_6M4X1URDL_RF19TC_fe_ATSTM_mux_menyl_typical_25c_xtr
XTR INFO: RUN calibre query on cell RF19TC_fe_ATSTM_mux...
XTR INFO: Query run command: calibre -query_input /home/dtmp/RF55LP_6M4X1URDL_RF19TC_fe_ATSTM_mux_menyl_typical_25c_xtr/RF19TC_fe_ATSTM_mux_query_cmd -query /home/dtmp/RF55LP_6M4X1URDL_RF19TC_fe_ATSTM_mux_menyl_lvs4cci/svdb_cci > RF19TC_fe_ATSTM_mux_query.log
XTR INFO: Query run was completed. See log file: RF19TC_fe_ATSTM_mux_query.log
XTR INFO: Star NXTGRD file: /ip/owner/menyl/DK55_NEW_55LP_6M4X1URDL/Extraction/Star_rcxt/tech_files/crn55rp_1p06m+alrdl_4x0z1u/1p6m_4x0z1u/RC_Star-RCXT_crn55lp_1p06m+alrdl_4x1u_typical/crn55lp_1p06m+alrdl_4x1u_typical.nxtgrd
XTR INFO: Star map file: /ip/owner/menyl/DK55_NEW_55LP_6M4X1URDL/LVS/Calibre/command_files/MAIN_DECK/CCI_FLOW/STAR_MAP/starrcxt_mapping_1p6m
XTR INFO: OA layer mapping file: /proj/RF55LP_6M4X1URDL/menyl/ws/etc/RF55LP_6M4X1URDL/pdv/templates/dfii_layer_map.txt
XTR INFO: OA device mapping file: /proj/RF55LP_6M4X1URDL/menyl/ws/etc/RF55LP_6M4X1URDL/pdv/templates/dfii_device_map.txt
XTR INFO: Run StarXtract: StarXtract -clean /home/dtmp/RF55LP_6M4X1URDL_RF19TC_fe_ATSTM_mux_menyl_typical_25c_xtr/RF19TC_fe_ATSTM_mux_typical_25c_star_cmd
XTR INFO: The StarRC run (typical, temp: 25) was completed successfully

Last edited by menylea; 11-19-2012 at 12:20 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
expect (Tcl) question kristof_v Programming 2 01-24-2013 05:32 AM
Tcl Tk script question KaYoS Slackware 1 11-20-2006 02:30 PM
Cannot find Tcl dll ( Perl's Tcl bridge ) Xyem Linux - Software 2 08-08-2006 09:45 AM
2 in 1 - dropline-gnome question and tcl question sl4ckw4re Slackware 7 07-24-2006 11:08 AM
Tcl/Tk - command < entry > question. liguorir Linux - Software 0 05-06-2004 10:36 PM


All times are GMT -5. The time now is 12:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration