Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Keeping a Tkinter GUI alive during a long running process

Reply
Thread Tools

Keeping a Tkinter GUI alive during a long running process

 
 
Kevin Walzer
Guest
Posts: n/a
 
      12-21-2012
I maintain a Tkinter application that's a front-end to to a package
manger, and I have never been able to find a way to keep the app from
locking up at some point during the piping in of the package manager's
build output into a text widget. At some point the buffer is overwhelmed
and the app simply can't respond anymore, or writes data to the text
widget after locking up for a period.

I've long used the typical Tkinter design pattern of opening a pipe to
the external command, and letting it do its thing. However, after a
time, this locks up the app. If I try to throttle the buffer with some
combination of "update" or "after" or "update_idletasks," that keeps the
data flowing, but it comes in too slowly and keeps flowing in long after
the external process has terminated.

Below is a sample function that illustrates how I approach this issue.
Can someone suggest a better approach?

#install a fink package
def installPackage(self):

self.package = self.infotable.getcurselection()
if not self.package:
showwarning(title='Error', message='Error', detail='Please
select a package name.', parent=self)
return
else:
self.clearData()
self.packagename = self.package[0][1]
self.status.set('Installing %s' % self.packagename)
self.setIcon(self.phynchronicity_install)
self.playSound('connect')
self.showProgress()
self.file = Popen('echo %s | sudo -S %s -y install %s' %
(self.passtext, self.finkpath.get(), self.packagename), shell=True,
bufsize=0, stdout=PIPE).stdout
for line in self.file:
self.inserturltext(line)
self.after(5000, self.update_idletasks)

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      12-29-2012
On 2012-12-21, Kevin Walzer <> wrote:

> I maintain a Tkinter application that's a front-end to to a package
> manger, and I have never been able to find a way to keep the app from
> locking up at some point during the piping in of the package manager's
> build output into a text widget. At some point the buffer is overwhelmed
> and the app simply can't respond anymore, or writes data to the text
> widget after locking up for a period.
>
> I've long used the typical Tkinter design pattern of opening a pipe to
> the external command, and letting it do its thing. However, after a
> time, this locks up the app. If I try to throttle the buffer with some
> combination of "update" or "after" or "update_idletasks," that keeps the
> data flowing, but it comes in too slowly and keeps flowing in long after
> the external process has terminated.


Isn't there a way in Tkinter to have a file descriptor produce an
event whenever it becomes readble?

http://stackoverflow.com/questions/3...ng-socket-data

--
Grant Edwards grant.b.edwards Yow! ... he dominates the
at DECADENT SUBWAY SCENE.
gmail.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How keep python socket alive for ever by setting Keep alive flag. hisan Python 1 06-25-2012 05:30 PM
Having compilation error: no match for call to ‘(const __gnu_cxx::hash<long long int>) (const long long int&)’ veryhotsausage C++ 1 07-04-2008 05:41 PM
Keeping a page from timing out when waiting for a long running process Steve W ASP .Net 4 12-23-2004 01:02 AM
Keeping a page from timing out when waiting for a long running process Steve W ASP .Net 2 12-22-2004 03:14 AM
Keeping a Session alive during long downloads hoenes1 ASP .Net 0 08-16-2004 12:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57