-
Notifications
You must be signed in to change notification settings - Fork 25
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
possible option to remove window wrap need #66
Comments
(testing in krita to have access to lots of qt widgets setup) from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtCore import Qt
for widget in QApplication.topLevelWidgets():
if widget.windowTitle() and widget.windowFlags() & Qt.Window:
print(widget, widget.windowTitle(), widget.window().window()) |
possible option 2: |
Would love to hear more about this, getting a bunch of bugs because of the wrapping. From what I can see (although I may be wrong) the only reason we do it is to allow the Qt window to be parented to the Blender window, allowing us to minimise the Blender window and the widget at the same time. |
Could you make a separate issue for each bug? Would help a lot addressing them |
also for your awareness. |
That's good to know, although we're looking to keep that focus unfortunately |
❌ I can show the qwidget in a sep window. not parented to blender. import sys
import ctypes
# import multiprocessing as mp
from PySide2.QtWidgets import QApplication, QWidget
def run_widget(handle):
app = QApplication.instance()
exec = False
if not app:
app = QApplication(sys.argv)#
exec = True
widget = QWidget()
widget.show()
if exec:
app.exec_()
user32 = ctypes.windll.user32
# def set_tool_window(hwnd):
# GWL_EXSTYLE=-20
# WS_EX_TOOLWINDOW=0x00000080
# user32.SetWindowLongPtrW(widget.winId(), GWL_EXSTYLE, WS_EX_TOOLWINDOW)
# this line makes the widget dissapear instantly.
user32.SetParent(widget.winId(), handle)
return widget
def do():
import bqt.blender_applications.win32_blender_application as win
blender_hwnd = win.get_blender_window()
#p = mp.Process(target=run_widget, args=(blender_hwnd,))
#p.start()
return run_widget(blender_hwnd) |
the floatingwindows.py script contains various ctypes methods that might prove usefull. #dupplicate into new windows
bpy.ops.screen.area_dupli('INVOKE_DEFAULT')
new_window = bpy.context.window_manager.windows[-1]
area = new_window.screen.areas[-1]
space_data = bpy.context.space_data |
❌ bpy.ops.wm.window_new() creates a new window, can we wrap this in qt. and do that for each widget we show? played around with some wrapping. but feels a bit hacky def da():
app = QApplication.instance()
exec = False
if not app:
app = QApplication(sys.argv)#
exec = True
bpy.ops.wm.window_new()
user32 = ctypes.windll.user32
win_h = user32.GetActiveWindow()
print("new window", win_h)
# set title, # todo doesnt work reliable
user32.SetWindowTextW(win_h, "Plugget Qt Manager")
blender_window = QWindow.fromWinId(win_h) # also sets flag to Qt.ForeignWindow
blender_widget = QWidget.createWindowContainer(blender_window)
blender_widget.show()
# tool window
widget = QWidget(blender_widget)
widget.setWindowFlags(widget.windowFlags() | Qt.Tool)
widget.show()
if exec:
app.exec_()
return widget, blender_widget, blender_window |
❌ errors, What if we use shiboken wrap? think this might allow to parent qwidgets to blender window without wrapping blender in a qwidget.
asked the AI, not sure how accurate
import ctypes
import shiboken2
from PyQt5.QtWidgets import QWidget
win_h = ctypes.windll.user32.GetActiveWindow() # Get the window handle for the active window
win_ptr = ctypes.windll.user32.GetWindowLongPtrW(win_h, ctypes.c_int(0)) # Get the pointer to the window
win_obj = shiboken2.wrapInstance(win_ptr, QWidget) # Wrap the pointer in a Python object
print(isinstance(win_obj, QWidget)) # Check |
parenting a new blender window to blender main window with ctypes works, but is really buggy. |
✅ this could be doable:
import ctypes
user32 = ctypes.windll.user32
w = user32.GetActiveWindow() if blender is active, bring the blender_widget to foreground. set flag always on top? event loop could be in blender, but ideally event loop would be in qt. using e.g. qttimers. e.g. anim_bar |
Using our own manager seems to work quite well. we'd need to create some kind of "register/wrap widget" method, to add the widget to our manager. custom widget focus manager:
PROS
CONS
Other
|
this has gone in with https://github.com/techartorg/bqt/releases/tag/1.1.0 created new issue to clarify this process in code and docs #80 |
interesting to note that this approach would not only work in Blender, but any software that can run python. |
right now we wrap blender in a qt window. this is the source of all our current issues.
unsure if context overrider for operators run from qt would be solved if not wrappedinvestigated, it doesn't solve #62
parent widgets to blender with ctypes
using ctypes on our widget windows might solve the parenting instead
https://blenderartists.org/t/floating-windows/1163493/317
wrap widgets in a window managed by blender
Can we either extend Blender source code, creating an official PR in the blender repo to support empty windows.
Or investigate what we already can do with the current exposed Python code.
auto parent widgets
Moved this to it's own issue #71
The text was updated successfully, but these errors were encountered: