Project: Blender Extensions
Tracker: Py Scripts Upload
Blender: 2.54
Category: Templates
Python: 3.1
Script name: Ping Pong
Author(s): Crouch
Status: Closed
This script is uploaded as a simple example to get started with scripting in Blender. Below you'll find an explanation of how it works.
The OBJECT_PT_pingpong class is to draw the gui.
'bl_space_type' is the kind of space it shows upis. "PROPERTIES" is the new name for what the buttons window was in Blender 2.4x, so that's where you'll find it.
'bl_region_type' is the kind of region it shows up in.
'bl_context' is when the panel will show (so you will need to have an object selected, for the panel to show up).
'bl_label' is the text displayed in the header.
'display' is a custom variable which we use te determine which button needs to be displayed.
'draw_header' is used to draw extra things in the header. In our case an icon. You can also use it to draw a checkbox that enables or disables all the settings in the panel.
'draw' defines the content of the panel. There is a single row, which is split in half. Each half contains a column. Aditionally we draw a button in one of these columns. The 'display' variable determines which one we draw. 0 = the left one, 1 = the right one. These buttons refer to an operator called 'pipo', which is the idname of the next class.
The OBJECT_OT_pingpong class defines our custom operator.
'bl_label' is the default text that's used by buttons in the user-interface (which we overwrite by for instance: text="Ping" )
'bl_idname' is what we use to refer to this operator.
'bl_description' is the text that shows up when you hover over a button that calls this operator (a bit like a tooltip).
'invoke' is called whenever a button calls the class.
'report' displays a message in the main header of Blender. After this line we also set the 'display' variable to the other value (0 if it's 1 right now, and vice versa).