Re: [vfx-platform-discuss] Qt.py

396 views
Skip to first unread message

Marcus Ottosson

unread,
Jan 25, 2017, 9:28:25 AM1/25/17
to vfx-platform-discuss, python_in...@googlegroups.com

Qt.py and safety

Hi community,

Today we’ve made a significant leap forwards for Qt.py and implemented a guarantee where if your program runs with Qt.py and any binding, such as PySide2, it will run in an identical fashion on any binding.

This means that it will throw an error if you use any feature of any particular binding that isn’t available on another binding.


What’s changed?

This is possible with the current iteration of Qt.py.

1: from Qt import QtGui, QtCore
2: 
3: class Widget(QtGui.QWidget):
4:   my_signal = QtCore.pyqtSignal(str)
  • On the third line, we run into an immediate problem; QWidget is only available via QtGui in PyQt4 and PySide(1).
  • On the 4th line, we refer to a signal as pyqtSignal which would work well on both PyQt4 and PyQt5, but fail in PySide and PySide2.
  • Worst yet, these problems would not make themselves known until you run it on each of the 4 bindings and make sure, first hand that it works as you’d expect.

With this new change, Qt.py limits the available members of each submodule into a subset of members that exist across all bindings. The result is finding out about these problems faster and being able to guarantee that if it runs on one binding, it works on all.

1: from Qt import QtGui
2: 
3: class Widget(QtGui.QWidget):
4:   pass
5:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'QWidget'


It’s a breaking change

As it is a breaking change, this bumps Qt.py from a 0.x.x release into a 1.x.x. This means some of your already-written software with Qt.py may need some tweaking. On the up-side, the software that would behave badly now, are those that would have already behaved badly in any of the 4 bindings. So this is your chance to smoke some of that out.

We are confident in this change and direction, but are still in discussion about whether now is the right time. One of the bindings, namely PySide2, is so far behind the other bindings that it the weakest link by far, and critical submodules - such as QtOpenGL - is still missing.

These are the modules supported by Qt.py with this change.

__all__ = [
    "QtGui",
    "QtCore",
    "QtWidgets",
    "QtNetwork",
    "QtXml",
    "QtHelp",
    "QtCompat"
]

The second concern regards which version of this weakest link to match. As PySide2 matures, more feature will be added and Qt.py could start to grow. But Maya 2017 and others are currently fixed at version 2.0.0. Growing Qt.py beyond what Maya 2017 is capable of would limit its usefulness.

For this I figure it wouldn’t be too cumbersome to implement compatibility profiles; where the end-user specifies which version of, say, the VFX Platform to provide support for.

$ # For example
$ export QT_BASELINE=CY2018
$ python -c "from Qt import QtOpenGL"


Bridging the bindings

For the time being, and where you need functionality exclusive to any particular binding, such as sip in PyQt, there is still the __binding__ member that allows conditional inclusion.

if "PySide" in __binding__:
  do_pyside_stuff()

This would allow you to explicitly mark the parts of your codebase that depend on any particular binding, and to enable a bridge to your code today and your code sometime in the future when the required functionality is officially part of Qt.py.


Guinea pigs unite!

For now, we’d appreciate your feedback on this major change and for you to test it out for yourself. The release is still considered “alpha” and is available directly via GitHub for download or install.

$ pip install git+git://github.com/mottosso/Qt.py

Thanks to Matthew Levine for the initial feature request and Fredrik Averpil for the unwavering support. :)

Best,
Marcus

Sebastian Schoellhammer

unread,
Jan 31, 2017, 7:38:27 AM1/31/17
to python_in...@googlegroups.com
Luckily I just found this thread :) 

I have a question concerning slots and signals. 
In a previous version of qt.py something like :

self.pbBrowse.connect(self.browse)

@QtCore.Slot() 
def browse(self):
pass

would work just fine (in both maya 2016/17).  (like described here: http://wiki.qt.io/Signals_and_... )

Now that I got the latest version from github, this doesn't work anymore. 
I get:
# Error: TypeError: file wgWidgets.py line 281: PySide2.QtCore.QObject.connect(): not enough arguments #

Something I had used before all before Qt.py:
self.connect(self.pbBrowse, QtCore.SIGNAL("clicked()"), QtCore.SLOT(self.browse))
doesn't work because QtCore doesn't contain SIGNAL

however when I try:
self.connect(self.pbBrowse, QtCore.Signal("clicked()"), QtCore.Slot(self.browse))
I get this error:
# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 280: Unknown signal argument type: instancemethod #

So I guess I'm asking what's the preferable way to connect widgets with the new qt.py :)
(the binding being used for this was Pyside 2 in maya 2017)


