Jump to content

import module problem(pyqt or pyside)


ylthh

Recommended Posts

Hello. I have a question about pyqt or pyside.

 

I made a simple pyqt. 

I typed some scripts in Python source editor like...

 

###############

import sys
sys.path.append('Z:/Script')
try:    
    reload(simple_qt)
except:    
    import simple_qt
################
 
It is working very well in python source editor in houdini.
 
However, when I made a button on houdini shelf, it is not working well.
First when I press a button, a ui pops up. But there is no pop-up after the first press.
Then I add one more line...

###############

import sys
sys.path.append('Z:/Script')
try:    
    reload(simple_qt)
except:    
    import simple_qt
    reload(simple_qt)
################
This is working, but you know, one more execution happens right away after one execution.
I think It is not good for script.
 
If anyone know about this, please help me.
 
Thank you.
 
Link to comment
Share on other sites

I guess you have all your PyQt code in global name space of simple_qt file. This is not good. Make a function in simple_qt file. for example:

 

def show_my_app():
    app = QApplication()
    ui = MyDialog()
    ui.show()
    app._exec()

Then in houdini:

import simple_qt
reload(simple_qt)
simple_qt.show_my_app()

And don't forget this

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...