Giter VIP home page Giter VIP logo

pyqvncwidget's Introduction

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

pyqvncwidget's People

Contributors

ken3 avatar p0ssi avatar zach-iglu avatar zocker-160 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyqvncwidget's Issues

Issue when connecting with RealVNC Server of Raspberry Pi

Hope you're fine.
I'm trying to connect to a sever(it's on raspberry pi) but I need to login with username and password but couldn't find how to do it.
trying with password only will give this exception:
qvncwidget.rfb.RFBHandshakeFailed: b'No configured security type is supported by 3.3 VNC Viewer'

adjust quality and such

Could you give me a pointer on how to adjust the quality of the transferred data?
Best regards!

Connection to a PLC not possible

I tried to run the example code, but the window remains black. Do you have any ideas what the problem could be?

[QVNCWidget]` DEBUG: backbuffer is None
[RFB Client <-] DEBUG: len: 12 | b'RFB 003.003\n'
[RFB Client] INFO: RFB from server: 3.3
[RFB -> Server] DEBUG: b'RFB 003.003\n'
[RFB Client] INFO: VNC connected
[RFB Client <-] DEBUG: len: 4 | b'\x00\x00\x00\x01'
[RFB -> Server] DEBUG: b'\x01'
[RFB Client <-] DEBUG: len: 24 | 
```b'\x02\x80\x01\xe0\x08\x08\x00\x00\x00\x07\x00\x07\x00\x03\x00\x03\x06\x00\x00\x00\x00\x00\x00\x11'
[RFB Client <-] DEBUG: len: 17 | b"VC Project 'Visu'"
[RFB Client] DEBUG: Connecting to "VC Project 'Visu'"
[RFB Client] DEBUG: Server Pixelformat: 8;8;0;0;7;7;3;0;3;6
[RFB Client] DEBUG: Resolution: 640x480
[RFB -> Server] DEBUG: b'\x02\x00\x00\x01'
[RFB -> Server] DEBUG: b'\x00\x00\x00\x00'
[QVNCWidget] INFO: VNC handshake done
[RFB -> Server] DEBUG: b'\x00\x00\x00\x00  \x00\x01\x00\xff\x00\xff\x00\xff\x10\x08\x00\x00\x00\x00'
[RFB -> Server] DEBUG: b'\x03\x00\x00\x00\x00\x00\x02\x80\x01\xe0'
Exception in thread Thread-1 (__start):
Traceback (most recent call last):
  File "C:\Users\test\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Users\test\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 108, in __start
    self._handleInitial()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 148, in _handleInitial
    self._handleAuth33(self.__recv(4))
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 163, in _handleAuth33
    self._doClientInit()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 173, in _doClientInit
    self._handleServerInit(self.__recv(24))
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 200, in _handleServerInit
    self._mainRequestLoop()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 269, in _mainRequestLoop
    self.onFatalError(e)
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 482, in onFatalError
    raise error
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 251, in _mainRequestLoop
    dType = self.__recv(1)
            ^^^^^^^^^^^^^^
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 92, in __recv
    buffer = self.connection.recv(expectedSize, socket.MSG_WAITALL)    
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [WinError 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
[RFB Client] DEBUG: Closing connection

Process finished with exit code 0`

need a few more examples

I'm very interested in this widget. I want to send mouse/key events to the vnc server.
I see RFBClient class has keyEvent() and pointerEvent() methods, but I don't know how to get the RFBClient instance from my application.
Cloud you help me?

Problems running with TigerVNC

I'm trying to execute the widget with TigerVNC and it is not working.

I set my vncserver with the following command:

vncserver -depth 24 :1

Then I launch the example1.py and I get the following screen:

image

The connection is established and the VNC screen is showing on the screen. But only on the white line of the dialog.

Can you advise me on how to have this working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.