Skip to content
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

Parent window to host #1

Closed
mottosso opened this issue Nov 13, 2014 · 4 comments
Closed

Parent window to host #1

mottosso opened this issue Nov 13, 2014 · 4 comments
Labels

Comments

@mottosso
Copy link
Member

Currently, the GUI is launched as a separate window, but we'd like it to appear as though it was a child of to the host.

This may require OS-specific commands.

On Windows, SetParent seems the obvious winner, though it seems to have some warts.

Something like this ought to do it for Maya on Windows.

from PySide import QtGui

widgets = dict((w.objectName(), w) for w in QtGui.QApplication.topLevelWidgets())
window = widgets['MayaWindow']
id = window.winId()

import ctypes
ctypes.pythonapi.PyCObject_AsVoidPtr.restype = ctypes.c_void_p
ctypes.pythonapi.PyCObject_AsVoidPtr.argtypes = [ctypes.py_object]

int_hwnd = ctypes.pythonapi.PyCObject_AsVoidPtr(id)

If a similar feature is available in Linux distributions (Wayland?) then that's where we'll go.

@tokejepsen
Copy link
Member

+1 for parenting to host:)

@ghost
Copy link

ghost commented Nov 18, 2014

+1 as it is really annoying when your tools hide behind the main Maya window (or any other application that you might be using).

@mottosso
Copy link
Member Author

Some thoughts on a potential solution to this.

I'm reluctant to try physically parenting the window to another process due to having read scare stories about it on the interwebs.

As an alternative, I'm thinking it may be more safe and equally user-friendly to simply introspect the external process, like it's current minimized state, size and position, and mirror this for our GUI.

The experience should be identical, but without the pitfalls of physical parenting.

Implementation

We can get the HWND from a host via QWidget.winId(). With that, we can poll for changes, such as whether or not the window has been minimized, moved or resized.

http://docs.activestate.com/activepython/3.2/pywin32/win32gui.html

We'll use this information in the GUI code to "monkey do, monkey say".

Another advantage of this approach is that we're safe from hosts crashing and vice versa; our app can't cause a host to crash. We can also choose to "detach" should be want our GUI to remain open during e.g. long running publishes.

@mottosso mottosso mentioned this issue Mar 1, 2015
mottosso pushed a commit that referenced this issue Apr 2, 2016
Add some flare to action icon
BigRoy referenced this issue in BigRoy/pyblish-qml Apr 27, 2016
Continuing on from PR to pyblish/pyblish-qml pyblish#181
mottosso pushed a commit that referenced this issue May 18, 2016
Added data files and metadata
mottosso pushed a commit that referenced this issue Jun 2, 2016
Consider inactive collectors
@mottosso
Copy link
Member Author

Implemented in #259

mottosso pushed a commit that referenced this issue Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants