我想在Windows上使用python和QT(PyQt)创建一些小型应用程序,并且希望将其嵌入到此应用程序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)尝试这种技巧,在这种情况下,一切正常(应用程序嵌入时没有边框/框架)
答案 0 :(得分:0)
您尝试过self.setWindowFlags(QtCore.Qt.FramelessWindowHint)