def __init__(self, parent, object=None, entity=False):
        wx.Panel.__init__(self, parent, -1)

        self.object = object
        self.entity = entity
        self.xml = readshared.get_xml_dom()

        nebulagui.nebula_object = self.object

        # Expand all button
        btn_expand = wx.Button(self, -1, "Expand All")

        # Collapse all button
        btn_collapse = wx.Button(self, -1, "Collapse All")

        # Property grid
        # N.B. the state property grid is NOT sorted -
        # see task #4270
        self.cmds_pg = pg.wxPropertyGrid(
            self, -1, wx.DefaultPosition, wx.DefaultSize, pg.wxPG_BOLD_MODIFIED
            | pg.wxPG_DEFAULT_STYLE | pg.wxPG_SPLITTER_AUTO_CENTER)

        # Default button
        btn_default = wx.Button(self, -1, "Default")

        # Save button
        btn_save = wx.Button(self, -1, "Save")

        # Display the state commands
        self.draw_state_commands(self.object)

        # Do layout
        border_width = cfg.BORDER_WIDTH
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_buttons.Add(btn_expand, 0, wx.ADJUST_MINSIZE)
        sizer_buttons.Add(btn_collapse, 0, wx.ADJUST_MINSIZE | wx.LEFT,
                          border_width)
        sizer.Add(sizer_buttons, 0, wx.EXPAND | wx.ALL, border_width)
        sizer_cmds = wx.BoxSizer(wx.HORIZONTAL)
        sizer_cmds.Add(self.cmds_pg, 1, wx.EXPAND)
        sizer.Add(sizer_cmds, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, border_width)
        sizer_more_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_more_buttons.Add(btn_default, 0)
        sizer_more_buttons.Add(btn_save, 0, wx.ADJUST_MINSIZE | wx.LEFT,
                               border_width)
        sizer.Add(sizer_more_buttons, 0, wx.ALIGN_RIGHT | wx.ALL, border_width)
        self.SetSizer(sizer)

        # Set tooltips
        btn_expand.SetToolTip(wx.ToolTip("Expand all categories"))
        btn_collapse.SetToolTip(wx.ToolTip("Collapse all categories"))
        btn_default.SetToolTip(wx.ToolTip("Return to original state"))
        btn_save.SetToolTip(wx.ToolTip("Save the new state"))

        # Bind events
        self.Bind(wx.EVT_BUTTON, self.on_expand_button, btn_expand)
        self.Bind(wx.EVT_BUTTON, self.on_collpase_button, btn_collapse)
        self.Bind(wx.EVT_BUTTON, self.on_save_button, btn_save)
        self.Bind(wx.EVT_BUTTON, self.on_default_button, btn_default)
 def __init__ (self, object):
     scriptingmodel.ScriptingModel.__init__(self, object)
     self.property_list = []
     self.xml = readshared.get_xml_dom()           # xml DOM interface
     self.object_info = self.get_object_info()   # Info extracted from xml
     if self.object_info == None:
         return None
     self.comp_list = self.build_component_list()
     self.command_list = self.build_command_list()
     self.values = {}           # Actual values
     self.init_values = {}     # Values used for retore to init state
     self.refresh( True )       # Initialize values (and init values)
     self.object = object
