Well to save you the head-scratching( I'm familiar with it due to hours of my own head-scratching :-) ), here is how to do it so each sftp run can be different.
| [reply] [d/l] |
Yah thanks alot. I got a little of that before you sent it, but definitly not all of it.
The program works great, does everything I want it to do. Now all that needs to be done is to make a listbox that prints all the print statements to it. It got some of it to work but when $msg=2 and the program enters the sub lstmsg, when it gets to the listbox insert the program stops. If I take the insert out it runs just fine. How can I fix this?
| [reply] [d/l] |
You are making a big mistake in trying to access one thread from another. Remember the rules I stated for threaded-Tk apps. No Tk code in the thread. Don't try to access Tk widgets from the thread. And in your case, don't use a goto, to try to jump into a thread.Without doing the code for you, this is how you would do it.
1. Make $msg, and $msg_return shared variables.
2. Like I did with the file counter, setup a timer in the main thread to watch for the value of $msg. At the point where you test for $msg==2 in the thread, go into a wait-loop in the thread,waiting for the shared-value $msg_return == 1. When that happens, continue in the thread.
3. When the main thread detects, $msg==2, it can do whatever is needed, then set $msg_return=1 and $msg=0, so the thread can continue.
Remember, ALL Tk stuff has to be done in the main thread. All communication with the worker thread(s) has to be done through simple shared-variables.
| [reply] |
Yeah, to make a new connection each run, move the connect to inside the go loop. To use new connection info for each connection, make them shared varaibles. Like:
my $user:shared = 'jlahowet';
+
my $server:shared = 'mistral.unl.edu';
+
my $lcl:shared = '/home/deadpickle/Desktop/Virtual Cockpit/uavposition
+';
my $rmt:shared = '/home/jlahowet/UAV/COORDS/uavposition';
#my $thr = threads->new(\&sftp, @setup);
my $thr = threads->new(\&sftp);
#then in your thread-code use the shared vars instead of
#using the passed in @setup array
You already have your entry widgets to setup to automatically change the vars with -textvariable.
There is one thing to watch out for: sometimes the threads
will not automatically pick up changes in textvariables, you might have to manually read them, but try it first, you may get lucky.
| [reply] [d/l] |