fredrikaverpil / pyvfx-boilerplate Goto Github PK
View Code? Open in Web Editor NEWA boilerplate for creating PySide/PyQt or PySide2/PyQt5 applications running inside of Maya, Nuke and standalone - using Python 2 or 3.
License: MIT License
A boilerplate for creating PySide/PyQt or PySide2/PyQt5 applications running inside of Maya, Nuke and standalone - using Python 2 or 3.
License: MIT License
Add screenshots to README.
More info:
From the Qt bug tracker on QTBUG-32067:
17/Aug/15 2:17 PM: This issue is being closed because Qt 4.8.x is no longer receiving patches other than security fixes.
So it seems if you wish to have a nice Maya-looking UI in standalone mode on OS X, you need to use PyQt5 or PySide2.
Need to add the MIT license to the repository.
You're writing in your readme about this but I can't find any of that in your repo?
Quiet possibly I'm confused..
In Nuke 12, the menubar is deleted upon creation of a panel based dockable boilerplate window.
The menubar is preserved if the boilerplate is created as a modal window.
I'm able to reproduce, and the fix is to remove the menubar widget from the main_window.ui
Translate: http://www.dfx.co.jp/dftalk/?p=8177
What's the central widget of Boilerplate
right now?
Everything seems to work, but why are they setting setCentralWidget in that example?
self.ui = load_ui(uifile)
self.setCentralWidget(self.ui)
Need to investigate...
When you launch a new instance of the boilerplate, it should clean out any previous instances.
On Mac OS X, I was unable to get the floating window to always stay on top of Nuke. If you click in the main Nuke window, the floating window would disappear behind the main Nuke window.
I reached out to the Foundry:
I'm creating a simple window with PySide and I parent it to the main Nuke application. In Windows this window will always stay on top of Nuke even if I click the main Nuke window.
In OS X however (and I assume perhaps also on Linux), if I click the Nuke window, my PySide window disappears behind Nuke. Why is that and can that be fixed?
Please note, I wish to keep the fullscreen/maximize/minimize window controls, so I'm not interested in setting the window flags to either Qt.Tool or Qt.WindowStaysOnTopHint.
Regards,
Fredrikfrom PySide import QtGui, QtCore class Boilerplate(QtGui.QMainWindow): def __init__(self, parent=None): super(Boilerplate, self).__init__(parent) # Set object name and window title self.setObjectName('hello') self.setWindowTitle('hello world!') # Window type (I don't want Qt.Tool) self.setWindowFlags(QtCore.Qt.Window) # Set the main widget self.main_widget = QtGui.QLabel('Hello world!') self.setCentralWidget(self.main_widget) def _nuke_main_window(): """Returns Nuke's main window""" for obj in QtGui.qApp.topLevelWidgets(): if (obj.inherits('QMainWindow') and obj.metaObject().className() == 'Foundry::UI::DockMainWindow'): return obj else: raise RuntimeError('Could not find DockMainWindow instance') my_window = Boilerplate(parent=_nuke_main_window()) my_window.show() # Show the UI
This was the response from The Foundry:
This is really difficult to solve unfortunately. The Qt documentation for QWidget says that parenting a window to another will make it float above the other window, but the documentation is wrong and the behaviour is dependent on the window management policy for your platform. Having a floating window which doesn't get hidden when the application goes to the background is deemed un-Mac-like behaviour and not allowed. The only ways to get windows to float are to use Qt.Tool or Qt.WindowStaysOnTopHint which both have problems. In particular, Qt.WindowStaysOnTopHint makes the window stay on top of all windows even when the application is in the background. Nuke gets round this problem by manipulating the Qt.WindowStaysOnTopHint during application activation and deactivation, but to do this correctly requires writing Objective-C code and can't be done from Python (the equivalent Qt events don't get delivered at the correct time for this).
Possible solutions are:
Use Qt.Tool (I know this has already been dismissed, but it's here for completeness. Nuke does make sure that Qt.Tool windows don't get hidden when the application is deactivated, but you do lose the maximize/minimize buttons
Use the Nuke APIs to register the window as a panel, This will allow the window to be docked but also make it float correctly. I'm not sure if it solves the maximize/minimize buttons though.
So, as a workaround, the boilerplate is now setting the windows flag Qt.Tool
, as I believe this a bit better than setting Qt.WindowStaysOnTopHint
.
Unfortunately, there seems to be no way around this as for now.
Hi,
I've made a cookiecutter version, check it out:
cookiecutter-pyvfx-boilerplate
This is really a copy paste of yours with minor updates and cookiecutterized.
I'll try to ehance it further but the workflow to code cookiecutters is not ideal, at least I haven't found an efficient workflow yet.
Thanks for the base.
Due to the fact that Nuke 10.0v1 for OS X is missing PySide.QtUiTools
, the boilerplate won't work in that environment if you load .ui files via convenience function Qt.load_ui
.
I've requested that The Foundry include PySide.QtUiTools
with Nuke 10 on OS X, as it is included in Nuke 10.0v1 for Windows and Linux.
I will keep this issue open until this has been resolved in a future Nuke version.
Latest version checked which exhibits this issue: 10.5v1
Additional elements needs to be styled.
When pressing the escape key, one would expect the window to close. Currently however, it causes the contents of the window to close, but the window remains open.
I have tried both defining the eventFilter, which picks up keypresses, but not escape, and overriding keyPressEvent, which has the same behaviour as eventFilter.
class Boilerplate(QtWidgets.QMainWindow):
def __init__(self, parent=None):
...
self.installEventFilter(self)
def eventFilter(self, widget, event):
if event.type() == QtCore.QEvent.KeyPress:
print 'press'
if event.key() == QtCore.Qt.Key_Escape:
print 'escape'
return super(Boilerplate, self).eventFilter(widget, event)
class Boilerplate(QtWidgets.QMainWindow):
def __init__(self, parent=None):
...
self.keyPressEvent = self.newKeyPressEvent
def newKeyPressEvent(self, event):
print 'press'
if event.key() == QtCore.Qt.Key_Escape:
print 'escape'
self.close()
Hi,
thanks a lot for the boilerplate, it has been very useful !
I got an issue though. My panel is over 500px high and when i launch it as a panel in nuke half of is hidden. Meaning only the top half is visible, even if my nuke panel is big enough.
It is a strange bug and i don't know where it's coming from. When i use the pyside example from nuke the panel looks fine and display all the way down.
Did you experienced something similar ?
In v1.0, the maya palette was implemented inside of the boilerplate which caused the file to gain ~100 rows of code. For v2.x, it would be better to put this code outside of the boilerplate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.