Difference between revisions of "Template:Snippet"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(Code:)
(Undo revision 23440 by Ivo.grigull (talk))
Line 14: Line 14:
 
{{{summary|}}}
 
{{{summary|}}}
 
<br />
 
<br />
<syntaxhighlight lang="python">
+
===Code:===
import lx
+
{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|}}} }}
import lxifc
+
[[Category: {{{lang|}}}]]
import lxu.command
+
</includeonly>
 
+
 
+
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 16:04, 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.