Jump to content
asnowcappedromance

Pyside Houdini Freeze

Recommended Posts

Hi guys,

 

I started to play around a bit with pyside in Houdini, but when I put the following script in a shelf tool, my Houdini just freezes.

 

import sys

import PySide
from PySide import QtGui
from PySide import QtCore
from PySide.QtGui import QApplication, QPushButton
from PySide.QtGui import QMessageBox

app = QtGui.QApplication.instance()

#wid = QtGui.QWidget()
wid = QtGui.QLabel()
wid.resize(250, 150)
wid.setWindowTitle('Simple')
wid.setText("hello Manu")
wid.show()
wid.activateWindow()

app.exec_()
#sys.exit( app.exec_() )

 

Any idea how to fix this?

 

Thanks,

Manu

Share this post


Link to post
Share on other sites

wid.activateWindow()  is also excess in your example

 

Hi Alexey, 

 

Thanks for your reply!

If I remove app.exec_() and activateWindow()

then the widget doesn't pop up anymore, my simple code looks like this now:

-------------------------------------

import PySide

from PySide import QtGui

wid = QtGui.QLabel()

wid.resize(250, 150)

wid.setWindowTitle('Simple')

wid.setText("hello Manu")

wid.show()

--------------------------------- 

 

Cheers,

Manu

Share this post


Link to post
Share on other sites

So, I think, they changed Qt widgets behavior in H15. This example works on my linux.

import PySide.QtGui as qtg
import PySide.QtCore as qtc

app = qtg.QApplication.instance()
cursor_pos = qtg.QCursor().pos()
parent = app.topLevelAt(cursor_pos)

label = qtg.QLabel('Hello World!', parent)
label.setWindowFlags(qtc.Qt.Window)
label.show()

I think widgets needs to set parent explicitly.

label.setWindowFlags(qtc.Qt.Window) will set widget as separate window.

Hope this helps.
 

Share this post


Link to post
Share on other sites

Good stuff Alexey!

Starting to get a lot of things to work now with Pyside!

 

Another issue I had was that I wasn't able to resize my fonts when running Pyside in Houdini/

Consider the following test:

import PySide.QtGui as qtg
import PySide.QtCore as qtc


class myClassTest(qtg.QWidget):
    """A test class for a widget"""
    
    def __init__(self):
        app = qtg.QApplication.instance()
        cursor_pos = qtg.QCursor().pos()
        parent = app.topLevelAt(cursor_pos)
        
        qtg.QWidget.__init__(self, parent)
        self.setMinimumSize(500,500)
        self.setWindowTitle("this is a test")
        self.setWindowFlags(qtc.Qt.Window)  
        
        self.header = qtg.QLabel("Hello World what's up:", self)
        self.header.move(10, 10)
        self.header.setFont( qtg.QFont( "Georgia", 140) )
                
    def run(self):
        self.show()

test =myClassTest()
test.run()
    

Any idea why the text is still displayed super small? No matter which value I put in there, the size always stays the same.

Does this have anything to do with the Global Ui Size in the Houdini preferences?

Thanks for you help!

Share this post


Link to post
Share on other sites
Guest mantragora   
Guest mantragora

from PySide import QtCore

from PySide import QtGui

class HOUWidget(QtGui.QWidget):

def __init__(self, parent = None):

super(HOUWidget, self).__init__(parent)

self.setMinimumSize(500,500)

self.setWindowTitle("this is a test")

self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

layout = QtGui.QVBoxLayout()

layout.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)

headerStyleSheet = 'font-size: 20px; font-family: Georgia;'

header = QtGui.QLabel("Hello World what's up:")

header.setStyleSheet(headerStyleSheet)

layout.addWidget(header)

self.setLayout(layout)

test = HOUWidget()

test.show()

Edited by fântastîque Mântragorîè

Share this post


Link to post
Share on other sites

so I ran into another PySide problem ... Maybe one of you can enlighten me on what I'm doing wrong with this one?

I'm trying to use the QtGui.setStyle() function in order to change the style of my GUI.

Turns out, no matter what preset I use, it all looks the same. (Using Windows7).

(Attached a screenshot)

 

Here's the code I'm running in a shelf tool:

from PySide import QtGui, QtCore

class Window(QtGui.QWidget):
    """A setStyle() test"""
    
    def __init__(self):
        super(Window, self).__init__()
        self.setGeometry(50, 50, 500, 300)
        self.setWindowTitle("PyQT tuts!")        
        self.home()
        
    def customHandler(self,  ErrorType, ErrorContext ):
        #print "Type:", ErrorType
        #print "error:", type(ErrorContext)
        pass

    def home(self):

        btn = QtGui.QPushButton("Test Button")

        styleChoice = QtGui.QLabel("Windows Vista")
        
        comboBox = QtGui.QComboBox()
        comboBox.addItem("motif")
        comboBox.addItem("Windows")
        comboBox.addItem("cde")
        comboBox.addItem("Plastique")
        comboBox.addItem("Cleanlooks")
        comboBox.addItem("windowsvista")
        comboBox.activated.connect(lambda: self.style_choice(comboBox, styleChoice))
        
        QtCore.qInstallMsgHandler(self.customHandler)
        
        qvbox = QtGui.QVBoxLayout()
        qvbox.addWidget(btn)
        qvbox.addWidget(comboBox)
        qvbox.addWidget(styleChoice)
        self.setLayout(qvbox)

    def style_choice(self, comboBox, widget):
        cur_str = comboBox.currentText()
        widget.setText(cur_str)
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create(cur_str))
                    
    def run(self):
        self.show()

main = Window()
main.run()

Thanks a bunch!

Cheers!

post-5147-0-98310800-1447548512_thumb.jp

Share this post


Link to post
Share on other sites
Stalkerx777    75

so I ran into another PySide problem ... Maybe one of you can enlighten me on what I'm doing wrong with this one?

I'm trying to use the QtGui.setStyle() function in order to change the style of my GUI.

Turns out, no matter what preset I use, it all looks the same. (Using Windows7).

 

I'm not sure you'll be able to use QStyle this way, better try to do this: QWidget.setStyleSheet(hou.ui.qtStyleSheet())

Share this post


Link to post
Share on other sites

I'm not sure you'll be able to use QStyle this way, better try to do this: QWidget.setStyleSheet(hou.ui.qtStyleSheet())

Hi Alexey,

Thanks for the reply. The problem is that I think by default QWidgets in PySide Houdini already use the hou.ui.qtStyleSheet() because when I apply this in Houdini 15 to my QWidget, the look doesn't change either, there is no difference at all to the jpg that I posted before. Is your GUI look changing when you set the Style Sheet like that?

Setting it to something like 'setStyleSheet("background-color: #00FF00; color: #FFFFFF")' makes a big difference on the other hand.

Cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×