hi,<br><br>i am using pygtk,glade in the front end and postgresql,python-twisted (xmlrpc) as the back end.My issue is i am trying to add the progress bar in my application but when the progress bar comes up it is blocking the backend process.So i started using threading in my application.But when i added that it is working but i am not able to destroy the window where the progress bar is present, which is part of main window. <br>
********************************************************************************************************<br>my code is <br>class ledger(threading.Thread):<br> """This class sets the fraction of the progressbar"""<br>
<br> #Thread event, stops the thread if it is set.<br> stopthread = threading.Event()<br> ......<br> wTree = gtk.glade.XML('gnukhata/main_window.glade','window_progressbar')<br> window = wTree.get_widget('window_progressbar')<br>
window.set_size_request(300,50)<br> progressbar = wTree.get_widget('progressbar')<br> #window.connect('destroy',self.main_quit)<br> window.show_all()<br> <br><br> <br> def run(self):<br>
"""Run method, this is the code that runs while thread is alive."""<br> <br> #Importing the progressbar widget from the global scope<br> #global progressbar <br> course = True<br>
#While the stopthread event isn't setted, the thread keeps going on<br> while course :<br> # Acquiring the gtk global mutex<br> gtk.gdk.threads_enter()<br> #Setting a random value for the fraction<br>
l=0.1<br> while l<1:<br> self.progressbar.pulse()<br> time.sleep(0.1)<br> l=l+0.1<br><br><br> queryParams = []<br> res1=self.x.account.getAllAccountNamesByLedger(queryParams)<br>
for l in range(0,len(res1)):<br> ;;;;;;;;;;;;;;;;;;<br> # Releasing the gtk global mutex<br> gtk.gdk.threads_leave()<br> <br> #Delaying 100ms until the next iteration<br>
time.sleep(0.1)<br> course = False<br> #gtk.main_quit()<br> global fs<br> print 'anu'<br> #Stopping the thread and the gtk's main loop<br> fs.stop()<br>
<br> #window.destroy()<br> <br> self.ods.save("Ledger.ods")<br> os.system("ooffice Ledger.ods")<br> <br> <br> def stop(self):<br> """Stop method, sets the event to terminate the thread's main loop"""<br>
self.stopthread.set()<br><br>*********************************************************************************************************<br><br><br><br>njoy the share of freedom,<br>Anusha Kadambala<br>