Strange appearance of RelativeProgress

edited June 4 in Python scripting

I am using RelativeProgress with the following pattern:

try:
   progress = pya.RelativeProgress("Exporting...", len(list))
   for item in list:
      do_some_work(item)
      progress.inc()
   except:
     self. handleError(sys.exc_info())
  finally:
     progress.destroy()

The progress bar is displayed, but it looks like this: I get two bars, with some flickering on the lower one:

How can I get rid of the second progress bar?
A second problem I have is, that the layout view panel stays "locked" with the progress bar, even after calling destroy().

Thanks a lot in advance.

Comments

  • edited June 4

    Hi,

    The second progress bar indicates an inner operation which also takes a progress. I assume that's something happening inside "do_some_work".

    If the progress gets stuck this means there still is a progress bar object alive. This can happen for example, if you stop your script using the debugger. Or if your work function displays a modal dialog - in this case, an inner event loop is created and the outer event loop won't continue, hence not executing "progress.destroy()".

    As you don't give me enough details to analyze the problem, I'm going to counter with a sample code which does NOT demonstrate the problem:

    len = 100
    
    ly = pya.Layout()
    top_cell = ly.create_cell("TOP")
    l1 = ly.layer(1, 0)
    for n in range(0, 1000000):
      top_cell.shapes(l1).insert(pya.Box(n, n, n + 10, n + 10))
    
    def do_some_work(index, ly):
      ly.write("/home/matthias/x.gds")  
    
    try:
      progress = pya.RelativeProgress("Exporting...", len)
      for index in range(0, len):
        do_some_work(index, ly)
        progress.inc()
    except:
      print("Error happened")
    finally:
      progress.destroy()
    

    This code works nicely by writing the same file in a loop. It shows the duplicate progress: the upper one for the "Exporting ..." loop, the lower one for writing each file. When you push Cancel, the progress is nicely destroyed in the "finally" clause and the main window gets unlocked.

    Matthias

  • Indeed, my do_some_work() includes a clip() operation which creates the 2nd progress bar. So it works as designed.
    Thank you very much,
    Michael

  • Very good ... :)

    Any idea why it got stuck?

    Matthias

Sign In or Register to comment.