gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:38:39 26 4
gpt4 key购买 nike

我想使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com