Parameters with Jython

Tags: #<Tag:0x00007fb883707e78> #<Tag:0x00007fb8837075e0>


Hi everyone

I am trying to make a little gui for unique needs.
I am working wtith jython by the script editor of imageJ and I try to get some parameters fro mthe users like Files integer and strings and make use with #@ parameters like imageJ recomend, but I hav esome problem
when I use this syntax the type of the variable is unicode instead of string or int and I can’t work with this.

Does someone know how to work with the variables of the parameters? Should I change something when I got those parameters?




Please post a sample script so we can see the issue you are having… an exact example would be great.



The script is:

#@ File(label="Select a directory", style="directory") myDir

import os.path
print type(myDir) 

And the error is:

TypeError: coercing to Unicode: need string, type found

So I cannot work with those variable that I get from the users with the modules of Jython

some question please:
Is this the right way to work with the Parameter methods?
Can I work with these parameters with Jython if not how can I get parameters from the users?
what is the type of those parameters (string, integer…)? I think that it is in java script so I do n’t know this language very well

Thank you very much


Ok @microb1

I really don’t know Jython well myself… but does this work?

#@ File(label="Select a directory", style="directory") myDir

import os.path
print type(myDir) 

And for the type - you have it printed in your script: <type ''>.



Now it is OK thank you very much

I have some question please:
What is the parameter variable? what is this unicode?
Are there another ways to get paremeter from the users? in case I want to make a gui
There is any way to operate imageJ Jython script editoor by IDE like pycharm? I have tried to do that with eclipse and pydev but I didn’t succeed unfortunetlly, It is very important for me from some reasons like console, debuger automatic complete on so on.

Thank you very much



So - I don’t know Jython well myself… so I can’t answer those Jython-specific questions. Perhaps someone else here can?

But for this question:

You can test out all the different widgets by running this code:

#@ boolean(label = "boolean") pBoolean
#@ byte(label = "byte") pByte
#@ char(label = "char") pChar
#@ double(label = "double") pDouble
#@ float(label = "float") pFloat
#@ int(label = "int") pInt
#@ long(label = "long") pLong
#@ short(label = "short") pShort
#@ Boolean(label = "Boolean") oBoolean
#@ Byte(label = "Byte") oByte
#@ Character(label = "Character") oCharacter
#@ Double(label = "Double") oDouble
#@ Float(label = "Float") oFloat
#@ Integer(label = "Integer") oInteger
#@ Long(label = "Long") oLong
#@ Short(label = "Short") oShort
#@ int(min = 0, max = 1000) boundedInteger
#@ double(min = 0.2, max = 1000.7, stepSize = 12.34) boundedDouble
#@ BigInteger bigInteger
#@ BigDecimal bigDecimal
#@ String string
#@ File file
#@ ColorRGB color
#@ OUTPUT String result



Did you read this thread?

Yeah, I have not had good luck with PyDev. It was very crashy for me. I like PyCharm much better.