threading issue
anusha k
anuhacks at gmail.com
Sun May 17 15:13:31 EDT 2009
hi,
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.
********************************************************************************************************
my code is
class ledger(threading.Thread):
"""This class sets the fraction of the progressbar"""
#Thread event, stops the thread if it is set.
stopthread = threading.Event()
......
wTree = gtk.glade.XML('gnukhata/main_window.glade','window_progressbar')
window = wTree.get_widget('window_progressbar')
window.set_size_request(300,50)
progressbar = wTree.get_widget('progressbar')
#window.connect('destroy',self.main_quit)
window.show_all()
def run(self):
"""Run method, this is the code that runs while thread is alive."""
#Importing the progressbar widget from the global scope
#global progressbar
course = True
#While the stopthread event isn't setted, the thread keeps going on
while course :
# Acquiring the gtk global mutex
gtk.gdk.threads_enter()
#Setting a random value for the fraction
l=0.1
while l<1:
self.progressbar.pulse()
time.sleep(0.1)
l=l+0.1
queryParams = []
res1=self.x.account.getAllAccountNamesByLedger(queryParams)
for l in range(0,len(res1)):
;;;;;;;;;;;;;;;;;;
# Releasing the gtk global mutex
gtk.gdk.threads_leave()
#Delaying 100ms until the next iteration
time.sleep(0.1)
course = False
#gtk.main_quit()
global fs
print 'anu'
#Stopping the thread and the gtk's main loop
fs.stop()
#window.destroy()
self.ods.save("Ledger.ods")
os.system("ooffice Ledger.ods")
def stop(self):
"""Stop method, sets the event to terminate the thread's main
loop"""
self.stopthread.set()
*********************************************************************************************************
njoy the share of freedom,
Anusha Kadambala
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090518/ea459c07/attachment.html>
More information about the Python-list
mailing list