Use native python libraries on 2.54 doesn't work?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
FidoX
Posts: 0
Joined: Tue Sep 07, 2010 12:56 pm

Use native python libraries on 2.54 doesn't work?

Post by FidoX » Wed Sep 15, 2010 2:58 pm

This works to somebody on 2.54?

Code: Select all

import bpy
import os

class TestPanel(bpy.types.Panel):
	bl_space_type = "PROPERTIES"
	bl_region_type = "WINDOW"
	bl_context = "render"
	bl_label = "Test import os"
		
	def draw(self, context):
		layout = self.layout
		scene = context.scene
		print(os)
		row = layout.row(align=True)
		if(os == None):							   
			row.label("os not imported")


bpy.types.unregister(TestPanel)
bpy.types.register(TestPanel)

dfelinto
Posts: 0
Joined: Wed May 17, 2006 8:44 pm
Location: Rio de Janeiro, Brasil

Post by dfelinto » Wed Oct 13, 2010 7:33 pm

Hi,
this will not work. There is no longer need to register and unregister your operators. The only thing you need to register now are properties stored in your blender objects (e.g. scene.my_custom_property). Your sample code rewritten for current API would be:

Code: Select all

import bpy 
import os 

class TestPanel(bpy.types.Panel): 
   bl_space_type = "PROPERTIES" 
   bl_region_type = "WINDOW" 
   bl_context = "render" 
   bl_label = "Test import os" 
       
   def draw(self, context): 
      layout = self.layout 
      scene = context.scene 
      print(os) 
      row = layout.row(align=True) 
      if(os == None):                         
         row.label("os not imported")
      else:
         row.label("os imported")

def register():
    pass

def unregister():
    pass

if __name__ == "__main__":
    pass
Rio de Janeiro - Brasil
http://blenderecia.orgfree.com

Post Reply