Comments (4)
嵌入外部窗口本身就有很多问题
可以尝试
window = QWindow.fromWinId(hwnd)
widget = QWidget.createWindowContainer(window)
layout.addWidget(widget)
widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, win32con.WS_EX_TOPMOST)
#注意这里
win32gui.SetParent(hwnd, int(self.winId()))
from pyqtclient.
经过实现,效果还是还是差不多;两个窗口在一起时候 会有出现马赛克的情况,效果丝毫差不多,下面是我的代码,自己又添加一些
window = QWindow.fromWinId(hwnd1)
widget = QWidget.createWindowContainer(window)
widget.setAttribute(Qt.WA_Mapped)
widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
win32gui.SetWindowLong(hwnd1, win32con.GWL_STYLE, win32con.WS_OVERLAPPEDWINDOW)
win32gui.SetParent(hwnd1, int(self.winId()))
self.tool_view.layout().addWidget(widget)
from pyqtclient.
下面是测试Notepad记事本。暂时没有问题。至于其他软件。部分软件本身是自绘的所以闪烁很厉害。甚至不刷新
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2020/8/15
@author: Irony
@site: https://pyqt5.com , https://github.com/892768447
@email: [email protected]
@file: MdiArea
@description:
"""
import win32con
import win32gui
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QWindow
from PyQt5.QtWidgets import QApplication, QMdiArea, QWidget
class Window(QMdiArea):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
def getWindow(hwnd, _):
# 查找位置
text = win32gui.GetWindowText(hwnd)
cname = win32gui.GetClassName(hwnd)
if cname == 'Notepad':
window = QWindow.fromWinId(hwnd)
widget = QWidget.createWindowContainer(window)
widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, win32con.WS_EX_TOPMOST)
# 注意这里
win32gui.SetParent(hwnd, int(self.winId()))
self.addSubWindow(widget)
win32gui.EnumChildWindows(0, getWindow, 0)
if __name__ == '__main__':
import sys
import cgitb
cgitb.enable(1, None, 5, '')
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
from pyqtclient.
[抱歉我回复迟了,感谢你的再次回复,跑了你的例子,效果符合预期;对比自己的程序,单独显示没有问题(和你的例子略有区别,发现的程序在拉升固定大小的程序时,你的代码在程序窗口扩展部分是显示白色的,我的是显示程序背景图),经过放大/拖拉边界后,发现窗口的右边和下边,各有一部马赛克(不知道是不是和窗口在处理拖拉时预留的长宽有关,然后在拖拉后没有及时画面渲染,不良体验都是在这个位置)
from pyqtclient.
Related Issues (6)
- 内测需求 HOT 2
- 图标旋转 HOT 1
- Does it support 64-bit systems? HOT 2
- 打包成exe过程遇到问题 HOT 2
- 右边窗口创建了浏览器打开网页遇到超链接无法跳转(点击无效) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyqtclient.