Ha, another issue
I’m new to Qt and PyQt, so, please, bear with me
But, I tried to create a simple UI in the Qt Designer and I saved it as a .ui file on C:\
However, when I try to run this Python code:
from blur.wingui import Dialog
from PyQt4.QtCore import SIGNAL # Signal mapping method for Qt
from PyQt4.QtGui import QTreeWidgetItem # Don't need the other imports, all loaded in the Ui file
import PyQt4.uic # Loader file
from Py3dsMax import mxs # Bring in the maxscript module
class ObjectItem( QTreeWidgetItem ):
def __init__( self, msobject ):
QTreeWidgetItem.__init__( self, [ msobject.name ] )
self._msobject = msobject
# Add the children of this item
for child in msobject.children:
self.addChild( ObjectItem( child ) )
def msobject( self ):
return self._msobject
class TestDialog( Dialog ):
def __init__( self ):
Dialog.__init__( self )
PyQt4.uic.loadUi( 'C:\ st.ui', self )
self._connect() # Connect the signals/slots
self.refresh() # Load the data
# Create the dialog
dialog = TestDialog()
dialog.show()
I get a TypeError:
TypeError: ('Wrong base class of toplevel widget', (<class '__main__.TestDialog'>, 'QMainWindow'))
Anyone knows what might be the problem?
You used a window instead of a dialogue in the .ui file hence it is a different class.
Here’s Working code. What i did is replace instances of Dialog with Window (including the import statement of course!). On a second note it would still error out because you are calling methods that you removed from the class declatration. I commented them out (refresh and _connect).
from blur.wingui import Window
from PyQt4.QtCore import SIGNAL # Signal mapping method for Qt
from PyQt4.QtGui import QTreeWidgetItem # Don't need the other imports, all loaded in the Ui file
import PyQt4.uic # Loader file
from Py3dsMax import mxs # Bring in the maxscript module
class ObjectItem( QTreeWidgetItem ):
def __init__( self, msobject ):
QTreeWidgetItem.__init__( self, [ msobject.name ] )
self._msobject = msobject
# Add the children of this item
for child in msobject.children:
self.addChild( ObjectItem( child ) )
def msobject( self ):
return self._msobject
class TestDialog( Window ):
def __init__( self ):
Window.__init__( self )
PyQt4.uic.loadUi( 'C:\ st.ui', self )
#self._connect() # Connect the signals/slots
#self.refresh() # Load the data
# Create the dialog
dialog = TestDialog()
dialog.show()
Hope that helps,
Thorsten
Thanks a lot!
Yeah, as I said, no prior experience with Qt and I only noticed the Dialog class now. Will pay more attention to the Qt Designer next time.
Thanks!
@ ypuech
Thanks for the windows icon code – I’ll include it in the next release, its very cool – works in 3dsMax and XSI. Though, it doesn’t seem to work in x64 bit, just x32.
@ instinct-vfx
Thanks for the tutorial – I uploaded it to the wiki:
http://code.google.com/p/blur-dev/wiki/Py3dsMaxCOMExecute?ts=1256323833&updated=Py3dsMaxCOMExecute
Thanks guys for helping debug and build this!
Eric
Also, we’re in the process of porting our tools over to a new PyQt based treegrunt that’ll run in both XSI & 3dsMax, so we will be updating our tools download soon enough.
Thanks guys!
I forgot to add in the modification the import of SendMessage from win32gui module:
from win32gui import FindWindow, SendMessage, GetClassLong, GetIconInfo
from win32con import WM_GETICON, GCL_HICONSM, GCL_HICON
I will try to make the icon code works under x64.
Thanks for the fix, it doesn’t throw the error now but the icon still doesn’t show up. I assume that’ll be the 64bit issue, as I’m on Vista Business x64, right?
Exact, I will try to fix it.
EDIT: I have found the problem but I don’t know how to fix it yet.
To get an application icon, it seems GetClassLong( core.parentWindow(), GCL_HICONSM ) is the function returning the icon most of the time.
But GetClassLong() is deprecated under x64 and replaced by GetClassLongPtr. I have checked in Python 2.4 and 2.6 PyWin32 documentation and I have not found it…
Hey Eric!
Thanks for this cant wait to play with it! Now we can make some nifty node based ui’s using qpainter…
Cheers,
Lukas
@ lukashi
I would recommend using the QGraphicsScene & QGraphicsView
We’ve been developing our own node based GUI’s using them and they are quite powerful, pretty much designed to handle such things.
At some point we’ll be releasing that out as well…
Eric
Ooops ya thats what i meant! Looking forward to those node based tools when they are ready!
Now that sounds pretty cool Eric! If you dont mind me asking did you develop the node system as a plugin to Qt with PyQt bindings or completely in PyQt?
Regards,
Thorsten