GithubHelp home page GithubHelp logo

vvzen / pyside2-qml-examples Goto Github PK

View Code? Open in Web Editor NEW
48.0 7.0 7.0 702 KB

Collection of simple examples showcasing qml & qtquick + PySide2 & python

License: MIT License

QML 65.86% Python 34.14%
pyside2 qml qml-samples python27 threads thread-pool listview nested-structures python37 qtquick

pyside2-qml-examples's Introduction

pyside2-qml-examples

license Generic badge

There are very few examples online of QML using PySide2 as a backend, so I decided to start collecting some simple ones while I learn this technology. I think QML is a great idea that clearly separates logic from presentation, so hopefully people in VFX and Animation will start using it (instead of handling all of the .ui to .py autogenerated code madness).

I've read online about QML from people in VFX and there is a certain sentiment that it's only for creating fancy "mobile-like" experiences. In my humble opinion, they really aren't getting the big picture...

Why I think QML can be good idea..

  • I don't like looking at your 1000 lines of autogerated UI code just to get a feeling of the underneath data model

  • No need to use QtDesigner/QtCreator. Iterating a UI mockup is simple enough via qmlscene and vim, neovim, vscode, etc.

  • It makes it easier to make edits on the presentation layer without touching the python code

  • You can create components that define a certain look/behaviour and reuse them (buttons but even lists views, menu bars, etc..)

  • Yes, It's still a little bit of a PITA to use QML inside Nuke/Maya/Houdini, but things are slowly changing. In the meantime, nothing prevents you from doing standalone apps in QML, as long as you've got ways to properly package/source PySide2 (rez, conda, pip, tcl-modules, etc..)

  • If you're crazy enough and you realize in the mid of a project that you need more performance for the backend, you could potentially rewrite it in C++ and leave the frontend almost untouched

  • Great UI performance thanks to the new QtQuick Scene Graph which greatly reduces draw calls (https://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html)

  • It finally offers TreeViews and TreeModels!

..and why it's still challenging

  • You need to learn something new (pros for some, con for others)

  • There's not really a lot of huge amount of documentation for Python as a backend (but if you're here we can change that!)

  • You might find it harder to tweak some of the UI elements exactly as you'd like to

  • As a framework, it's not as old and mature as QtWidgets, so expect things to change or be deprecated between versions

FAQs

How to quickly preview some qml

This is really useful for prototyping a UI without wanting to write a main.py at all.

$ qmlscene main.qml

Ok, you convinced me. Where can I learn QtQml?

Examples

Note: The following examples have been tested under python3.7 and pyside2=5.13.2. They should also work under python2.7, but I haven't tested that

list-view

Very simple example showing how to populate a 1d list-view using a model.

list-view/list-view.png

2d-list-view

Slightly more complex example showing how to implement a basic app that uses threads and signals to perform a long blocking calculation without blocking the UI. Also shows an example of a 2d list view where each row item contains sub items.

2d-list-view/2d-list-view.png

publisher-app

Boiler-plate code that shows how you could integrate drag & drop and some parsing logic in order to fill a list view. This could be for example used as the start of an app for publishing frames

publisher-app/publisher-app.png

launcher-app

An example of an application launcher where updating a dropdown menu causes the update of the others. Uses a reusable ContextDropDown qml component that works with a standard ListModel with a custom delegate.

launcher-app/launcher-app.png

How to contribute

As always, PRs are welcome! There are different types of contributions that you could make. For now, I think that those would be nice:

Readme & docs

  • Improve the wiki! (which is empty, at the moment)
  • Improve the readme
  • Add relevant links where people can learn more about PySide2 + QML
  • Start an issue to discuss about something relevant to everybody (IE: how the heck can I use this workflow in Nuke?)

Code

  • Improving the existing examples to make it easier to follow through
  • Add more generic examples to showcase different usage scenarios (I'd love to see a Text autocompleter implemented in Qml!)
  • Check on all OS (I can only test on macOS and Centos 7.7!)
  • Write tests

pyside2-qml-examples's People

Contributors

vvzen 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyside2-qml-examples's Issues

Add a license

Please choose and add a free software license so others can use these examples. Thanks!

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.