python - PyQt 将 PuTTY/KiTTY 嵌入到应用程序中 - 无法删除边框

标签 python pyqt putty hwnd

我想使用 python 和 QT (PyQt) 在 Windows 上创建一些小应用程序,并且我想嵌入到这个应用程序 ssh 控制台中。我尝试使用 PuTTY 和 KiTTY,但我根本无法删除边框(WS_BORDER 、 WS_CAPTION)。

exePath = "putty.exe sample_login@sample_host"
subprocess.Popen(exePath) # Run SSH Putty session
time.sleep(1)

hwnd = win32gui.FindWindowEx(0, 0, None, "sample_host - PuTTY") # Get hwnd of started putty 
style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)

print("hwnd ",hwnd)
print("style ", style)
style = style - int(win32con.WS_CAPTION) - int(win32con.WS_THICKFRAME)
print("style after ", style)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style) # Apply modified style to Putty windidow

# Here my Putty windows looks exacly what I want - it show only SSH console and scroolbar, without titlebar, close button, frame, border etc.


self.window = QWindow.fromWinId(hwnd)
self.widget = QWidget.createWindowContainer(self.window, self)
self.widget.resize(600, 600)
self.widget.move(50, 50)

self.setGeometry(100, 100, 900, 900)
self.setWindowTitle('Putty test')
self.show()

# Here my Putty windows was already appended to PyQt app, but border / frame  was appear.

我尝试混合一些 Windows 风格,但我无法实现这一点。 我还尝试使用其他一些应用程序(例如记事本或 Windows calc)来尝试此技巧,在这种情况下一切正常(应用程序嵌入时没有边框/框架)

下面是我嵌入 Putty 之前和之后的情况屏幕。 我尝试在嵌入窗口(仅显示控制台)后实现左侧的情况。 enter image description here

最佳答案

你尝试过self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

关于python - PyQt 将 PuTTY/KiTTY 嵌入到应用程序中 - 无法删除边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53069443/

相关文章:

python - 在 pyqt 上显示图像

python - 从连接到 QML 的 PyQt5 打开文件对话框

linux - 使用 awk 计算数字的平均值

无法在腻子中正确显示十六进制值

python - 遍历响应并通过 Python 获取值

python - 如何在 python 中使用 pytest 使用 json 数组测试数据参数化测试?

python - 从搜索模式中排除空格

python - PyQt5:如何在QMessageBox中显示列表?类型错误:参数 3 具有意外类型 'list'

windows - 无法从 Windows ssh 登录到 ubuntu

python - Python 中的浮点相等处理