Пример #1
0
def cmds_select(inspector, cmd_name):
    inspector.cmds_pg.Clear()

    # get command
    inspector.cmd = inspector.xml.get_cmd_by_name(
        inspector.class_info[0]["commands"], cmd_name)

    # get and update doc
    doc = inspector.xml.get_cmd_doc(inspector.cmd)
    inspector.doc_text.SetLabel(doc)
    inspector.Layout()

    # Draw In properties
    inspector.in_elements = list()
    inspector.out_elements = list()

    inspector.in_params = inspector.xml.get_cmd_input(inspector.cmd)

    if len(inspector.in_params) > 0:
        inspector.cmds_pg.Append(pg.wxPropertyCategory("In Args", "InValues"))
        __draw_input_fields(inspector, inspector.in_params, "in")

    # Draw Out properties
    inspector.out_params = inspector.xml.get_cmd_output(inspector.cmd)

    if len(inspector.out_params) > 0:
        inspector.cmds_pg.Append(pg.wxPropertyCategory("Out Args",
                                                       "OutValues"))
        __draw_input_fields(inspector, inspector.out_params, "out")

    inspector.btn_exec.Enable()
    inspector.cmds_pg.Refresh()
Пример #2
0
def cmds_select(inspector, cmd_name):
    inspector.cmds_pg.Clear()        
    
    # get command
    inspector.cmd = inspector.xml.get_cmd_by_name(
                            inspector.class_info[0]["commands"], 
                            cmd_name
                            )

    # get and update doc
    doc = inspector.xml.get_cmd_doc(inspector.cmd)
    inspector.doc_text.SetLabel(doc)
    inspector.Layout()

    # Draw In properties
    inspector.in_elements = list()
    inspector.out_elements = list()

    inspector.in_params = inspector.xml.get_cmd_input(inspector.cmd)

    if len(inspector.in_params) > 0:
        inspector.cmds_pg.Append(
            pg.wxPropertyCategory( 
                "In Args", 
                "InValues" 
                )
            )
        __draw_input_fields(
            inspector, 
            inspector.in_params, 
            "in"
            )

    # Draw Out properties
    inspector.out_params = inspector.xml.get_cmd_output(inspector.cmd)

    if len(inspector.out_params) > 0:
        inspector.cmds_pg.Append(
            pg.wxPropertyCategory(
                "Out Args", 
                "OutValues")
                )
        __draw_input_fields(
            inspector, 
            inspector.out_params, 
            "out"
            )

    inspector.btn_exec.Enable()
    inspector.cmds_pg.Refresh()
Пример #3
0
 def append_category(self, name):
     """Add a new category """
     label = "category_" + name
     prop = pg.wxPropertyCategory(name, label)
     pid = self.Append( prop )
     # If only
     if self.categories[0].name == None:
         self.categories[0] = _CategoryNode(name)
     return pid
