How to use script code to open a new graph file in the currently opened nxt_editor without using the File-Open Graph menu of nxt_editor? #261
-
As the title says, I want to use script code to open an already stored .nxt file again in the current editor. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @ordinc!
|
Beta Was this translation helpful? Give feedback.
-
I would be willing to guess there's something you can do based on the fact that it's a Qt object with an object name, https://github.com/nxt-dev/nxt_editor/blob/release/nxt_editor/main_window.py#L106 Unfortunatley I don't have an example just ready to go for how to do that, but I'm pretty sure you can use qt to search for children from any widget, like your dcc's main window. Hopefully in the future I'll come back with an example graph. |
Beta Was this translation helpful? Give feedback.
-
@ImLucasBrown @MichaelAldrich I guess it should be that the new instance needs to get the object of the editor that I have opened so that I can achieve my goal and open it in the current editor instead of opening a new editor UI again. |
Beta Was this translation helpful? Give feedback.
Unfortunately this doesn't work as expected because the NXT main window isn't a singleton. Here's some code I've used in the past to do something similar to what I think you're trying to do here.
Qt knows about all the top level widgets, so if we loop over them looking for one that's an instance of the NXT MainWindow you should be able to fi…