0

custom plugin launch QDialog subwindow

Howdy,

We've got an often used little PyQt QDialog window that we use to set variables like Shot, Sequence, Shotgun Task/Context

that has its own .ui file.   From inside a new custom RV Python plugin, I'm calling in a way that we use a lot and we like to use as a popup dialog in RV.

I guess I should ask first whether or not this is possible.  I search the forum here and found a post or two that seem to imply it was.

 

First, I have the RV plugin code, which compiles and loads.  At the top, I do a

    import Settings_Dialog as SD

Later, I call it like so:

    dialog = SD.Ui_Dialog()

    if dialog.exec_():

        settings = dialog.DoIt()

        print settings

 

Before describing the file "Settings_Dialog.py",...let just say, that if I execute this,...RV will error out saying:

    ERROR: 'Ui_Dialog' object has no attribute 'exec_'

But I know this it does,..as this syntax works in non-RV related work.   Just for grins, I replaced "exec_()" with "show()"

and the subwindow did appear for a brief second, then disappears.  The version of PyQt4 that I'm using is compatible with Python 2.6.6.

Is there some inherent limitation to doing something like this? 

 

Thank you,

Jim

 

Btw:  using RV 4.0.9 on Windows 7 64-bit

 




UI_Test-1.0.rvpkg

13 comments

  • 0
    Avatar
    Jim Polk

    bump

  • 0
    Avatar
    Jon Morley

    Hi Jim,

    For legal reasons we cannot distribute PyQt with RV. We have a commercial license of Qt which prohibits us from including it or PyQt built against it with our releases. Now that disclaimer is out of the way.

    Many of our users compile PyQt on their own to work with RV, but it is a delicate challenge. You have to compile with the exact version of Qt (4.8.5) and Python (2.6.7) that we use or else it won't work.

    We have received mixed messages from users regarding including pyside, but have given that some investigation. Would that help in your case or are you exclusively interested in matching your PyQt version?

    I would also suggest using a newer version of RV itself as there have been many bug fixes since 4.0.9.

    Thanks,
    Jon

  • 0
    Avatar
    Jim Polk

    Hi John,

    Though the differences are slight, and we have both PyQt and PySide installed, we still lean towards PyQt for now...

    I have compiled Qt from source before,...but we're using Qt 4.8.4 which is so close to 4.8.5 that it would be hard to believe that the

    difference would be an issue,...so let's set that aside for the moment,....unless you have evidence to the contrary.

     

    Can you elaborate any other reasons why the code example would not work ?...

    Do you guys have any example usage of loading and using a .ui file?...from either PyQt or PySide ?

    Do you have any example  usage of calling a QDialog ?

     

    Thanks!

    Jim

     

  • 0
    Avatar
    Jon Morley

    Hi Jim,

    Sorry about the delay. I lost the original reply I wrote here when I thought I sent it along.

    I would say that it is not safe to dismiss the version mismatching that quickly. We have had many users, as well as myself, run into serious issues without matching up.

    That having been said:

    1) Can you please launch from the command line and show us any and all output that shows up when you execute your package?

    2) Can you please modify your code to include "print(type(dialog),dir(dialog))" before your exec_() call?

    We do not currently use ui files on the scripting side. I am attaching the one example that I have for PyQt usage.

    Thanks,
    Jon

  • 0
    Avatar
    Jim Polk

    Hey Jon,..no worries,...

    I'll track down and install 4.8.5 I guess and see if that makes a difference...

    I've attached a zip file with contents you asked for, including simple source to illustrate...Also, look in "printouts.txt" to see "dir()" of dialog...

    Thanks!

    Jim

  • 0
    Avatar
    Jon Morley

    Hi Jim,

    I reduced your package even further and tried it out. Your dialog popped right up and the printed output I see "exec_". I think getting the version of Qt and Python matching is a good first step. Please let me know if you still see issues once that is working.

    Thanks,
    Jon

     

    Package attached in original post now.

  • 0
    Avatar
    Jim Polk

    Hey Jon,

    ...great to hear it's working for you, but unfortunately, it's not working for me here...Still get same error message.."no attribute 'exec_'"

    I was able to find and install 4.8.5...as for Python, we have 2.6.6 and 2.7.6.   While a version difference of 0.0.1 may be significant,

    I'm pretty sure many would agree that the difference in 2.6.6 and 2.6.7 is extremely small, so I'm not going to install 2.6.7...at least not yet.

    Since our software environments are setup differently, I can't run your code exactly as-is,...we use 'sys.path.insert()' to set our paths,etc..

    I will tinker with it a bit more, but if we can't solve this, then we give up being able to use Designer, and have manually code future plugin UIs.

    (I know there's a way to convert .ui to .py, but it adds many more steps and I'd like to avoid that route as well)

    Please let me know if you think of anything else in relation to this.  I'll tinker a bit and get back to you.

    Thank you,

    Jim

     

  • 0
    Avatar
    Jim Polk

    Hey again Jon,....

    Does your RV combination of Python/PyQt of  2.6.7 / 4.8.5 refer to RV version 4.0.11 ?  and/or 4.0.9 ?

    Thanks,

     

  • 0
    Avatar
    Jon Morley

    Hi Jim,

    All RV versions since 4.0.9 use Qt 4.8.5 and Python 2.6.7 (Window/Linux) or 2.6.8 (Mac), but we always suggest using the latest version (now 4.0.12) to get the best performance and latest bug fixes.

    The right thing to do here is for us to compile and include our own compatible PyQt Modules, but we are legally forbidden from doing so. There are a handful of Windows users that have made this work, but it is very challenging to get right and we cannot support customers trying to compile this in their unique setups. That is why we are looking at getting pyside working. We just haven't put a lot of effort in there due to the lukewarm reception that idea has garnered.

    I am truly sorry I don't have anything more helpful to add.

    Thanks,
    Jon

  • 0
    Avatar
    Jo Jurgens

    The right thing to do here is for us to compile and include our own compatible PyQt Modules, but we are legally forbidden from doing so.

    Would it be legal for you to provide this to users that have purchased PyQt. I know other companies that provide the source for their guis to users that have paid for a PyQt license. 

    Our inhouse pipeline contains tens of thousands of lines of PyQt code. I would love to make this work with Rv, but supporting PySide is simply too much work at this point

  • 0
    Avatar
    Jim Polk

    That's a great idea,...

    Btw,..just wanted to add,...I was able to hook into the RV menu/window PyQt hierarchy,...and was able to get our UI to display.

    It wasn't using the development path we normally use, i.e., using a .ui file directly,...but it is a workable path and it's getting the job done for us.

    Cheers,

  • 0
    Avatar
    Alan Trombla

    @Jim: great!  glad to hear you got it working.

    @Jo: "Would it be legal for you to provide this to users that have purchased PyQt. I know other companies that provide the source for their guis to users that have paid for a PyQt license".  I'm not sure.  To be clear the problem is not providing source (there is no PyQt source in RV) the issue is providing a general purpose python interpreter in RV with access to PyQt modules.   But as a practical matter, we have no way of segregating access to PyQt to only those users of RV that happen to have a commercial PyQt license.

    Cheers,

    Alan

  • 0
    Avatar
    Jo Jurgens

    This version of PyQt, which has been compiled for Maya 2014 on Windows, seems to be a lot more stable than vanilla PyQt for some reason. it only works on Rv 4.2+, though, since it's for Python 2.7

    https://github.com/pyqt/maya2014-qt4

     

     

     

Please sign in to leave a comment.