Hi All,<br><br>I'm new bie to python and programming and would like to get some assistance on the problem stated below.<br><br>I'm developing a GUI (using pyqt) to run some scripts (which were run on command line earlier).<br>
<br>on the GUI I have a run button which calls a .bat file , which has the list of scripts to execute. Once the run button is clicked, the run button is disabled as it invokes a command prompt, calls a .bat file and when I close the command prompt, I would like to re-enable the Run button.<br>
<br>Since I wanted to monitor the command prompt, I thought of invoking the command prompt on a thread and monitor the thread. Correct me if I went techinically incorrect here.<br><br>Run button on GUI: - Here I call the runscript ()<br>
self.connect(self.run_button, SIGNAL('clicked()'), self.runscript)<br clear="all"><br>def runscript(self):<br> file_operation.Generate_Bat_File(self.complete_file_path) # Generate a bat file.<br> <br>
self.timer = QTimer() # invoke timer for starting and monitoring the thread.<br> self.timer.connect(self.timer, SIGNAL("timeout()"),self.sendData) <br> self.timer.start(1000) <br><br>class RunMonitor(QThread):<br>
def __init__(self, parent=None):<br> QThread.__init__(self)<br> def run(self):<br> print 'Invoking Command Prompt..........'<br> subprocess.call(["start", "/DC:\\Scripts", "scripts_to_execute.bat"], shell=True)<br>
<br>def sendData(self):<br> <br> if self.run_timer:<br> run_monitor_object = RunMonitor()<br> print 'Starting the thread...........'<br> run_monitor_object.start()<br>
<br> if run_monitor_object.isRunning():<br> print 'The Thread is still Alive .......'<br> <br> if run_monitor_object.isFinished():<br> print 'The Thread is not alive anymore......'<br>
<br>I doubt the following.<br><br><a href="http://1.is">1.is</a> this the correct way to monitor the thread? if not any help towards this is appreciated.<br>2. Is this the correct way to invoke the command prompt in thread?<br>
3. is it safe to assume that as long as the command prompt is alive, the thread is active and when command prompt is closed, the thread is no more active.<br><br>Please help.....<br><br>Eagerly looking forward for some help....I googled enough but could not arrive at a solution.<br>
<br>-- <br>Vijay Swaminathan<br>