我想使用 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)来尝试此技巧,在这种情况下一切正常(应用程序嵌入时没有边框/框架)
最佳答案
你尝试过self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
关于python - PyQt 将 PuTTY/KiTTY 嵌入到应用程序中 - 无法删除边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53069443/