Difference between revisions of "Template:Snippet"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(Code:)
Line 14: Line 14:
 
{{{summary|}}}
 
{{{summary|}}}
 
<br />
 
<br />
===Code:===
+
<syntaxhighlight lang="python">
{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|}}} }}
+
import lx
[[Category: {{{lang|}}}]]
+
import lxifc
</includeonly>
+
import lxu.command
 +
 
 +
 
 +
class CmdDynamicButtonName(lxu.command.BasicCommand):
 +
    def __init__(self):
 +
        lxu.command.BasicCommand.__init__(self)
 +
 
 +
    def cmd_Flags(self):
 +
        return lx.symbol.fCMD_MODEL | lx.symbol.fCMD_UNDO
 +
 
 +
    def basic_Enable(self, msg):
 +
        return True
 +
 
 +
    def cmd_Interact(self):
 +
        pass
 +
 
 +
    def basic_Execute(self, msg, flags):
 +
        lx.notimpl()
 +
 
 +
    def basic_ButtonName(self):
 +
       
 +
        myVariable = 'Something'
 +
        msg_svc = lx.service.Message()
 +
        msg = lx.object.Message(msg_svc.Allocate())
 +
       
 +
        # This selects the message "Result: %1" by it's key "myTableEntryKey" for
 +
        # the current language (en_US by default) from the message table of
 +
        # the config file.
 +
        msg.SetMessage ('myTableKey', 'myTableEntryKey', 0)
 +
       
 +
        # Replaces the '%1' substring with the content of myVariable
 +
        msg.SetArgumentString (1, '%s' % myVariable)
 +
       
 +
        myButtonName = msg_svc.MessageText(msg)
 +
        #Result: 'Result: Something'
 +
       
 +
        return myButtonName
 +
 
 +
lx.bless(CmdDynamicButtonName, "dynamic.label")
 +
 
 +
</syntaxhighlight>

Revision as of 15:59, 2 November 2015

This is the "Snippet" template. It should be called in the following format:

{{Snippet
|summary=
|code=
|lang=
}}

Edit the page to see the template text.