~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to doc/python_api/examples/bpy.types.Menu.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Basic Menu Example
 
3
++++++++++++++++++
 
4
This script is a simple menu, menus differ from panels in that they must
 
5
reference from a header, panel or another menu.
 
6
 
 
7
Notice the 'CATEGORY_MT_name' :class:`Menu.bl_idname`, this is a naming
 
8
convention for menus.
 
9
 
 
10
.. note::
 
11
 
 
12
   Menu subclasses must be registered before referencing them from blender.
 
13
 
 
14
.. note::
 
15
   Menu's have their :class:`Layout.operator_context` initialized as
 
16
   'EXEC_REGION_WIN' rather then 'INVOKE_DEFAULT', so if the operator context
 
17
   needs to initialize inputs from the :class:`Operator.invoke` function
 
18
   then this needs to be explicitly set.
 
19
"""
 
20
import bpy
 
21
 
 
22
 
 
23
class BasicMenu(bpy.types.Menu):
 
24
    bl_idname = "OBJECT_MT_select_test"
 
25
    bl_label = "Select"
 
26
 
 
27
    def draw(self, context):
 
28
        layout = self.layout
 
29
 
 
30
        layout.operator("object.select_all", text="Select/Deselect All").action = 'TOGGLE'
 
31
        layout.operator("object.select_all", text="Inverse").action = 'INVERT'
 
32
        layout.operator("object.select_random", text="Random")
 
33
 
 
34
 
 
35
bpy.utils.register_class(BasicMenu)
 
36
 
 
37
# test call to display immediately.
 
38
bpy.ops.wm.call_menu(name="OBJECT_MT_select_test")