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

Question about 'viewer.plot()' and 'input()' in example tri2Dinput.py #947

Open
CalebDmArcher opened this issue Sep 11, 2023 · 5 comments
Open

Comments

@CalebDmArcher
Copy link

CalebDmArcher commented Sep 11, 2023

The example code contains the following two lines
viewer.plot()
input("finished")

If comment out input("finished"), the plot will pop out and automatically close.
If keep input("finished"), the plot stays but the plot window crashes (not responding).

Can anyone help me with this issue to keep the plot window open and not crash?
Can you also explain what exactly this 'input' function does? (The source code is too complex for me to understand.)

@guyer
Copy link
Member

guyer commented Sep 11, 2023

The purpose of the input() is to display the string as a prompt and wait for keyboard input, i.e., hit return or enter. We use it to pause the program so you can see the plot.

As to the crash or non-response, please tell us what example you're talking about.

@CalebDmArcher
Copy link
Author

CalebDmArcher commented Sep 11, 2023

Thank you for your fast response. I was trying /examples/diffusion/steadyState/mesh1D/tri2Dinput.py and /examples/diffusion/steadyState/mesh20x20/tri2Dinput.py. Both of them have viewer. plot() and input("finished").
I tried the code by using PyCharm and the terminal. Both cases have the 'not responding' issue.
I also tried to debug by placing a pause point at the line of viewer. plot(). The plot works fine (it shows up and not crashing).
However, if continue running (running input("finished")), the text 'finished' will be printed in the console, and the plot window freeze with showing not responding.

(Usually, I used plt.show() to keep the plot window open and not crashing.
Not sure how to do a similar thing with 'viewer'.)
notres

@guyer
Copy link
Member

guyer commented Sep 11, 2023

And if you press return?

Have you run examples/diffusion/mesh1D.py? That's where we expect people to start.

@CalebDmArcher
Copy link
Author

And if you press return?

Have you run examples/diffusion/mesh1D.py? That's where we expect people to start.

If I press return, the program terminates (plot window closes) with 'Process finished with exit code 0'.

I haven't tired examples/diffusion/mesh1D.py yet. Thank you for sharing this resource.

@guyer
Copy link
Member

guyer commented Sep 11, 2023

If I press return, the program terminates (plot window closes) with 'Process finished with exit code 0'.

That's as expected

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

No branches or pull requests

2 participants