How to make a GUI for getting user inputs for my python script?
-
Hello,
I realized that I have 5 different "change name" scripts for special needs. I need an interface that I can get some inputs from that and use it in a single script. For example suffix text, prefix text, and some checkboxes in a single panel.how can I do that? As far as I learned there are some gui functions for only one input type like:
inputString=gui.InputDialog()
I need a panel that will contain different type of multiple inputs. Is it possible?
-
Yes. But you need to define your own dialog class. Consider the class GeDialog here:
https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html
Derive your own class from that and use the methods listed on that page to construct your own GUI and your own responders. -
Hi @delizade as @Cairyn pointed out you should implement a GeDialog to create a dialog.
The creation of the dialog is done within the CreateLayout method, where you need to call AddEditText to add some text input. The first parameter is an ID(int) that is used to identify the gadget. You are free to choose what you want but they should be unique in your dialog. You can retrieve the value of such input with GetString and the id used on the creation. If you want to know when the value change, you can override the Command method, which is called for each Gadget change with the ID of the gadget.Find more information about GeDialog in the C++ Manual, don't be afraid, the code is really adaptable to Python but this manual have some context that could help you to understand the whole logic of GeDialog. And finally find some example of GeDialog in the Python Github repository.
Cheers,
Maxime. -
-
Hello @delizade,
without further questions or replies, we will consider this topic as solved by Monday, the 30th and flag it accordingly.
Thank you for your understanding,
Ferdinand