Пример #4
0
    def draw_state_commands(self, obj):
        self.cmds_pg.Clear()

        if obj is None:
            self.Disable()
            return
        else:
            self.Enable()

        # Get the commands

        inspector = pynebula.new(
                            "nobjinspector",
                            "/editor/inspector"
                            )
        inspector.initcmdsstate(obj)

        # Navigate over the commands and build the interface. We need
        # the command definition to put it in the category. So first create
        # the grid properties  but do not append them until the category
        # is placed with the full description.

        cmds_count = inspector.getcmdscount() 
        self.cmd_list = list()       # Command list
        self.cmd_name_list = list()  # Store the categories
        self.undo_list = list()

        if cmds_count == 0:
            self.cmds_pg.Append(
                pg.wxPropertyCategory(
                    str("State is EMPTY"), 
                    str("nostate")
                    )
                )

        self.prev_state = list() # Storage state when the inspector is call
        for num_cmd in xrange(cmds_count):
            cmds_name_desc = inspector.getcmdname(num_cmd) + str(" (")
            undo_cmd = inspector.getcmdname(num_cmd) + str("(")
            args_count = inspector.getinargscount(num_cmd)
            self.element = list()   # Start argument list            

            for num_arg in xrange(args_count):                
                label = "label_in" + str(num_cmd) + "-" + str(num_arg+1)
                arg_type = inspector.gettype(num_cmd, num_arg+1)

                # Type is Int

                if arg_type == 1:
                    value = inspector.geti(num_cmd, num_arg+1)
                    self.element.append(
                        pg.wxIntProperty(
                            'Integer', 
                            label
                            )
                        )
                    value_as_string = str(value)
                    self.element[num_arg].SetValueFromString(
                        value_as_string, 
                        0
                        )
                    self.prev_state.append(value_as_string)
                    cmds_name_desc = cmds_name_desc + value_as_string + ", "
                    undo_cmd = undo_cmd + value_as_string + ","

                # Type is Float

                elif arg_type == 2:
                    value = inspector.getf(num_cmd, num_arg+1)
                    self.element.append(
                        pg.wxFloatProperty(
                            'Float', 
                            label
                            )
                        )
                    value_as_string = str(value)    
                    self.element[num_arg].SetValueFromString(
                        value_as_string,
                        0
                        )
                    self.prev_state.append(value_as_string)
                    undo_cmd = undo_cmd + value_as_string + ","
                    temp = value_as_string.rsplit('.')
                    value = temp[0] + '.' + temp[1][:2]
                    cmds_name_desc = cmds_name_desc + value_as_string + ", "

                # Type if String

                elif arg_type == 3:
                    value = inspector.gets(num_cmd, num_arg+1)
                    self.element.append(
                        pg.wxStringProperty(
                            'String',
                            label, 
                            ''
                            )
                        )
                    value_as_string = str(value)
                    self.element[num_arg].SetValueFromString(
                        value_as_string,
                        0
                        )
                    self.prev_state.append(value_as_string)
                    cmds_name_desc = cmds_name_desc +\
                                   '"' + value_as_string + '"' + ", "
                    undo_cmd = undo_cmd + '"' + value_as_string + '"' + ","

                # Type is Boolean

                elif arg_type == 4:
                    value = inspector.getb(num_cmd, num_arg+1)
                    self.element.append(
                        pg.wxEnumProperty(
                            'Boolean', 
                            label,
                            ['True','False'],
                            [1,0],
                            2 
                            )
                        )
                    if value == 1:
                        self.element[num_arg].SetValueFromString(
                            str("True"), 
                            0
                            )
                        cmds_name_desc = cmds_name_desc + str('True') + ", "
                        self.prev_state.append('True')
                    else:
                        self.element[num_arg].SetValueFromString(
                            str("False"), 
                            0
                            )
                        cmds_name_desc = cmds_name_desc + str('False') + ", "
                        self.prev_state.append('False')
                    undo_cmd = undo_cmd + str(value) + ","

                # Type is Object

                elif arg_type == 5:
                    value = inspector.geto(num_cmd, num_arg+1)             
                    self.element.append(
                        pg.wxStringProperty(
                            'Object', 
                            label, 
                            ''
                            )
                        )
                    full_name_as_string = str( value.getfullname() )
                    self.element[num_arg].SetValueFromString(
                        full_name_as_string,
                        0
                        )
                    self.prev_state.append(full_name_as_string)
                    cmds_name_desc = cmds_name_desc +\
                                   str(value.getname()) + ", "
                    undo_cmd = undo_cmd + "lookup(" + \
                                            full_name_as_string + "),"

                # Type not implemented

                else:
                    cjr.show_error_message("Unknown type!!!")

            # Write the command definition into the category and attach it

            if args_count > 0:
                cmds_name_desc = cmds_name_desc[:-2] + ")"
                undo_cmd = undo_cmd[:-1] + ")"
            else:
                cmds_name_desc = cmds_name_desc + ")"
                undo_cmd = undo_cmd + ")"

            category = pg.wxPropertyCategory(
                                cmds_name_desc, 
                                "cmdLabel%d" % num_cmd
                                )
            self.cmds_pg.Append(category)
            self.cmd_name_list.append(
                inspector.getcmdprotoname(num_cmd)
                )

            # Show the arguments (append to grid) recently created 
            # and append them to a command list

            for num_arg in xrange(args_count):
                self.cmds_pg.Append(self.element[num_arg])
            
            self.cmd_list.append(self.element)

            self.undo_list.append(undo_cmd)

        pynebula.delete("/editor/inspector")

        # Make de object the current

        nebulagui.nebula_object = obj
        self.object = obj

        # Refresh control
        self.cmds_pg.Refresh()
