Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status bar messages to indicate rendering and viewing progress #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mbway
Copy link
Contributor

@mbway mbway commented Feb 21, 2021

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')
statusbar.mp4

@mbway
Copy link
Contributor Author

mbway commented Feb 21, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant