C_Q Posted February 13, 2019 Share Posted February 13, 2019 I got a request to insert an entry into the Windows menu of Houdini, when this menu entry is clicked, it should show a GUI, with some input controls to let user input something as parameters, and a button to call the APIs provided by our own C++ lib. After the button is clicked, the status of the C++ lib should be updated on the GUI. What I got currently is I customized a MainMenuCommon.xml and inserted my own menu entry under the Windows menu. Then I tried defining a dialog using Houdini's UI script and then using the builduicode.exe tool to generate a pair of .c/h file in hoping that I can interact with the C++ lib in the callbacks of the UI elements, but I don't know how to show this UI from my added menu entry. Is this the correct way to do the task, or is there any better ways? Any suggestions/comments is welcome! Thanks! Quote Link to comment Share on other sites More sharing options...
C_Q Posted February 13, 2019 Author Share Posted February 13, 2019 I'm on Houdini 16.5. Quote Link to comment Share on other sites More sharing options...
C_Q Posted February 15, 2019 Author Share Posted February 15, 2019 (edited) I have made it work in this way: 1. define a command in c++, say my_cmd; in the command, open up the dialog I defined 2. install the command in CMDextendLibrary 3. make a .py file to call the command, the py file is quite simple hou.hscript('my_cmd') 4. execute the .py file in my inserted menu entry Although it worked, as I still new to Houdini, I'm not sure if this is the recommended way in Houdini, or is there any better ways? Thanks for any inputs! Edited February 15, 2019 by C_Q Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted February 19, 2019 Share Posted February 19, 2019 I've done something similar recently. You've picked the right way - by implementing an HScript command. The UI part is much simpler to implement with Qt though. Quote Link to comment Share on other sites More sharing options...
C_Q Posted March 18, 2019 Author Share Posted March 18, 2019 On 2/20/2019 at 2:05 AM, Stalkerx777 said: I've done something similar recently. You've picked the right way - by implementing an HScript command. The UI part is much simpler to implement with Qt though. Hi Alex, Thank you very much for your response! For the UI part, if I use Qt, or PySide, how can I communicate with the C++ lib then? Do I have to wrap the C++ lib for Python scripts? Quote Link to comment Share on other sites More sharing options...
Yannci Posted March 18, 2019 Share Posted March 18, 2019 If you're using Qt it would be native c++ application (I assume we are talking about the Framework and not the wrapper library). You could then launch it as standalone Qt Application from your menu. A guess from my side would be, if your own library is kind of simple, to use the ctypes python module which allows you to directly load a dynamic library into the RAM and use it in your python code. I haven't tested it in anyway and it could be a hassle getting this to work. Another option is to use e.g boost python which let's your write simple c++ code to wrap your library functions in python code. Quote Link to comment Share on other sites More sharing options...
C_Q Posted March 20, 2019 Author Share Posted March 20, 2019 On 3/19/2019 at 6:20 AM, Yannci said: If you're using Qt it would be native c++ application (I assume we are talking about the Framework and not the wrapper library). You could then launch it as standalone Qt Application from your menu. A guess from my side would be, if your own library is kind of simple, to use the ctypes python module which allows you to directly load a dynamic library into the RAM and use it in your python code. I haven't tested it in anyway and it could be a hassle getting this to work. Another option is to use e.g boost python which let's your write simple c++ code to wrap your library functions in python code. Thank you Yannci! Your second suggestion is worth trying. The side effect is that as the C++ lib upgrades I will have to update an additional wrapper. But it seems a doable way. Quote Link to comment Share on other sites More sharing options...
Yannci Posted March 20, 2019 Share Posted March 20, 2019 You're welcome! Haven't tried both ways to be honest but wanted to mention it. Would be cool if you could share your experiences! 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.