Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem submitting TCL page

Status
Not open for further replies.

anirban2k2001

Programmer
Aug 25, 2003
27
0
0
IN
Hi all,

I have a TCL page with a list box and two command buttons - Submit and Exit.
When I click the Exit button the page exits.

However, I am facing problems with the Submit button.
I want the current page to unload and a new TCL page to get loaded when I click the submit button.
The first page is pick_cons.tcl and the second page is display_cons.tcl.

The list box and command buttons as mentioned above are in pick_cons.tcl and the page to be loaded when I click the Submit button in pick_cons.tcl is display_cons.tcl.

How do I load the display_cons.tcl?
Also is there any way by which I can carry over any variable (say cmd) from pick_cons.tcl to display_cons.tcl when I click on the Submit button?

For your convenience, I am giving the code of the mentioned file - pick_cons.tcl. They are under /usr/local/bin directory.

#########################CODE#############################

# To use alchemy API do the following
package require picoapi
update idletasks

# The following gets executed, when the application is closed
wm protocol . WM_DELETE_WINDOW {
# You can do some wrap-up work here, before the application quits
exit
}

# Set the title and the status here
# Status message is always right justified by default
wm title . "Meter Details"
alchemy status_msg "Meter Details"

#Creating a Frame
frame .f
place .f -x 0 -y 0 -width 240 -height 270

#creating a listbox with a scroll bar
label .f.name -text "Select consumer no."
place .f.name -x 10 -y 5

listbox .f.l -yscrollcommand {.f.s set} -font "-picopeta-simputer-medium-r-normal--11-120-101-108-p-120-fontspecific-0"
place .f.l -x 10 -y 40 -width 220 -height 130

#creating a label widget (With no text)
label .f.lab -text ""
place .f.lab -x 10 -y 160

#Defining a scroll bar for the listbox
scrollbar .f.s -orient vertical -command {.f.l yview}
place .f.s -x 230 -y 40 -width 10 -height 130

# Loading the sqlite database
load /usr/lib/tclsqlite-2.8.15.so Sqlite
sqlite db1 /root/cesc_simputer.db

# Fetching and populating values from backend
db1 eval {select con_no from mri} values {
parray values
.f.l insert end $values(con_no)
puts ""
}

button .b1 -text "Submit" -command {}
place .b1 -x 10 -y 175 -width 70 -height 20

button .b2 -text "Exit" -command exit
place .b2 -x 115 -y 175 -width 70 -height 20

#Blocking the first item in the Listbox
#By default, the first item in the listbox will be selected
.f.l selection set 0 0

#The bind will be called when some action taken place on the Listbox.
#This will be called when the item is selected in the List box.
bind .f.l <<ListboxSelect>> {
#Calling a procedure callled 'send_remote_command'
send_remote_command
}

proc send_remote_command {} {
#[.f.l curselection] will return the index number of the item selected in the Listbox.
set sel [.f.l curselection]

if {$sel != ""} {
#The [.f.l get $sel $sel] will get the actual value been selected in the Listbox
set cmd [.f.l get $sel $sel]
#This will execute a tcl prog called display_cons.tcl and send the value
#of $cmd as a command line arguement
#exec /usr/local/bin/display_cons.tcl $cmd

#Initialise and open the text file for writing
set filename "cons_sel.txt"
set fileId [open $filename "w"]

#Setting the data variable
set data $cmd
puts -nonewline $fileId $data

#Closing all open file objects
close $fileId

#exec /usr/local/bin/display_cons.tcl
#exit


}
}

#Closing the database
db1 close









#########################CODE#############################

The backend database is cesc_simputer.db and it is under /root directory. I cannot provide the database as I can find no option to attach it when I post a new thread.

Any help in this regard will be highly appreciated.

Regards,
Anirban Sarkar
 
I'm not sure what you mean by "page" but I'm guessing it's the toplevel window. If that's the case what I would do is the following:
1. destroy existing widgets
2. build new widgets

The simplest way to do this, I think, would be to have the submit button command to call a proc like this:

proc changePage {} {
destroy .f
source /usr/local/bin/display_cons.tcl
}


This presupposes that the code in display_cons.tcl sets up its own frames and widgets.

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top