Giter Site home page Giter Site logo

ryvencore-qt's Introduction

drawing

ryvencore-qt provides Qt-based GUI classes for ryvencore, to provide a visual flow-based programming interface. The Ryven editor is built on top of ryvencore-qt, and their development is currently tightly coupled.

Installation

You need to have Python and pip installed. Then, either install from PyPI using pip:

pip install ryvencore-qt

or build from sources

git clone https://github.com/leon-thomm/ryvencore-qt
cd ryvencore-qt
pip install .

Dependencies

ryvencore-qt uses Python bindings for Qt using QtPy. I usually run it with PySide2, running on PySide6 should also work with minor changes. PyQt is not supported, due to crucial inheritance restrictions in PyQt.

Documentation

An extensive documentation doesn't currently exist.

quick start

The below code demonstrates how to set up an editor with custom defined nodes. You can also find the code in the examples folder.

main.py

# Qt
import sys
import os
os.environ['QT_API'] = 'pyside2'  # tells QtPy to use PySide2
from qtpy.QtWidgets import QMainWindow, QApplication

# ryvencore-qt
import ryvencore_qt as rc
from nodes import export_nodes


if __name__ == "__main__":

    # first, we create the Qt application and a window
    app = QApplication()
    mw = QMainWindow()

    # now we initialize a new ryvencore-qt session
    session = rc.Session()
    session.design.set_flow_theme(name='pure light')  # setting the design theme

    # and register our nodes
    session.register_nodes(export_nodes)

    # to get a flow where we can place nodes, we need to crate a new script
    script = session.create_script('hello world', flow_view_size=[800, 500])

    # getting the flow widget of the newly created script
    flow_view = session.flow_views[script]
    mw.setCentralWidget(flow_view)  # and show it in the main window

    # finally, show the window and run the application
    mw.show()
    sys.exit(app.exec_())

nodes.py

import ryvencore_qt as rc
from random import random


# let's define some nodes
# to easily see something in action, we create one node generating random numbers, and one that prints them

class PrintNode(rc.Node):
    """Prints your data"""

    title = 'Print'
    init_inputs = [
        rc.NodeInputBP(),
    ]
    init_outputs = []
    color = '#A9D5EF'

    # we could also skip the constructor here
    def __init__(self, params):
        super().__init__(params)

    def update_event(self, inp=-1):
        print(
            self.input(0)  # get data from the first input
        )


class RandNode(rc.Node):
    """Generates scaled random float values"""

    title = 'Rand'
    init_inputs = [
        rc.NodeInputBP(dtype=rc.dtypes.Data(default=1)),
    ]
    init_outputs = [
        rc.NodeOutputBP(),
    ]
    color = '#fcba03'

    def update_event(self, inp=-1):
        # random float between 0 and value at input
        val = random() * self.input(0)

        # setting the value of the first output
        self.set_output_val(0, val)


export_nodes = [
    PrintNode,
    RandNode,
]

Development

The individual subpackages have their own READMEs giving a quick overview which should be quite helpful to gain understanding about implementations.

Cheers.

ryvencore-qt's People

Contributors

amaury-anciaux avatar leon-thomm avatar sphh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ryvencore-qt's Issues

Error when connecting to dtype inputs

Hi,
I hope it is correct to report this issue here, although it occurred while using Ryven.
When connecting to a node with, for example, a dtype=dtypes.Integer(), an error can be thrown if the type of the input does not match the expectation (Integer).
While this generally makes sense, it makes building macros with one of the inputs being used in a for loop impossible. The data type of the input will be None.
When a file is saved that has one of these "illegal" connections, it also becomes impossible to open in Ryven as the error is thrown during the loading process as well and will shut down the process.

Traceback (most recent call last):
  File "C:\Users\test\.virtualenvs\Ryven\lib\site-packages\ryvencore_qt\src\FlowView.py", line 876, in add_connection

item.inp_item.port_connected()

  File "C:\Users\test\.virtualenvs\Ryven\lib\site-packages\ryvencore_qt\src\PortItem.py", line 168, in port_connected

self._port_val_updated(self.port.val)

  File "C:\Users\test\.virtualenvs\Ryven\lib\site-packages\ryvencore_qt\src\PortItem.py", line 179, in _port_val_updated

self.widget.val_update_event(val)

  File "C:\Users\test\.virtualenvs\Ryven\lib\site-packages\ryvencore_qt\src\PortItemInputWidgets.py", line 285, in val_update_event

self.setValue(val)

TypeError
:
'PySide2.QtWidgets.QSpinBox.setValue' called with wrong argument types:
  PySide2.QtWidgets.QSpinBox.setValue(NoneType)
Supported signatures:
  PySide2.QtWidgets.QSpinBox.setValue(int)

Is there a way to alert to this error but still allow for the creation of flows?

Blank screen with basic example

hi,

i am trying to run the basic example (the one from the README of this repo), but i only get a blank screen.
Screenshot 2022-01-24 at 12 34 56

any ideas about what the problem might be?
i just copy-pasted the code from the README and i don't get any errors...

thanks!

Problem with file open dialogs

Hello!

  1. All QFileDialog.getOpenFileName(), not work in my system (Manjaro) without parameter:
    options=QFileDialog.DontUseNativeDialog

  2. And I can't comment. If I find how fix I'm report.

  3. Have way to broke link between nodes? If not it feature need. Or I need it fix too...

  4. Any package may have dependencies that need to be installed, before import. May be need system for it, at least check. Or may be some another system install them with dependencies.

Thanks for macros, slider and more types default inputs, and global rework!

Support other Qt bindings

Current implementation seems only support PySide2. Will ryvencore_qt be compatible with other Qt bindings in the future, such as PyQt5?

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.