Thanks a lot!
seb

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODFjo%2BzMcM0OzmnDxJ2BeTNZ%2BjNHPQVKtJoEv-w7PT%3D%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Sebastian Schoellhammer

www.sebscorner.org

Marcus Ottosson

unread,
Jan 31, 2017, 9:27:44 AM1/31/17
to python_in...@googlegroups.com, vfx-platform-discuss
Thanks Sebastian, that's just the kind of special cases I'm looking to find.

Quite surprising that it this would happen, as the remapping happens here as it did before. I'll be taking a closer look at this as soon as I am back from holiday (10th of Feb), until then it would be fantastic if you could post this as an issue under the projects GitHub page in case someone else is able to have a look at it sooner.


Best,
Marcus

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Jan 31, 2017, 1:30:19 PM1/31/17
to python_in...@googlegroups.com


On Wed, Feb 1, 2017, 1:38 AM Sebastian Schoellhammer <sschoellha...@gmail.com> wrote:

Something I had used before all before Qt.py:
self.connect(self.pbBrowse, QtCore.SIGNAL("clicked()"), QtCore.SLOT(self.browse))
doesn't work because QtCore doesn't contain SIGNAL

however when I try:
self.connect(self.pbBrowse, QtCore.Signal("clicked()"), QtCore.Slot(self.browse))
I get this error:
# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 280: Unknown signal argument type: instancemethod #


That's the old signal slot connection style, which maps to the way you do it in C++


There are a number of different signatures for calling it but this looks like you are using it wrong. Either you want to pass the slot method as the method itself without wrapping it in a Slot() call, or you want to pass the receiver class (self) and then the slot name :

self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self, QtCore.Slot("browse()"))

Or

self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self.browse)





To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAMLepcbyCV4wdGkKVMW62dy4%3DdUJkX%2BfnvR3ToeTGAmDW2NzvQ%40mail.gmail.com.

Sebastian Schoellhammer

unread,
Feb 1, 2017, 4:14:12 AM2/1/17
to python_in...@googlegroups.com
Hi Justin,

thanks for the reply but both methods you suggest don't work for me:

self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self, QtCore.Slot("browse()"))

# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 285: 'PySide2.QtCore.QObject.connect' called with wrong argument types:
  PySide2.QtCore.QObject.connect(PySide2.QtWidgets.QPushButton, PySide2.QtCore.Signal, LineEditPath, PySide2.QtCore.Slot)
Supported signatures:
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, callable, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, PySide2.QtCore.QObject, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(str, callable, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(str, PySide2.QtCore.QObject, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection) # 


self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self.browse)

# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 284: 'PySide2.QtCore.QObject.connect' called with wrong argument types:
  PySide2.QtCore.QObject.connect(PySide2.QtWidgets.QPushButton, PySide2.QtCore.Signal, instancemethod)
Supported signatures:
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, callable, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, PySide2.QtCore.QObject, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(str, callable, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection)
  PySide2.QtCore.QObject.connect(str, PySide2.QtCore.QObject, str, PySide2.QtCore.Qt.ConnectionType = Qt.AutoConnection) # 


If Id do:
self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self.browse())

it runs but browse() is called right at this point....

Sorry, very confused :/

Thanks for any more pointers,

seb


On Tue, Jan 31, 2017 at 7:30 PM, Justin Israel <justin...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0v8HxvzVhZj2VkbgeQw%2BapGunHfZ1G0OAc7_WSvTR%2B3Q%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Sebastian Schoellhammer

www.sebscorner.org

Sebastian Schoellhammer

unread,
Feb 1, 2017, 4:40:22 AM2/1/17
to python_in...@googlegroups.com
I set up a simple test script:

In the end this notation seemed to work for me again:
pb.clicked.connect(self.browse)

So is that the correct way?




To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org



--
Sebastian Schoellhammer

www.sebscorner.org

Justin Israel

unread,
Feb 1, 2017, 4:48:59 AM2/1/17
to python_in...@googlegroups.com


