How to find the Python equivalent operation for tools, settings & menu? When you press a button or change a setting, this is an operation which you can also do in Python, how do you find the Python equivalent to accessing these user interface elements.


Settings (text, numbers, colors... etc)
Buttons (tools you access via key bindings, menu items etc)
Menus (accessed via headers, other menus or key-bindings)
Edit Source

If you wanted to find out the python code for some of the user interface and panels you could right-click on parts of the UI (such as buttons or properties within the panel you wanted to know about) and choose 'Edit Source'.

For example, if I wanted to know about the render panel:



I could right-click on the 'Render' button and choose 'Edit Source':



A notification will then appear in the Info header at the top of the screen (in a default layout) informing you that a text file had been created for viewing in the text editor:



You can check this file and view the python code that makes up the panel:



In this example you can see information which might be useful such as: The panel class name which can be used to append new UI elements into existing parts of the UI (RENDER_PT_render), the operator names and categories (render.render for example) and general UI code for creating rows (row = layout.row(align=True)).

Autocomplete

Sometimes, if you are searching for the python equivalent of a property, it might be useful to use the autocomplete feature (CTRL+Space) of the 'Python Console' to explore the api.

Autocomplete will show you all the possible options branching off the current one. For example, using autocomplete on bpy.data.objects['Cube'] would result in showing me all the available python properties for that object:



Online API documentation

You can also browse the online 'Python API Reference' (that link always redirects to the latest version) which can be found via the help menu:



This documentation includes several pages serving as an introduction to the API as well as a full reference to all the python commands and properties available to use in blender. While this doesn't provide the python command to an exact tool/panel instantly, a simple generic search of "panel" using the search box would provide results relating to existing panels in blender and examples of how to create a new one.

Hotkey Preferences

If you wanted to find out the python name of a menu that appears when you press a hotkey, you can search for that hotkey in the preferences. For example, if I wanted to know the python name of the menu that appears when I press Ctrl+H in edit mode (the hook menu), I can search using the shortcut (when search type is 'key binding') in File> User Preferences> Input:



This provides several results, one of which is a 'Call Menu' item in the 'Mesh' category which reveals the name of the menu being called:



Here we can see the menu being called with that shortcut is VIEW3D_MT_hook, which you can then call in your own scripts.