Learning blender python - GUI

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
radubolovan
Posts: 1
Joined: Thu Aug 30, 2012 11:10 am

Learning blender python - GUI

Post by radubolovan » Thu Aug 30, 2012 11:22 am

I just started to learn GUI blender python and go through tutorials and API Doc. Long story short I have this script which I put it in blender_scripts_root/startup:

Code: Select all

import bpy


class CustomDrawOperator(bpy.types.Operator):
	bl_idname = "object.custom_draw"
	bl_label = "Simple Modal Operator"

	filepath = bpy.props.StringProperty(subtype="FILE_PATH")

	def execute(self, context):
		print("Test", self)
		return {'FINISHED'}

	def invoke(self, context, event):
		context.window_manager.fileselect_add(self)
		return {'RUNNING_MODAL'}



class HelloWorldPanel(bpy.types.Panel):
	bl_label		= "Hello World Panel"
	bl_idname		= "OBJECT_PT_hello"
	bl_space_type	= "PROPERTIES"
	bl_region_type	= "WINDOW"
	bl_context		= "object"

	my_test_bool	= bpy.props.BoolProperty(name="my_test_bool", description="a bool property", default=False, options={'ANIMATABLE'}, subtype='NONE', update=None)

	def draw(self, context):
		layout = self.layout

		obj = context.object

		row = layout.row()
		row.label(text="Hello world!", icon='WORLD_DATA')

		row = layout.row()
		row.label(text="Active object is: " + obj.name)
		row = layout.row()
		row.prop(obj, "name")

		row = layout.row()
		row.prop(self, "bl_context")

		row = layout.row()
		row.prop(self, "my_test_bool")

		row = layout.row()
		row.operator("object.custom_draw")


def register():
	bpy.utils.register_class(CustomDrawOperator)
	bpy.utils.register_class(HelloWorldPanel)


def unregister():
	bpy.utils.unregister_class(CustomDrawOperator)
	bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
	register()
Everything is fine, except this:

Code: Select all

row.prop(self, "my_test_bool")
I can't see it. Can someone tell me what I did wrong?

OBS1 - in the console is this info: "property not found: OBJECT_PT_hello.my_test_bool" <- very strange
OBS2 - I have Blender 2.6.2 running on Windows7.

Thanks in advance for any info about my not working code code.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest