i see that the generic tool utils use if kwargs.has_key(“ctrlclick”):
and then it's easy to check whether the value for that key is True or False.
my question is - is there a case when the key “ctrlclick” might be missing from kwargs? do i need to worry about handling that case?
thx.
handling Ctrl-click on shelf button
4517 3 0-
- whalerider
- Member
- 194 posts
- Joined:
- オフライン
-
- rafal
- スタッフ
- 1471 posts
- Joined: 7月 2005
- オフライン
When invoked from the shelf, the “ctrlclick” will always be there. But it is a good programming style to check anyway. Maybe in the future, there will be a way of invoking a tool with custom kwargs in Python itself, and then users may not add “ctrlclick” explicitly, in which case you may get exceptions in your tool.
-
- whalerider
- Member
- 194 posts
- Joined:
- オフライン
Thanks.
I'll keep the check whether the key exists.
I wasn't sure what to do if it does not.
Right now my code does not do anything if the ‘ctrlclick’ does not exist in kwargs. Should it throw a certain kind of exception? Or just print out some error message?
Or maybe it should default to the normal ‘click’ behavior and bring up a dialog where the user specifies the tool's parameters.
edit: i guess the last alternative makes most sense.
I'll keep the check whether the key exists.
I wasn't sure what to do if it does not.
Right now my code does not do anything if the ‘ctrlclick’ does not exist in kwargs. Should it throw a certain kind of exception? Or just print out some error message?
Or maybe it should default to the normal ‘click’ behavior and bring up a dialog where the user specifies the tool's parameters.
edit: i guess the last alternative makes most sense.
-
- rafal
- スタッフ
- 1471 posts
- Joined: 7月 2005
- オフライン
-
- Quick Links