On Wed, Feb 1, 2017, 10:14 PM Sebastian Schoellhammer <sschoellha...@gmail.com> wrote:
Hi Justin,

thanks for the reply but both methods you suggest don't work for me:

self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self, QtCore.Slot("browse()"))

# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 285: 'PySide2.QtCore.QObject.connect' called with wrong argument types:
  PySide2.QtCore.QObject
Snip.... 

self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self.browse)

# Error: TypeError: file D:\Tech-Art\Core\Python\Qt\wgWidgets.py line 284: 'PySide2.QtCore.QObject.connect' called with wrong argument types:
  Snip... 

Well I think I would just be spinning wheels if I tried to comment on this problem when it has the Qt.py layer between it. Qt.py does whatever monkey patching it does to create the compatibility layer, so Marcus will probably just have to comment on it in depth when he returns. 

But the usage patterns I was quoting were from PySide 1.x and they seemed to be the same in PySide2, minus the title case vs all case which is introduced by Qt.py
You can see different usages of new and old connection style in the PySide2 unit tests



If Id do:
self.connect(self.pbBrowse, QtCore.Signal("clicked()"), self.browse())

it runs but browse() is called right at this point....

Yep. That's what that would do if you called a function and tried to pass it's return value as a result to the connect()  :-) 

I think the previous approaches that were failing were closer to what I would expect to work in PySide2, but I haven't actually used PySide2 yet so maybe I am overlooking a change. 

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAMLepcYWd9FMd1Re9wOn7dYsROeVPu%2B_WDcWJwQ7cu9KxBCmTw%40mail.gmail.com.

Justin Israel

unread,
Feb 1, 2017, 4:52:02 AM2/1/17
to python_in...@googlegroups.com


On Wed, Feb 1, 2017, 10:40 PM Sebastian Schoellhammer <sschoellha...@gmail.com> wrote:
I set up a simple test script:

In the end this notation seemed to work for me again:
pb.clicked.connect(self.browse)

So is that the correct way?

Wow. It didn't occur to me in your first mail, without a code example, that pbBrowse was a widget and not a signal instance. This new working approach is exactly what I would expect to work and would use in my own approach. This is the new style signal slot connection where the signal is a first class object that provides connect and disconnect methods straight to callables

Glad you got it sorted. 





To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org



--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAMLepcbpjTTfG15yrDANXztugiqHx3OOcXL3S4p1Rq1rmqmK6g%40mail.gmail.com.

Marcus Ottosson

unread,
Feb 1, 2017, 10:44:29 PM2/1/17
to python_in...@googlegroups.com
Seconded. 

SIGNAL and SLOT are excluded from Qt.py as are pre-4.8 functionality. Better stick to the 5.0+ syntax.

On 1 Feb 2017 16:51, "Justin Israel" <justin...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org



--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0j2ONAcLYjqGWfu1W6YjcoRBt%3DuC%2BfbXKyhB7sagws_A%40mail.gmail.com.

Sebastian Schoellhammer

unread,
Feb 2, 2017, 12:46:46 PM2/2/17
to python_in...@googlegroups.com
Thanks again - all is good now :-)

I have one further question, is there an elegant way to load a widget from a UI file which you can then inherit from ?

as in: 
class NewUI(uiwidget_base, uiwidget_form):
def __init__(self):
        super(NewUI, self).__init__(parent)
        self.setupUi(self)
etc.

this is what I came up with, just tested with maya2015, maya2016..

(I do know there is QtCompat.load_ui() but I needed this functionality as well)

seb



To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Sebastian Schoellhammer

www.sebscorner.org



--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Sebastian Schoellhammer

www.sebscorner.org

Marcus Ottosson

unread,
Feb 2, 2017, 10:04:03 PM2/2/17
to python_in...@googlegroups.com
If you go to the issues section in the project on GitHub, search for loadUi and similar keywords to find previous discussions about how to work with Qt Designer files in a cross-compatible way.




--
Sebastian Schoellhammer

www.sebscorner.org

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Sebastian Schoellhammer

unread,
Feb 3, 2017, 5:36:40 AM2/3/17
to python_in...@googlegroups.com
Thanks again - I've found something by Fredrik!

