Skip to content
Discussion options

You must be logged in to vote

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.

from nxt_editor.main_window import MainWindow
from Qt import QtWidgets

qapp = QtWidgets.QApplication.instance()
if not qapp:
    raise Exception('No qapp found! Is nxt open?')
windows = qapp.topLevelWidgets()
for win in windows:
    if isinstance(win, MainWindow):
        nxt_window = win
        break
else:
    raise Exception('No nxt window found')

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…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@ordinc
Comment options

@ImLucasBrown
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ImLucasBrown
Comment options

Answer selected by ordinc
@ordinc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants