I’m new to Qt and facing an issue while writing in PySide2 for Houdini UI.. I’ve written a script in Houdini that creates a window with two buttons: Build and Close.
Clicking the Build button opens another window with the same two buttons (Build and Close). The Build button works fine the first time, opening the new window. However, subsequent clicks on the Build button don’t seem to work at all. Additionally, each click on the Build button is counted, and when the Close button is clicked, it prints the total number of clicks. This behavior happens regardless of whether you close the window from the main or subsequent windows. Could someone please explain why the Build button stops functioning after the first click? I’d appreciate any help or guidance! https://github.com/MaheshFXTD/shotbuilder [github.com]
Please note that main.py is for houdini ui and windows_main.py is for running the code in windows python3.1 which works fine. But for some reason it's not working in houdini. Thank you!
I hope I understand you correctly. You can't click it anymore because the second dialog spawned by clicking "Build" is a modal, meaning it's a type of a pop-up that requires user interaction before they're allowed to do anything with the main application again. It is a modal because you launch it with dialog.exec()in the show_collected_files_windowmethod.
If you want to keep the window clickable, use dialog.show()instead.
@alex Thanks for responding on this topic. Most of the issues in the UI are fixed but still close button or default close button is printing the collected files before closing the window. I’ve tried using self.close, self.ignore, and overriding the closeEvent function, but the issue persists.
Are you asking me how to stop your program from printing the message "Debugging collected files."? Your close button has a lambda function connected to it (line 138):
You must still be using a modal dialog.exec()and not dialog.show().
The parent program becomes frozen when launching a modal, and any print statements will also wait until you've closed the window. What you're seeing is not the "Close" button printing anything, but rather (to my understanding) resuming your program and all the print()commands you've accumulated appear all at once -- but they were in fact created by your "Build" button.
Switch to dialog.show()and it will make your Build button print statements the moment you press it and your Close button will not print anything anymore.