[Bf-taskforce25] usage of uiItemR()
Nathan Letwory
jesterking at letwory.net
Mon Aug 10 10:02:22 CEST 2009
Joshua Leung wrote:
> Names with postfix 'R' mean RNA, or data/setting
> Names with postfix 'O' mean Operator, or command/tool
Meaning that, if you want an action to be executed through a button, you
have to create an operator first.
import bpy
class YourOperator(bpy.types.Operator):
'''docstring'''
__idname__ = "some.path.to.operator" # like "myops.resize"
__label__ = "The string you see ie. in command search (ctrl+space)" #
like "My Resize"
__props__ = [] # list of props used, see release/io/export_ply.py for
example
def poll(self, context):
# checks to ensure your operator has what it needs
return True # or False if context is not correct, ie no selected objects
def execute(self, context):
# here your original resize() code
return ('FINISHED', ) # or 'CANCELLED' or any of the others, depending
on what you need
To ensure your own operator actually gets registered to the operator
system, you have to do also:
bpy.ops.add(YourOperator)
Anyway, check export_ply.py and the pov render engine integration
scripts for many cool examples of what you can do to integrate your
code tightly with Blender in a great way.
/Nathan
>
> On Mon, Aug 10, 2009 at 7:12 PM, Stefaan michielsen
> <stefaan.michielsen at gmail.com <mailto:stefaan.michielsen at gmail.com>> wrote:
>
> I can't get the way of how uiItemR() should be used.
>
> for instance I want to create a button that resizes a cube when selected
>
> def resize():
> <code that resizes the current cube>
>
> How can i call this function from within an itemR()?
>
> itemR(context.scene, "resize") doesn't do it.
>
> Help will be deeply appreciated
>
> _______________________________________________
> Bf-taskforce25 mailing list
> Bf-taskforce25 at blender.org <mailto:Bf-taskforce25 at blender.org>
> http://lists.blender.org/mailman/listinfo/bf-taskforce25
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Bf-taskforce25 mailing list
> Bf-taskforce25 at blender.org
> http://lists.blender.org/mailman/listinfo/bf-taskforce25
--
Nathan Letwory
http://www.planetblender.org | http://www.blender-fi.org
More information about the Bf-taskforce25
mailing list