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

Add python console to 3D view #392

Merged
merged 7 commits into from
Aug 22, 2024
Merged

Conversation

trungleduc
Copy link
Member

@trungleduc trungleduc commented Jul 30, 2024

User-facing changes

  • New toolbar button to open the python console
  • The JCAD document is loaded automatically into the doc variable
jcad222.mp4

Code changes

  • The main view is now a split panel instead of a panel

Copy link
Contributor

Binder 👈 Launch a Binder on branch trungleduc/jupytercad/console

@martinRenou
Copy link
Member

Cross referencing with geojupyter/jupytergis#41 where we discussed with David about potentially saving the state of the console

@trungleduc
Copy link
Member Author

trungleduc commented Jul 31, 2024

What is the benefit of keeping the console state in the document? The python APIs modify the document directly, so you would not want to re-run the API calls once they are applied

@martinRenou
Copy link
Member

I figured it was nice to see the history of executed code to see how the file was modified/what data was loaded etc.

I've not played so much with the console in tools like blender/freecad, do they not store the history?

Not storing the history makes life simpler so if the benefit is small, let's not do it.

@trungleduc
Copy link
Member Author

I figured it was nice to see the history of executed code to see how the file was modified/what data was loaded etc.

But if you re-execute these codes, you might mess up your CAD document since their effects are already applied to the doc.

I've not played so much with the console in tools like blender/freecad, do they not store the history?

Nope, but their GUI is basically a shortcut to call Python APIs, so you can translate your GUI working session into a Python script.

@trungleduc trungleduc marked this pull request as ready for review August 21, 2024 16:04
@trungleduc trungleduc requested a review from martinRenou August 21, 2024 16:04
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

For a future PR, we may want to use the StateDB to store the state of the console in the main view (open/close, expanded/hidden)

render(): React.ReactNode {
return (
<div className="jpcad-toolbar-usertoolbar">
{this.state.usersList.map(item => {
{this.filterDuplicated(this.state.usersList).map(item => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I've seen this issue once indeed when using the Python API next to the main view

@martinRenou martinRenou merged commit 67ab7fb into jupytercad:main Aug 22, 2024
10 checks passed
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.

2 participants