Skip to main content

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


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.5.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qvncwidget-0.3.5-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file qvncwidget-0.3.5.tar.gz.

File metadata

  • Download URL: qvncwidget-0.3.5.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic

File hashes

Hashes for qvncwidget-0.3.5.tar.gz
Algorithm Hash digest
SHA256 d2bf7d1b68d4fa9af5b5271dc395c06c90d1db0bc43a76ef45ffaa14cf51e18f
MD5 a3ffaaccdbb18cd72cb15ea859a3128f
BLAKE2b-256 2909addfdb9b20e58233dc7c97be26b0065729f1048d9c9ff0680b900935a4ec

See more details on using hashes here.

File details

Details for the file qvncwidget-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: qvncwidget-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic

File hashes

Hashes for qvncwidget-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c3d1bf865b728977d4cb815d2d908a454cf4d6f8f88378093b885bc1530e8073
MD5 79f3bbbcdbc2ee7873793dd124f275db
BLAKE2b-256 673ade895aa226b8e56b0c8d734e0b8103cf7f8737cd947296528ccb79978fdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page