VNC QT Widget for Python using PyQt5
Project description
pyQVNCWidget
VNC Widget for Python using PyQt5
How to install
pip3 install qvncwidget
TODO:
- Proper error handling
onFatalError
- support for more than just RAW and RGB32 PIXEL_FORMATs
- support for compression
- implement rfb 3.7 and 3.8
- implement local and remote clipboard
Examples (see /examples folder)
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from qvncwidget import QVNCWidget
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setWindowTitle("QVNCWidget")
self.vnc = QVNCWidget(
parent=self,
host="127.0.0.1", port=5900,
password="1234",
readOnly=True
)
self.setCentralWidget(self.vnc)
# if you want to resize the window to the resolution of the
# VNC remote device screen, you can do this
self.vnc.onInitialResize.connect(self.resize)
self.vnc.start()
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_())
Example with widget input events
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from qvncwidget import QVNCWidget
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setWindowTitle("QVNCWidget")
self.vnc = QVNCWidget(
parent=self,
host="127.0.0.1", port=5900,
password="1234",
readOnly=False
)
self.setCentralWidget(self.vnc)
# we need to request focus otherwise we will not get keyboard input events
self.vnc.setFocus()
# you can disable mouse tracking if desired
self.vnc.setMouseTracking(False)
self.vnc.start()
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_())
Example with window input events
In this example we are passing input events from the window to the widget
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from qvncwidget import QVNCWidget
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setWindowTitle("QVNCWidget")
self.vnc = QVNCWidget(
parent=self,
host="127.0.0.1", port=5900,
password="1234",
readOnly=False
)
self.setCentralWidget(self.vnc)
# you can disable mouse tracking if desired
self.vnc.setMouseTracking(False)
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_())
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qvncwidget-0.3.4.tar.gz
(25.3 kB
view hashes)
Built Distribution
qvncwidget-0.3.4-py3-none-any.whl
(26.5 kB
view hashes)
Close
Hashes for qvncwidget-0.3.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfc17507f37a6d9b863cdf6927c37e24dd1f79c664d3a6b2c53ce5fad24752e8 |
|
MD5 | 7ba0fde1f527645a91fe6df602f895b8 |
|
BLAKE2b-256 | d550e4c5127b49b7bd0bda59cb851f4be0f941d087e91355a274140b3dbc6e7f |