asnowcappedromance Posted October 29, 2015 Share Posted October 29, 2015 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 Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 (edited) just remove app.exec_() because H14\15 is a Qt application and it doesn't need to run exec_ func. Edited October 29, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 (edited) wid.activateWindow() is also excess in your example Edited October 29, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 29, 2015 Author Share Posted October 29, 2015 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 Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 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. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 import PySide from PySide import QtGui What is this? This will work also: from PySide import QtGui Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 29, 2015 Author Share Posted October 29, 2015 Thanks, that totally works now!! I'm using H14 right now by the way. I also could get this cookbook example to work, where they don't use the QGuiApplication 'toplevelat' function, but instead wrap the code in a class: http://www.sidefx.com/docs/houdini14.0/hom/cookbook/qt/ Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 (edited) Yes, but Qdialog(QFontDialog , etc) is notthe same as QWidget(Qlabel etc), because it waits for your choice Edited October 30, 2015 by Alexey Vanzhula 1 Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted October 29, 2015 Share Posted October 29, 2015 Recently your first example (but wihout app.exec_()) would have worked in previous H14 builds. But not now, as I see) Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 30, 2015 Author Share Posted October 30, 2015 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! Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted October 30, 2015 Share Posted October 30, 2015 (edited) 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 October 30, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 30, 2015 Author Share Posted October 30, 2015 Nice!! Thanks for the reply! Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted November 15, 2015 Author Share Posted November 15, 2015 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! Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted November 15, 2015 Share Posted November 15, 2015 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()) Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted November 15, 2015 Author Share Posted November 15, 2015 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.