Keeping a Tkinter GUI alive during a long running process

Discussion in 'Python' started by Kevin Walzer, Dec 21, 2012.

  1. Kevin Walzer

    Kevin Walzer Guest

    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
     
    Kevin Walzer, Dec 21, 2012
    #1
    1. Advertising

  2. 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/...inter-repond-events-while-waiting-socket-data

    --
    Grant Edwards grant.b.edwards Yow! ... he dominates the
    at DECADENT SUBWAY SCENE.
    gmail.com
     
    Grant Edwards, Dec 29, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hoenes1
    Replies:
    0
    Views:
    397
    hoenes1
    Aug 16, 2004
  2. Steve W
    Replies:
    4
    Views:
    555
    Steven Cheng[MSFT]
    Dec 23, 2004
  3. Steve W
    Replies:
    2
    Views:
    999
    Steven Cheng[MSFT]
    Dec 22, 2004
  4. =?Utf-8?B?RGF2ZSBBbHZhcmFkbw==?=

    Keeping a session alive when accessing an ASP page with .Net code

    =?Utf-8?B?RGF2ZSBBbHZhcmFkbw==?=, Sep 1, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    688
    =?Utf-8?B?RGF2ZSBBbHZhcmFkbw==?=
    Sep 1, 2005
  5. hisan
    Replies:
    1
    Views:
    1,411
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page