ID 347885 - Nuke 11 missing attribute 'statusBar' exception thrown if PySide2 window is created via menu.py script on launch

Follow

Problem summary
When launching Nuke11, if a user adds a function to call a QMainWindow within their menu.py file, Nuke will throw the following exception:

​  

 

As displayed above, the exception is called because the 'PySide2.QtWidgets.QWidget' object has no attribute 'statusBar'

This does not stop Nuke running, although the Status bar will not be displayed in the bottom right.

Status bar:


If the same function ( edited imports to PySide ) is launched as a startup script within '.nuke/Python/Startup/' the script functions as expected.

Customer reported version
nuke.11.1v2

Customer reported platform
windows10

Steps to reproduce

1) Open your menu.py file ( Located in your .nuke folder ) within a Python script editor ( IDLE, PyCharm, etc.)

2) Copy/Paste the following Python script at the bottom of your file:

​if nuke.NUKE_VERSION_MAJOR >= 11: from PySide2.QtWidgets import *        from PySide2.QtGui import *        from PySide2.QtCore import *else:        from PySide.QtGui import *        from PySide.QtCore import *def get_main_window():    window_name = 'Foundry::UI::DockMainWindow'    for w in QApplication.topLevelWidgets():        if w.inherits('QMainWindow') and window_name in w.metaObject().className():            return w    return Noneclass MainWindow(QMainWindow):    def __init__(self, parent=get_main_window()):        super(MainWindow, self).__init__(parent)

3)  Save your menu.py script 

4)  Launch Nuke 11

Result: Nuke will throw the exception displayed in the summary, the Status bar will not appear after Nuke is loaded


Workaround
The example code above can be tweaked to work around the problem. The fix would be to change the MainWindow definition to the following:

class MainWindow(QMainWindow):    def __init__(self, parent=None):        parent = parent or get_main_window()        super(MainWindow, self).__init__(parent)

Reproduced by support
This bug has been reproduced in:
Nuke11.1v3 - Windows 7 - Mac10.13 - CentOS6.9
Nuke11.1v1 - Windows 7 - Mac10.13 - CentOS6.9
Nuke11.0v4 - Windows 7 - Mac10.13 - CentOS6.9
Nuke11.0v1 - Windows 7 - Mac10.13 - CentOS6.9 - Regression


Unable to reproduce bug in:
Nuke10.5v7 - Windows 7 - Mac10.13 - CentOS6.9

Earliest version tested
Nuke10.5v7 - This issue no longer appears in this version and has regressed

Expected behaviour
Nuke should launch the Qt functions without issues.

Actual behaviour
Exceptions are thrown due to Status Bar not being loaded before the menu.py is launched.
 

    We're sorry to hear that

    Please tell us why