-
Notifications
You must be signed in to change notification settings - Fork 20
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
450f322
Create console panel
trungleduc 839a749
wip
trungleduc 898f84f
add console to tracker
trungleduc d981768
Load document on console startup
trungleduc 68b170a
Add toolbar
trungleduc 3d7594f
Remove banner
trungleduc 2809058
Add UI test
trungleduc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './mainview'; | ||
export * from './mainviewwidget'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ReactWidget } from '@jupyterlab/apputils'; | ||
import * as React from 'react'; | ||
|
||
import { MainView } from './mainview'; | ||
import { MainViewModel } from './mainviewmodel'; | ||
|
||
export class JupyterCadMainViewPanel extends ReactWidget { | ||
/** | ||
* Construct a `JupyterCadPanel`. | ||
* | ||
* @param context - The documents context. | ||
*/ | ||
constructor(options: { mainViewModel: MainViewModel }) { | ||
super(); | ||
this._mainViewModel = options.mainViewModel; | ||
this.addClass('jp-jupytercad-panel'); | ||
} | ||
|
||
render(): JSX.Element { | ||
return <MainView viewModel={this._mainViewModel} />; | ||
} | ||
|
||
private _mainViewModel: MainViewModel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { ConsolePanel } from '@jupyterlab/console'; | ||
import { ServiceManager } from '@jupyterlab/services'; | ||
import { BoxPanel, Widget } from '@lumino/widgets'; | ||
import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; | ||
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor'; | ||
import { debounce } from '../tools'; | ||
import { | ||
closeIcon, | ||
CommandToolbarButton, | ||
expandIcon, | ||
Toolbar | ||
} from '@jupyterlab/ui-components'; | ||
import { CommandRegistry } from '@lumino/commands'; | ||
|
||
export class ConsoleView extends BoxPanel { | ||
constructor(options: ConsoleView.IOptions) { | ||
super({ direction: 'top-to-bottom' }); | ||
this.addClass('jpcad-console'); | ||
const { manager, contentFactory, mimeTypeService, rendermime } = options; | ||
const clonedRendermime = rendermime.clone(); | ||
this._consolePanel = new ConsolePanel({ | ||
manager, | ||
contentFactory, | ||
mimeTypeService, | ||
rendermime: clonedRendermime, | ||
kernelPreference: { name: 'python3', shutdownOnDispose: true } | ||
}); | ||
this._consolePanel.console.node.dataset.jpInteractionMode = 'notebook'; | ||
this.addWidget(this._consolePanel); | ||
BoxPanel.setStretch(this._consolePanel, 1); | ||
|
||
this._consolePanel.toolbar.addItem('spacer', Toolbar.createSpacerItem()); | ||
|
||
this._consolePanel.toolbar.addItem( | ||
'toggle', | ||
new CommandToolbarButton({ | ||
label: '', | ||
icon: expandIcon, | ||
id: 'jupytercad:toggleConsole', | ||
commands: options.commandRegistry | ||
}) | ||
); | ||
this._consolePanel.toolbar.addItem( | ||
'close', | ||
new CommandToolbarButton({ | ||
label: '', | ||
icon: closeIcon, | ||
id: 'jupytercad:removeConsole', | ||
commands: options.commandRegistry | ||
}) | ||
); | ||
} | ||
|
||
get consolePanel() { | ||
return this._consolePanel; | ||
} | ||
|
||
dispose(): void { | ||
if (this.isDisposed) { | ||
return; | ||
} | ||
this._consolePanel.dispose(); | ||
super.dispose(); | ||
} | ||
execute() { | ||
this._consolePanel.console.execute(false); | ||
} | ||
|
||
protected onResize(msg: Widget.ResizeMessage): void { | ||
super.onResize(msg); | ||
this._resize(); | ||
} | ||
private _consolePanel: ConsolePanel; | ||
private _resize = debounce(() => { | ||
window.dispatchEvent(new Event('resize')); | ||
}, 200); | ||
} | ||
|
||
export namespace ConsoleView { | ||
export interface IOptions { | ||
manager: ServiceManager.IManager; | ||
contentFactory: ConsolePanel.IContentFactory; | ||
mimeTypeService: IEditorMimeTypeService; | ||
rendermime: IRenderMimeRegistry; | ||
commandRegistry: CommandRegistry; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './consoleview'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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