Skip to main content

VNC Qt Widget for Python using PyQt6

Project description

pyQVNCWidget

VNC Widget for Python using PyQt6

This is a fork of zocker-160/pyQVNCWidget, which updates the package to use PyQt6 instead of PyQt5.

How to install

pip3 install qvncwidget6

TODO from pyQVNCWidget

  • 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 PyQt6.QtWidgets import QApplication, QMainWindow
from qvncwidget6 import QVNCWidget

class Window(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("QVNCWidget")

        self.vnc = QVNCWidget(
            parent=self,
            host="127.0.0.1", port=5900,
            password="1234",
            readOnly=True #, autoResize = 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, but before you
        # must specify `autoResize=True` when creating the instance
        self.vnc.onResize.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 PyQt6.QtWidgets import QApplication, QMainWindow
from qvncwidget6 import QVNCWidget

class Window(QMainWindow):
    def __init__(self):
        super().__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 PyQt6.QtWidgets import QApplication, QMainWindow
from qvncwidget6 import QVNCWidget

class Window(QMainWindow):
    def __init__(self):
        super().__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

qvncwidget6-1.0.7.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

qvncwidget6-1.0.7-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file qvncwidget6-1.0.7.tar.gz.

File metadata

  • Download URL: qvncwidget6-1.0.7.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Windows/11

File hashes

Hashes for qvncwidget6-1.0.7.tar.gz
Algorithm Hash digest
SHA256 acee4147137cadfe553268fb144273aad802ecb6519a865a931276e0ade6895f
MD5 f7f8bd930d7f861a480e8190b312b5d6
BLAKE2b-256 08c80db1595a4e1c4664ee254bd0cfbd9bf0b4088eb0cd85bbd8753621c4b470

See more details on using hashes here.

File details

Details for the file qvncwidget6-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: qvncwidget6-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Windows/11

File hashes

Hashes for qvncwidget6-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 40cfc920eaee67977e61c6646e2e117332a7c5835a4973f2a3685698fca0b6dc
MD5 17eb725ff48e50526e85c2ad754dfb1e
BLAKE2b-256 b46960a788cfd0d20054b1cfb57742d6da19c98c2f541b6597865c6cf66dbd64

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