Hi All,
I have taken Ricky’s panel demo code and modified it into a first draft for the BlendText conversion.
The modification I made was for the draw routine to draw controls in the properties panel of the active object
instead of in the tools panel as Ricky had.
BlendText is going to extend an existing object (typically an empty), not generate one.
Paste this code in to a text window and run it with ALT-P.
Then select the object properties TAB and
the BlendText panel will appear when you move your mouse into the properties area.
Here is the code:
import bpy
import mathutils
from math import *
from bpy.props import *
"""
Name: 'General Triangles'
Blender: 250
"""
__author__ = ["Rickyblender "]
__version__ = '0.0.1'
__url__ = [" "]
__bpydoc__ = """
"""
last_method = 'None'
last_methodmenu1= 'None'
hypo=0.0
###############
bpy.types.Scene.BoolProperty( attr = 'MyBoolProperty', default = True)
subtypes = ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE','XYZ', 'COLOR_GAMMA', 'LAYER']#, 'NONE']
for subtype in subtypes:
bpy.types.Scene.FloatVectorProperty( attr = 'FloatVector' + subtype, default = [0.0, 0.0, 0.0], subtype= subtype)
##############
last_method = 'None'
class myPanel(bpy.types.Panel): # This is the panel
# Panel
bl_label = "BlendText" # Called this
#bl_space_type = "VIEW_3D" # in 3D view
#bl_region_type = "TOOL_PROPS" # in Operator's panel in tool shelf
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW" # in Operator's panel in tool shelf
def draw(self, context):
global last_method # make this global to find the last operation
layout = self.layout
scene = context.scene
col = layout.column()
col.label(' A menu that executes operators:', 'UI')
col.operator_menu_enum('view_3d.my_operator', 'method', 'Operate') # Here the operator menu is displayed
# 'view_3d.my_operator' is the bl_idname of the operator called
# No box draw on GUI only the Menu name = Operate and list used is called = method
col.separator()
col.label('Font Metrics:')
col.prop(scene, "MyBoolProperty", text = "Generate Font CAPs")
col.separator()
col.label('Effector Scale Influence:')
subtype ='XYZ'
col.prop(scene, 'FloatVector' +subtype )
col.separator()
col.label('Font Material:')
subtype ='COLOR'
col.prop(scene, 'FloatVector' +subtype )
##############
class myOperator(bpy.types.Operator): # When an option in the operator menu is clicked, this is called
# Operator
bl_idname = 'view_3d.my_operator'
bl_label = 'Operator'
# Define possible operations
method = EnumProperty(items=(
('1 inclass', 'One op', 'The first item 111'),
('2 inclass', 'Two op', 'The second item 222'),
('3 inclass', 'Three op', 'The third item 333'),
('3 inclass', 'Fourth op', 'The Fourth item 444')))
def execute(self, context):
global last_method # Make global so we can later draw it in the panel
last_method = self.properties.method # Store the choosen operation
print ('in myoperator Selection =',last_method)
return {'FINISHED'}
So now I have some controls in a panel under the object context.
But the only control that generates an event seems to be the menu,
because it is initiated as an operator.
Q: How can I get events like the check box click or number change to appear in my code for processing?
Q: What kind of callbacks or setups need to be done so I can capture these events for processing?