On Fri, Feb 3, 2017 at 4:03 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
If you go to the issues section in the project on GitHub, search for loadUi and similar keywords to find previous discussions about how to work with Qt Designer files in a cross-compatible way.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Sebastian Schoellhammer

www.sebscorner.org

jonn

unread,
Feb 4, 2017, 1:26:36 AM2/4/17
to Python Programming for Autodesk Maya, vfx-platfo...@googlegroups.com

form_class, base_class = uic.loadUiType(ui_file)

how to do it


在 2017年1月25日星期三 UTC+8下午10:28:25,Marcus Ottosson写道:

Slavomir Kaslev

unread,
Feb 7, 2017, 7:25:42 AM2/7/17
to python_in...@googlegroups.com, vfx-platfo...@googlegroups.com
On Sat, Feb 4, 2017 at 8:26 AM, jonn <jon...@gmail.com> wrote:

form_class, base_class = uic.loadUiType(ui_file)

how to do it

Here's what we use:

from cStringIO import StringIO
import xml.etree.ElementTree as xml
import Qt
from Qt import QtCore, QtWidgets

def load_ui_type(ui_file):
    parsed = xml.parse(ui_file)
    widget_class = parsed.find('widget').get('class')
    form_class = parsed.find('class').text
    if Qt.__binding__ == 'PySide2':
        from pyside2uic import compileUi
    elif Qt.__binding__ == 'PyQt5':
        from PyQt5.uic import compileUi
    elif Qt.__binding__ == 'PySide':
        from pysideuic import compileUi
    elif Qt.__binding__ == 'PyQt4':
        from PyQt4.uic import compileUi
    else:
        assert False, 'Qt binding %s is unknown' % Qt.__binding__

    with open(ui_file, 'r') as f:
        frame = {}
        o = StringIO()
        compileUi(f, o, indent=0)
        pyc = compile(o.getvalue(), '<string>', 'exec')
        exec pyc in frame
        form_class = frame['Ui_%s' % form_class]
        base_class = eval('QtWidgets.%s' % widget_class)
    return form_class, base_class


Maybe something along those lines will make it in Qt.py?
 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Slavomir Kaslev

Sebastian Schoellhammer

unread,
Feb 7, 2017, 9:52:47 AM2/7/17
to python_in...@googlegroups.com, vfx-platfo...@googlegroups.com
Nice!

Fredrik suggested this:

def setupUi(uifile, base_instance=None):
    """Load a Qt Designer .ui file and returns an instance of the user interface
    Args:
        uifile (str): Absolute path to .ui file
        base_instance (QWidget): The widget into which UI widgets are loaded
    Returns:
        QWidget: the base instance
    """
    ui = QtCompat.load_ui(uifile)  # Qt.py mapped function
    if not base_instance:
        return ui
    else:
        for member in dir(ui):
            if not member.startswith('__') and \
               member is not 'staticMetaObject':
                setattr(base_instance, member, getattr(ui, member))
        return ui

and then use it like:

class MyWidget(QtWidgets.QtWidget):
    def __init__(self, parent=wgQtUtil.getMayaWindow()):
        super(MyWidget, self).__init__(parent)
        setupUi(MyWidgetUI, self)



which seems neat and gets around the compile stuff but sadly widgets loaded that way don't let me add them into another layout. 







To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Slavomir Kaslev

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Sebastian Schoellhammer

www.sebscorner.org

David Aguilar

unread,
Apr 25, 2017, 9:41:59 PM4/25/17
to Marcus Ottosson, vfx-platform-discuss, python_in...@googlegroups.com

On Wed, Jan 25, 2017 at 6:28 AM, Marcus Ottosson <konstr...@gmail.com> wrote:

Thanks to Matthew Levine for the initial feature request and Fredrik Averpil for the unwavering support. :)


Hey, I just wanted to say thanks for following through and making these changes to Qt.py happen.

In case you're curious, WDAS has since switched to using Qt.py to aid in our Qt4 to Qt5 transition process.

The hard work and effort that has gone into Qt.py is very much appreciated.


cheers,
--
David

Marcus Ottosson

unread,
Apr 26, 2017, 9:28:35 AM4/26/17
to David Aguilar, vfx-platform-discuss, python_in...@googlegroups.com
Appreciate the kind words, David. It's been my pleasure and I'm happy you find it useful!​
Reply all
Reply to author
Forward
0 new messages