示例#3
0
 def __init__(self, object):
     scriptingmodel.ScriptingModel.__init__(self, object)
     self.property_list = []
     self.xml = readshared.get_xml_dom()  # xml DOM interface
     self.object_info = self.get_object_info()  # Info extracted from xml
     if self.object_info == None:
         return None
     self.comp_list = self.build_component_list()
     self.command_list = self.build_command_list()
     self.values = {}  # Actual values
     self.init_values = {}  # Values used for retore to init state
     self.refresh(True)  # Initialize values (and init values)
     self.object = object
    def __init__(self, parent, object=None, entity = False):
        wx.Panel.__init__(self, parent, -1)     

        self.object = object
        self.entity = entity
        self.xml = readshared.get_xml_dom()

        nebulagui.nebula_object = self.object

        # Expand all button
        btn_expand = wx.Button(self, -1, "Expand All")

        # Collapse all button
        btn_collapse = wx.Button(self, -1, "Collapse All")
        
        # Property grid 
        # N.B. the state property grid is NOT sorted - 
        # see task #4270
        self.cmds_pg = pg.wxPropertyGrid(
                                self, 
                                -1, 
                                wx.DefaultPosition, 
                                wx.DefaultSize, 
                                pg.wxPG_BOLD_MODIFIED|
                                    pg.wxPG_DEFAULT_STYLE|
                                    pg.wxPG_SPLITTER_AUTO_CENTER
                                )

        # Default button
        btn_default = wx.Button(self, -1, "Default")

        # Save button
        btn_save = wx.Button(self, -1, "Save")

        # Display the state commands
        self.draw_state_commands(self.object)
        
        # Do layout
        border_width = cfg.BORDER_WIDTH
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_buttons.Add(btn_expand, 0, wx.ADJUST_MINSIZE)
        sizer_buttons.Add(
            btn_collapse, 
            0, 
            wx.ADJUST_MINSIZE|wx.LEFT, 
            border_width
            )
        sizer.Add(sizer_buttons, 0, wx.EXPAND|wx.ALL, border_width)
        sizer_cmds = wx.BoxSizer(wx.HORIZONTAL)
        sizer_cmds.Add(self.cmds_pg, 1, wx.EXPAND)
        sizer.Add(sizer_cmds, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, border_width)
        sizer_more_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_more_buttons.Add(btn_default, 0)
        sizer_more_buttons.Add(
            btn_save, 
            0, 
            wx.ADJUST_MINSIZE|wx.LEFT, 
            border_width
            )
        sizer.Add(sizer_more_buttons, 0, wx.ALIGN_RIGHT|wx.ALL, border_width)
        self.SetSizer(sizer)

        # Set tooltips
        btn_expand.SetToolTip(
            wx.ToolTip("Expand all categories")
            )
        btn_collapse.SetToolTip(
            wx.ToolTip("Collapse all categories")
            )
        btn_default.SetToolTip(
            wx.ToolTip("Return to original state")
            )
        btn_save.SetToolTip(
            wx.ToolTip("Save the new state")
            )

        # Bind events
        self.Bind(wx.EVT_BUTTON, self.on_expand_button, btn_expand)
        self.Bind(wx.EVT_BUTTON, self.on_collpase_button, btn_collapse)
        self.Bind(wx.EVT_BUTTON, self.on_save_button, btn_save)
        self.Bind(wx.EVT_BUTTON, self.on_default_button, btn_default)    
    def __init__(self, parent, object=None, entity = False):
        wx.Panel.__init__(self, parent, -1)
        self.object = object
        self.entity = entity
        nebulagui.nebula_object = self.object
        self.parent = parent
        self.executed = False
        self.inspector = "savecmds"
        self.xml = readshared.get_xml_dom()

        ## Create controls

        # Text label

        text_class = wx.StaticText(self, -1, "Class")

        # Classes combobox. We have to get the list of classes from object
        # If some class is not in the xml file use the savecmds inspector
        class_list = list()
        if object != None:
            for class_name in object.getclasses():
                class_list.append(class_name)
        class_list.append("All")

        self.classes = wx.ComboBox(
                                self, 
                                -1, 
                                "Choose class",
                                 size=wx.DefaultSize,
                                 choices=class_list,
                                 style=wx.CB_DROPDOWN
                                 )

        # Text label
        text_command = wx.StaticText(self, -1, "Command")

        # Commands combobox
        self.cmds = wx.ComboBox(
                            self, 
                            -1, 
                            "Choose command",
                            size=wx.DefaultSize,
                            style=wx.CB_DROPDOWN|wx.CB_SORT
                            )

        # Property grid.
        self.cmds_pg = pg.wxPropertyGrid(
                                self, 
                                -1, 
                                wx.DefaultPosition, 
                                wx.DefaultSize, 
                                pg.wxPG_BOLD_MODIFIED
                                |pg.wxPG_DEFAULT_STYLE
                                |pg.wxPG_SPLITTER_AUTO_CENTER
                                |pg.wxPG_FLOAT_PRECISION
                                )

        # Get button
        self.btn_get = wx.Button(self, -1, "Get")
        self.btn_get.Disable()

        # Execute button
        self.btn_exec = wx.Button(self, -1, "Execute")
        self.btn_exec.Disable()

        # Doc text
        self.doc_box = wx.StaticBox(self, -1, "Documentation")
        self.doc_text = wx.StaticText(
                                self, 
                                -1, 
                                "Documentation for classes and commands"
                                )

        # Do layout
        border_width = cfg.BORDER_WIDTH
        sizer = wx.BoxSizer(wx.VERTICAL)
        grid_sizer = wx.FlexGridSizer(2, 2, border_width, border_width * 2)
        grid_sizer.AddGrowableCol(1)
        grid_sizer.Add(
            text_class, 
            0, 
            cfg.LABEL_ALIGN|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE
            )
        grid_sizer.Add(self.classes, 0, wx.ADJUST_MINSIZE|wx.EXPAND)
        grid_sizer.Add(
            text_command, 
            0, 
            cfg.LABEL_ALIGN|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE
            )
        grid_sizer.Add(self.cmds, 0, wx.ADJUST_MINSIZE | wx.EXPAND)
        sizer.Add(grid_sizer, 0, wx.ALL|wx.EXPAND, border_width)
        
        sizer_property_grid = wx.BoxSizer(wx.HORIZONTAL)
        sizer_property_grid.Add(self.cmds_pg, 1, wx.EXPAND)
        sizer.Add(sizer_property_grid, 1, wx.EXPAND|wx.ALL, border_width)

        bsizer = wx.StaticBoxSizer(self.doc_box, wx.VERTICAL)
        bsizer.Add(self.doc_text, 0, wx.ALL, border_width)
        sizer.Add(bsizer, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, border_width)

        sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_buttons.Add(self.btn_get, 0)
        sizer_buttons.Add(self.btn_exec, 0, wx.LEFT, border_width)
        sizer.Add(sizer_buttons, 0, wx.ALL|wx.ALIGN_RIGHT, border_width)

        self.SetSizer(sizer)

        ## Set Tooltips

        self.btn_get.SetToolTip(
            wx.ToolTip(
                "Click to update the field values with the current " \
                "command state (Only valid for set commands)"
                )
            )
        self.btn_exec.SetToolTip(
            wx.ToolTip("Click to execute the command")
            )

        ## Bind events

        self.cmds_pg.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
        self.classes.Bind(wx.EVT_COMBOBOX, self.on_class_select)
        self.classes.Bind(wx.EVT_CHAR, self.on_combo_char)
        self.classes.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
        self.cmds.Bind(wx.EVT_COMBOBOX, self.on_cmds_select)
        self.cmds.Bind(wx.EVT_CHAR, self.on_combo_char)
        self.Bind(wx.EVT_BUTTON, self.on_get_button, self.btn_get)
        self.Bind(wx.EVT_BUTTON, self.on_execute_button, self.btn_exec)
        self.Bind(pg.EVT_PG_CHANGED, self.on_pg, self.cmds_pg)
        self.Bind(wx.EVT_SIZE, self.OnSize)