Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Python - EnumEditor

Hello,

I am trying to make a model flexible by adapting all my gp directly from a specific caliber.

I want to make the choose of the caliber by an app, which  ask directly the caliber from an enum editor.

 

Once I have this parameter I can go ahead and set all the gp directly with python.

This is how I want to handle this

 

Now I am already stucked by reading the caliber given in the enum editor.

I gave 3 items: 16 / 25 /32

Capture.JPG

 

I thought it was easy to set my parameter such like:

 

ng_parameter= self.my_enum_editor.getValue()

 

But I can't find the right way to do the job.

I am looking in the AdvancedCustomizedParameterizationApp.ame

But because of my poor python level (actually 0),  it is not successfull

 

Thanks for any tip

Regards

Maxime

2 REPLIES
Solution
Solution
Accepted by topic author mAx
‎06-30-2017 05:29 AM

Re: Python - EnumEditor

Hi Max,

 

The enumeration widget is close to a combobox. If you need help, you should look at Qt QComboBox class documentation.

 

You have then to properties available.

  • currentIndex: which returns an integer (number of the selectect item)
  • currentText: which returns the selected text

You can try this in your code

ng_parameter = self.my_enum_editor.currentIndex()

You will probably need for your code to update itself when you interact with your GUI.

=> use the connect  method

 

self.my_enum_editor = QComboBox()
self.my_enum_editor.addItems(['16', '25', '32'])
self.my_enum_editor.currentIndexChanged.connect(self.my_update_function)

def my_update_function(self, index) :
    print index
    print self.my_enum_editor.currentIndex()
    # both methods should print the same results

    

This should help you.

 

Best regards,

 

Thomas

 

Re: Python - EnumEditor

Thank you for your reply.
Something went wrong yesterday as I was trying to post this thread.
I couldn't post anything, so I asked directly the support.
Now I have 2 solutions.
Great
Thank you