mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 11:02:04 +08:00
初步的虚拟机vnc连接
This commit is contained in:
44
novnc-client/main.py
Normal file
44
novnc-client/main.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import sys
|
||||
import logging
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow
|
||||
from qvncwidget import QVNCWidget
|
||||
#logging.basicConfig(level=logging.DEBUG) # DEBUG及以上的日志信息都会显示
|
||||
class Window(QMainWindow):
|
||||
def __init__(self):
|
||||
super(Window, self).__init__()
|
||||
|
||||
self.setWindowTitle("QVNCWidget")
|
||||
|
||||
self.vnc = QVNCWidget(
|
||||
parent=self,
|
||||
host="127.0.0.1", port=5905,
|
||||
readOnly=False
|
||||
)
|
||||
|
||||
self.setCentralWidget(self.vnc)
|
||||
|
||||
# you can disable mouse tracking if desired
|
||||
self.vnc.setMouseTracking(True)
|
||||
self.setAutoFillBackground(True)
|
||||
|
||||
|
||||
self.vnc.start()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
self.vnc.keyPressEvent(ev)
|
||||
return super().keyPressEvent(ev) # in case you need the signal somewhere else in the window
|
||||
|
||||
def keyReleaseEvent(self, ev):
|
||||
self.vnc.keyReleaseEvent(ev)
|
||||
return super().keyReleaseEvent(ev) # in case you need the signal somewhere else in the window
|
||||
|
||||
def closeEvent(self, ev):
|
||||
self.vnc.stop()
|
||||
return super().closeEvent(ev)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.resize(800, 600)
|
||||
window.show()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
Reference in New Issue
Block a user