Пример #5
0
    def draw_state_commands(self, obj):
        self.cmds_pg.Clear()

        if obj is None:
            self.Disable()
            return
        else:
            self.Enable()

        # Get the commands

        inspector = pynebula.new("nobjinspector", "/editor/inspector")
        inspector.initcmdsstate(obj)

        # Navigate over the commands and build the interface. We need
        # the command definition to put it in the category. So first create
        # the grid properties  but do not append them until the category
        # is placed with the full description.

        cmds_count = inspector.getcmdscount()
        self.cmd_list = list()  # Command list
        self.cmd_name_list = list()  # Store the categories
        self.undo_list = list()

        if cmds_count == 0:
            self.cmds_pg.Append(
                pg.wxPropertyCategory(str("State is EMPTY"), str("nostate")))

        self.prev_state = list()  # Storage state when the inspector is call
        for num_cmd in xrange(cmds_count):
            cmds_name_desc = inspector.getcmdname(num_cmd) + str(" (")
            undo_cmd = inspector.getcmdname(num_cmd) + str("(")
            args_count = inspector.getinargscount(num_cmd)
            self.element = list()  # Start argument list

            for num_arg in xrange(args_count):
                label = "label_in" + str(num_cmd) + "-" + str(num_arg + 1)
                arg_type = inspector.gettype(num_cmd, num_arg + 1)

                # Type is Int

                if arg_type == 1:
                    value = inspector.geti(num_cmd, num_arg + 1)
                    self.element.append(pg.wxIntProperty('Integer', label))
                    value_as_string = str(value)
                    self.element[num_arg].SetValueFromString(
                        value_as_string, 0)
                    self.prev_state.append(value_as_string)
                    cmds_name_desc = cmds_name_desc + value_as_string + ", "
                    undo_cmd = undo_cmd + value_as_string + ","

                # Type is Float

                elif arg_type == 2:
                    value = inspector.getf(num_cmd, num_arg + 1)
                    self.element.append(pg.wxFloatProperty('Float', label))
                    value_as_string = str(value)
                    self.element[num_arg].SetValueFromString(
                        value_as_string, 0)
                    self.prev_state.append(value_as_string)
                    undo_cmd = undo_cmd + value_as_string + ","
                    temp = value_as_string.rsplit('.')
                    value = temp[0] + '.' + temp[1][:2]
                    cmds_name_desc = cmds_name_desc + value_as_string + ", "

                # Type if String

                elif arg_type == 3:
                    value = inspector.gets(num_cmd, num_arg + 1)
                    self.element.append(
                        pg.wxStringProperty('String', label, ''))
                    value_as_string = str(value)
                    self.element[num_arg].SetValueFromString(
                        value_as_string, 0)
                    self.prev_state.append(value_as_string)
                    cmds_name_desc = cmds_name_desc +\
                                   '"' + value_as_string + '"' + ", "
                    undo_cmd = undo_cmd + '"' + value_as_string + '"' + ","

                # Type is Boolean

                elif arg_type == 4:
                    value = inspector.getb(num_cmd, num_arg + 1)
                    self.element.append(
                        pg.wxEnumProperty('Boolean', label, ['True', 'False'],
                                          [1, 0], 2))
                    if value == 1:
                        self.element[num_arg].SetValueFromString(
                            str("True"), 0)
                        cmds_name_desc = cmds_name_desc + str('True') + ", "
                        self.prev_state.append('True')
                    else:
                        self.element[num_arg].SetValueFromString(
                            str("False"), 0)
                        cmds_name_desc = cmds_name_desc + str('False') + ", "
                        self.prev_state.append('False')
                    undo_cmd = undo_cmd + str(value) + ","

                # Type is Object

                elif arg_type == 5:
                    value = inspector.geto(num_cmd, num_arg + 1)
                    self.element.append(
                        pg.wxStringProperty('Object', label, ''))
                    full_name_as_string = str(value.getfullname())
                    self.element[num_arg].SetValueFromString(
                        full_name_as_string, 0)
                    self.prev_state.append(full_name_as_string)
                    cmds_name_desc = cmds_name_desc +\
                                   str(value.getname()) + ", "
                    undo_cmd = undo_cmd + "lookup(" + \
                                            full_name_as_string + "),"

                # Type not implemented

                else:
                    cjr.show_error_message("Unknown type!!!")

            # Write the command definition into the category and attach it

            if args_count > 0:
                cmds_name_desc = cmds_name_desc[:-2] + ")"
                undo_cmd = undo_cmd[:-1] + ")"
            else:
                cmds_name_desc = cmds_name_desc + ")"
                undo_cmd = undo_cmd + ")"

            category = pg.wxPropertyCategory(cmds_name_desc,
                                             "cmdLabel%d" % num_cmd)
            self.cmds_pg.Append(category)
            self.cmd_name_list.append(inspector.getcmdprotoname(num_cmd))

            # Show the arguments (append to grid) recently created
            # and append them to a command list

            for num_arg in xrange(args_count):
                self.cmds_pg.Append(self.element[num_arg])

            self.cmd_list.append(self.element)

            self.undo_list.append(undo_cmd)

        pynebula.delete("/editor/inspector")

        # Make de object the current

        nebulagui.nebula_object = obj
        self.object = obj

        # Refresh control
        self.cmds_pg.Refresh()
    def on_signal_select(self, evt):
        cmd_name = self.cmds.GetStringSelection()

        self.cmds_pg.Clear()        
        class_name = self.classes.GetStringSelection()

        # Temporary object to get the commands: must be deleted after use!!
        inspector = pynebula.new(
                            "nobjinspector",
                            "/editor/inspector"
                            )
        if class_name == "All":
            for name in self.object.getclasses():
                inspector.initsignalsclass( str(name) )
        else:
            inspector.initsignalsclass( str(class_name) )

        # Build a dictionary with the cmd name and its
        # position in the array: this way I can list the cmds
        # alphabetically
        self.cmd_dict = dict()
        for index in xrange( inspector.getcmdscount() ):
            self.cmd_dict[inspector.getcmdname(index)] = index

        num_cmd = self.cmd_dict[cmd_name]
        num_args = inspector.getinargscount(num_cmd)

        # Build the properties depending of the argument type
        self.cmd_proto_name = inspector.getcmdprotoname(num_cmd)

        arg = self.cmd_proto_name.rsplit('_')

        # Draw In properties
        self.in_elements = list()
        if num_args > 0:
            self.cmds_pg.Append(
                pg.wxPropertyCategory(
                    "In Args", 
                    "InValues" 
                    )
                )
            self.__draw_input_fields(
                arg[2], 
                self.in_elements, 
                "in"
                )

        # Draw Out properties
        self.out_elements = list()
        if inspector.getoutargscount(num_cmd) > 0:
            self.cmds_pg.Append(
                pg.wxPropertyCategory(
                    "Out Args", 
                    "OutValues"
                    )
                )
            self.__draw_input_fields(
                arg[0], 
                self.out_elements, 
                "out"
                )

        # Delete the inspector
        pynebula.delete("/editor/inspector")

        self.btn_send.Enable()
