Forum

Author Topic: A way to open a non-blocking UI?  (Read 5078 times)

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
A way to open a non-blocking UI?
« on: September 23, 2016, 12:15:45 AM »
I have to loop over a bunch of different chunks and run expensive tasks in a script. I'd like a way to see which one I'm on, so I was hoping to open a little PyQt widget that displays the current chunk and a progress bar. Unfortunately, once I launch my gui, it seems like it blocks the drawing of both agisoft and my ui.  Here's the abbreviated version of what I'm running:

Code: [Select]
class MyWidget (QtGui.QWidget):
  # Define the behavior here
  def setCurrentChunk( self, chunkNumber ):
    # Do some stuff

def doIt():
  win = MyWidget()
  win.show()
  for i in range(0,4):
    win.setCurrentChunk( i )
    print("Running %d"%i)
    time.sleep(5)

Unfortunately, my window updates sporadically and the print statements don't show up in the agisoft console until after the whole loop is done.

I know python isn't truly threaded, but is there a way that you've found to launch a gui that won't block draws? I really don't want to have to write a separate program that communicates over sockets just for a progress bar.

Thanks!

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: A way to open a non-blocking UI?
« Reply #1 on: September 23, 2016, 12:37:49 AM »
Nevermind, a combination of liberally sprinkling app.processEvents() and fixing bugs in my own code has this working now.