Select to view content in your preferred language

TypeError: GPToolDialog() takes at most 1 argument (2 given)

7193
21
08-04-2014 11:00 AM
SurendranNeelakantan
Occasional Contributor

I am using ArcGIS 10.22

An error  is coming in the python window  "TypeError: GPToolDialog() takes at most 1 argument (2 given)"

But the tool seems working fine

The  documentation says : GPToolDialog(toolbox, tool_name)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Does anyone know the  reason ?

 

Thanks

0 Kudos
21 Replies
DanPatterson_Retired
MVP Emeritus

Just curious as to why the python window would be open?  Are you editing then running the tool from the toolbar without closing the python window?  If it works totally fine with the window closed, then forget about

0 Kudos
SurendranNeelakantan
Occasional Contributor

Dan

a small python window was docked by default . That is the reason I noticed this issue. Only once I received the error in  a message box.  I am closing the python  window for the time being.

I am still wondering  the GPToolDialog() need two argument  then why the error message  says   "at most 1 argument" 

The error message it self is  wrong ?   Do you think it could be a bug ?

Thank you

0 Kudos
DanPatterson_Retired
MVP Emeritus

I didn't find any posted...I suspect it has something to do with the python window being open which under normal circumstances, it wouldn't be

0 Kudos
SurendranNeelakantan
Occasional Contributor

Dan

Thank you for looking into this, I will keep an eye on this  and I will post more details when I have.

0 Kudos
TI
by
Frequent Contributor

I'm getting the same error using ArcMap 10.5.1.  I have Python Add-In with several tools which invoke pythonaddins.GPToolDialog() .  In all cases they work perfectly well, but print out this error to the Python console:

TypeError: GPToolDialog() takes at most 1 argument (2 given)

I reckon it's a bug as the documentation clearly states that the function takes 2 arguments and it works fine with 2 arguments AND it doesn't appear to be a real problem as the tools all run perfectly well.

(I have a python console open sometimes for diagnostic purposes when developing and running these tools which use 'print' commands to log their progress.)

0 Kudos
Luke_Pinner
MVP Regular Contributor

It's a longstanding bug NIM089253. The workaround is just to wrap the call in a try block:

try:
    GPToolDialog(toolbox, tool_name)
except TypeError:
    pass
0 Kudos
DanPatterson_Retired
MVP Emeritus

with the except block being

print " "

from the link... the thread that it refers to is archived since it is so old.  and it was found in 10.1 but windows 7

0 Kudos
Luke_Pinner
MVP Regular Contributor

pass worked for me in 10.2 (it's been a while since I've worked with python addins...) but not for another user.  

https://community.esri.com/thread/160547#comment-534380 

Meh, python addins are not supported in Pro so I stopped bothering with them.

0 Kudos
TI
by
Frequent Contributor

pass makes more sense in this context than printing a whitespace character or empty string.  I don't see any point in printing an empty line in this context.  pass is a Python no-op, so actually legitimately does nothing in a context where a statement is required.  I think that print statement is an attempt at a no-op, but doesn't quite hit the mark, as it would generate an empty-ish line of text (which may not matter to some people, but might to others).

0 Kudos
Luke_Pinner
MVP Regular Contributor

In general yes. In this case I think was because arcpy messes with sys.stdout/stderr (from memory) so the print ' ' was supposed to help silence the error output.

I can't check now as I can't get any addins at all to work (I think it's our locked down corp environment)

0 Kudos