Skip to content

Commit

Permalink
Merge pull request #435 from og76/patch-1
Browse files Browse the repository at this point in the history
Create change_text_case.py
  • Loading branch information
JacquesLucke committed Mar 25, 2016
2 parents 35535bf + 4260788 commit 21e37f4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions nodes/text/change_text_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import bpy
from bpy.props import *
from ... events import executionCodeChanged
from ... base_types.node import AnimationNode

caseTypeItems= [("UPPER", "To Upper Case", ""),
("LOWER", "To Lower Case", ""),
("CAPITALIZE", "Capitalize Phrase", "") ]

caseTypeCode = { item[0] : item[0].lower() for item in caseTypeItems }

class ChangeTextCaseNode(bpy.types.Node, AnimationNode):
bl_idname = "an_ChangeTextCaseNode"
bl_label = "Change Text Case"

def caseTypeChanges(self, context):
executionCodeChanged()

caseType = EnumProperty(
name = "Case Type", default = "CAPITALIZE",
items = caseTypeItems, update = caseTypeChanges)

def create(self):
self.inputs.new("an_StringSocket", "Text", "inText")
self.outputs.new("an_StringSocket", "Text", "outText")

def draw(self, layout):
layout.prop(self, "caseType", text = "")

def getExecutionCode(self):
return "outText = inText.{}()".format(caseTypeCode[self.caseType])

0 comments on commit 21e37f4

Please sign in to comment.