Behaviour module UI


import Atoms
import AtomsCore
import AtomsMath
import os

class HardContstructorTests(Atoms.BehaviourModule):
    def __init__(self):
        Atoms.BehaviourModule.__init__(self)
        
        meta_type =  AtomsCore.IntMetadata()
        self.addAttribute("type", meta_type, True)
        

        self.addAttribute("p1", meta_type, True)
        self.addAttribute("p2", meta_type, True)

        
        self.addAttribute("h1", meta_type, True)
        self.addAttribute("h2", meta_type, True)                
       

        BEHAVIOUR = Atoms.GLOBAL_NAMES.BEHAVIOUR
        
        #tooltip
        tooltip_type = AtomsCore.StringMetadata("Metadata type id")
        self.addAttributeProperty("type",  BEHAVIOUR.TOOLTIP, tooltip_type)


        # hard constructor
        hc = AtomsCore.StringMetadata(BEHAVIOUR.HARD_CONSTRUCTORS.COMBOBOX)
        self.addAttributeProperty("type", BEHAVIOUR.HARD_CONSTRUCTOR, hc)

        # values and labels for the combobox
        values = AtomsCore.UIntArrayMetadata()
        values.set([0, 1, 2])
        self.addAttributeProperty("type", BEHAVIOUR.VALUE, values)
     

        labels = AtomsCore.StringArrayMetadata()
        labels.set(["first", "second", "third"])
        self.addAttributeProperty("type", BEHAVIOUR.OPTION_LIST, labels);

      
        # enable states
        enable_deps = AtomsCore.ArrayMetadata()
        el1 = AtomsCore.StringArrayMetadata()
        el1.set(["p1"])
        el2 = AtomsCore.StringArrayMetadata()
        el2.set(["p2"])
        el3 = AtomsCore.StringArrayMetadata()
        el3.set([])
        enable_deps.append(el1)
        enable_deps.append(el2)
        enable_deps.append(el3)

        self.addAttributeProperty("type", BEHAVIOUR.ENABLE_STATUS_DEPENDENCY, enable_deps)


        # visibility states  
        vis_deps = AtomsCore.ArrayMetadata()
        el1 = AtomsCore.StringArrayMetadata()
        el1.set(["h1"])
        el2 = AtomsCore.StringArrayMetadata()
        el2.set(["h2"])
        el3 = AtomsCore.StringArrayMetadata()
        el3.set([])
        vis_deps.append(el1)
        vis_deps.append(el2)
        vis_deps.append(el3)

        self.addAttributeProperty("type", BEHAVIOUR.VISIBLE_STATUS_DEPENDENCY, vis_deps)

    
    @staticmethod
    def category():
        return "Python"







Copyright © 2017, Toolchefs LTD.