Status bar messages to indicate rendering and viewing progress
since the application doesn't look visually different when it is rendering/drawing and when you can interact with it, I think it would be useful if there was some way to determine if CQ-Editor is currently busy at a glance. The status bar isn't currently being used for anything so I used that to display messages:
time.sleep(1.5) # to simulate a long running script
sphere = cq.Workplane('XY').move(6, 6).sphere(3)
loft = cq.Workplane('XY').ellipse(5, 7).workplane(5).circle(4).workplane(5).ellipse(7, 5).loft()
box = cq.Workplane('XY').move(-8, -2).box(3, 4, 2)
show_object(loft, 'my_loft')
show_object(sphere, 'my_sphere')
show_object(box, 'my_box')
https://user-images.githubusercontent.com/4923501/108626297-4c81b100-7447-11eb-806c-0af038f160d2.mp4
It seems to be because I'm calling QApplication.processEvents() inside set_status_message() some unit tests are failing. This is currently required for the status messages to be visible as rendering blocks the main thread.
In the test_console() unit test from master (which passes) if I insert these two lines:
# test print_text
pos_orig = console._prompt_pos
console.print_text('a')
+ from PyQt5.QtWidgets import QApplication
+ QApplication.processEvents()
assert(console._prompt_pos == pos_orig + len('a'))
then the test fails because the prompt is printed
print(repr(console._control.document().toPlainText()))
'a\n\nIn [1]: \n\nIn [2]: '
and with processEvents called inside set_status_message the content is: '\nIn [1]: a'
Any advice on how best to handle this? should I update the unit tests or find another workaround (not that I can think of any)