これでオブジェクトのすべてのプロパティを取得できます
dir(YouObjectInstance.props)
YourObjectInstanceは、もちろん作成する任意のインスタンスです。
簡単な方法は、ターミナルを開くことです。
you@yourcomputer ~/Desktop/python $ python
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk, GtkSource, GObject
>>> window_instance = Gtk.Window()
>>> dir(window_instance.props)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__len__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'accept_focus', 'app_paintable', 'application', 'border_width', 'can_default', 'can_focus', 'child', 'composite_child', 'decorated', 'default_height', 'default_width', 'deletable', 'destroy_with_parent', 'double_buffered', 'events', 'expand', 'focus_on_map', 'focus_visible', 'gravity', 'halign', 'has_default', 'has_focus', 'has_resize_grip', 'has_tooltip', 'has_toplevel_focus', 'height_request', 'hexpand', 'hexpand_set', 'icon', 'icon_name', 'is_active', 'is_focus', 'margin', 'margin_bottom', 'margin_left', 'margin_right', 'margin_top', 'mnemonics_visible', 'modal', 'name', 'no_show_all', 'opacity', 'parent', 'receives_default', 'resizable', 'resize_grip_visible', 'resize_mode', 'role', 'screen', 'sensitive', 'skip_pager_hint', 'skip_taskbar_hint', 'startup_id', 'style', 'title', 'tooltip_markup', 'tooltip_text', 'transient_for', 'type', 'type_hint', 'ubuntu_no_proxy', 'urgency_hint', 'valign', 'vexpand', 'vexpand_set', 'visible', 'width_request', 'window', 'window_position']
>>>
これで、オブジェクトのプロパティのドキュメントがすぐに作成できます。
メソッドが必要な場合は?
for names in dir(window_instance):
attr = getattr(window_instance,names)
if callable(attr):
print names,':',attr.__doc__
リフレクションが必要な場合は、次のリンクにアクセスできます。リフレクションapi
これにより時間を大幅に節約できます。また、任意のオブジェクトを受け入れるように変更したり、継承したりすることもできます。
次のものも使用できます:
help(SomeClassModuleOrFunction)
ただし、help()から出力されるテキストは制限できますが、instance.propsを使用してインスタンスをループすることも、コードがどれだけ適切に文書化されているかによっては、欠点が生じる可能性があります。
上記の方法のいずれかを使用して、少なくともいくつかのドキュメントを入手してください。1つが必要なものに合わない場合は、別の方法を試してください。