Пример #7
0
def cmds_select(inspector_win):
    cmd_name = inspector_win.cmds.GetStringSelection()

    inspector_win.cmds_pg.Clear()        
    class_name = str( inspector_win.classes.GetStringSelection() )

    # Temporary object to get the commands: must be deleted after use!!
    inspector = pynebula.new(
                        "nobjinspector",
                        "/editor/inspector"
                        )

    if class_name == "All":
        for name in inspector_win.object.getclasses():
            inspector.initcmdsclass( str(name) )
    else:
        inspector.initcmdsclass(class_name)

    # Build a dictionary with the cmd name and its
    # position in the array: this way I can list the cmds
    # alphabetically
    inspector_win.cmd_dict = dict()
    for index in xrange( inspector.getcmdscount() ):
        inspector_win.cmd_dict[inspector.getcmdname(index)] = index

    num_cmd = inspector_win.cmd_dict[cmd_name]
    num_args = inspector.getinargscount(num_cmd)        

    # Enable the get button if the command has a get counterpart
    if re.compile("set.*").match(cmd_name):
        name = cmd_name[3:]
        try:
            num_getcmd = inspector_win.cmd_dict[str("get"+name)]
            num_get_out_args = inspector.getoutargscount(num_getcmd)
            if num_args != num_get_out_args:
                inspector_win.btn_get.Disable()
            else:
                inspector_win.btn_get.Enable()                
        except:           
            inspector_win.btn_get.Disable()
    else:
        inspector_win.btn_get.Disable()
    
    # Build the properties depending on the argument type
    inspector_win.cmd_proto_name = inspector.getcmdprotoname(num_cmd)

    arg = inspector_win.cmd_proto_name.rsplit('_')              

    # Draw In properties
    inspector_win.in_elements = list()  
    if num_args > 0:
        inspector_win.cmds_pg.Append(
            pg.wxPropertyCategory(
                "In Args", 
                "InValues" 
                )
            )
        draw_input_fields(
            inspector_win, 
            arg[2], 
            inspector_win.in_elements, 
            "in"
            )
        
    # Draw Out properties
    inspector_win.out_elements = list()
    if inspector.getoutargscount(num_cmd) > 0:
        inspector_win.cmds_pg.Append(
            pg.wxPropertyCategory(
                "Out Args", 
                "OutValues"
                )
            )
        draw_input_fields(
            inspector_win, 
            arg[0], 
            inspector_win.out_elements, 
            "out"
            )

    # Delete the inspector
    pynebula.delete("/editor/inspector")

    inspector_win.btn_exec.Enable()
    inspector_win.cmds_pg.Refresh()