Coder Social home page Coder Social logo

qtside's Introduction

QtSide

Wrap PyQt4 PyQt5 PySide PySide2 together.

INSTALLATION

  1. Download the latest release and unzip to a folder with the name 'QtSide' where you want to live.
  2. Add parent folder to the PYTHONPATH env var.

HOW DOES IT WORK

QtSide replaces itself with whatever Python binding is available (or preferred) in the Python environment your script runs in. However, QtSide will first take care of remappings of calls so that the Qt5 style syntax of PySide2 will work even if you run this code in an environment with a Python binding for Qt4.

Environment variables.

  • QT_SIDE_BINDING
  • QT_SIDE_PYQT4_DIR
  • QT_SIDE_PYQT5_DIR
  • QT_SIDE_PYSIDE_DIR
  • QT_SIDE_PYSIDE2_DIR

Before open your custom apps or vfx-dccs, you need to set these environment variable first.

  • You need tell QtSide which binding to prefer by setting the QT_SIDE_BINDING environment variable.
  • You need tell QtSide prefer-binding's folder locations by setting the QT_SIDE_*_DIR environment variable.

For example:

Maya 2016 with PyQt4
- linux:
    export QT_SIDE_BINDING=pyqt4
    export QT_SIDE_PYQT4_DIR=/mnt/mount/lib/pyqt4_parent_folder  # ignore this if PyQt4 package already exists in PYTHONPATH/sys.path
- windows:
    set QT_SIDE_BINDING=pyqt4
    set QT_SIDE_PYQT4_DIR=c:/mount/lib/pyqt4_parent_folder  # ignore this if PyQt4 package already exists in PYTHONPATH/sys.path

Maya 2016 with PySide
- linux:
    export QT_SIDE_BINDING=pyside
- windows:
    set QT_SIDE_BINDING=pyside

Maya 2017 with PyQt5
- linux:
    export QT_SIDE_BINDING=pyqt5
    export QT_SIDE_PYQT5_DIR=/mnt/mount/lib/pyqt5_parent_folder  # ignore this if PyQt5 package already setted into PYTHONPATH or sys.path
- windows:
    set QT_SIDE_BINDING=pyqt5
    set QT_SIDE_PYQT5_DIR=c:/mount/lib/pyqt5_parent_folder  # ignore this if PyQt5 package already setted into PYTHONPATH or sys.path

Maya 2017 with PySide2
- linux:
    export QT_SIDE_BINDING=pyside2
- windows:
    set QT_SIDE_BINDING=pyside2

USAGE

For those of you new to Qt5 (and PySide2 or PyQt5), all widget classes of QtGui were moved into its own module called QtWidgets. I had to say this is one of the largest backwards compatibility breaking changes you will have to deal with when changing existing scripts to use QtSide.

import sys
from QtSide import QtWidgets, QtGui, QtCore
app = QtWidgets.QApplication(sys.argv)
button = QtWidgets.QPushButton('Hello World')
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(True)
button.setFont(font)
button.setMinimumSize(QtCore.QSize(0, 22))
button.setMaximumSize(QtCore.QSize(168, 22))
button.show()
app.exec_()
# VFX DCC - Maya
from QtSide import QtWidgets, ui_wrapper
import maya.OpenMayaUI as OpenMayaUI
connector = ui_wrapper.wrapinstance(
    long(OpenMayaUI.MQtUtil.mainWindow()),
    QtWidgets.QMainWindow
)

qtside's People

Contributors

astips avatar

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.