LoginSignup
0
0

More than 5 years have passed since last update.

PythonistaのCustom Attributeでハマったところ

Posted at

CustomAttributeにアクセスしたらエラー

PythonistaでUIとしてtextfieldを追加し、それに付与したCustomAttributeにアクセスしたところ、以下のようなエラーメッセージが表示されました。

CustomAttribute(NG)
{‘attr‘:‘value‘}
action.py
def action(sender):
   print(sender.attr)
console
Warning: could not load custom attributes of view "CustomAttributeの名前": invalid character in identifier

原因

Pythonのコードを含めて、外部キーボードからの入力をしていたのですが、Pythonのエディタ上では問題ない'(シングルクォーテーション)の入力が、CustomAttributeを入力するinspector上だと‘(引用符?)となってしまうのが原因でした。
とりあえず、外部キーボードからではなく、スクリーンキーボードから入力することにより対処しました。

CustomAttribute(OK)
{'attr':'value'}

根本的な問題

iOSのスマート句読点という機能のせいでした。
設定から変更したらば、外部キーボードからでも正常に入力できるようになりました。

参考

https://forum.omz-software.com/topic/2663/syntax-inside-the-custom-attributes-section/11
https://getnavi.jp/business/247123/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0