示例#1
0
    def __init__(self,
                 element,
                 showRun=True,
                 mode='mini',
                 icon=None,
                 networkInspectorName=None,
                 tabIndex=None):
        """
    element -- A RuntimeElement.
    showRun -- Whether to show the RuntimeInspector in the dropdown.
    mode -- Initial mode for selecting inspectors, either 'mini' or 'grid'.
    networkInspectorName -- Stirng representation of a NetworkInspector
      subclass, used as the initial inspector.
    tabIndex -- Which tab to show initially (RegionInspectors only).
    """

        focused = wx.Window.FindFocus()

        wx.Frame.__init__(self,
                          None,
                          style=wx.DEFAULT_FRAME_STYLE - wx.MAXIMIZE_BOX -
                          wx.RESIZE_BORDER)

        if icon:
            self.SetIcon(icon)

        self.panel = MultiInspectorPanel(
            element=element,
            parent=self,
            embed=False,
            showRun=showRun,
            mode=mode,
            networkInspectorName=networkInspectorName,
            tabIndex=tabIndex)

        self.SetClientSize(self.panel.GetBestSize())

        menuBar, self.menuItemIDs = _inspect.createInspectorMenus()
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_MENU, self.onMenu)

        if not focused:
            # This is the first window - center it
            self.Center()
        else:
            # Stagger the window
            while focused.GetParent():
                focused = focused.GetParent()
            self.MoveXY(*[p + 15 for p in focused.GetPositionTuple()])
        self.Show(True)

        self.Bind(wx.EVT_CLOSE, self.close)
示例#2
0
  def __init__(self, element, showRun=True, mode='mini', icon=None,
               networkInspectorName=None, tabIndex=None):
    """
    element -- A RuntimeElement.
    showRun -- Whether to show the RuntimeInspector in the dropdown.
    mode -- Initial mode for selecting inspectors, either 'mini' or 'grid'.
    networkInspectorName -- Stirng representation of a NetworkInspector
      subclass, used as the initial inspector.
    tabIndex -- Which tab to show initially (RegionInspectors only).
    """

    focused = wx.Window.FindFocus()

    wx.Frame.__init__(self, None,
      style=wx.DEFAULT_FRAME_STYLE - wx.MAXIMIZE_BOX - wx.RESIZE_BORDER)

    if icon:
      self.SetIcon(icon)

    self.panel = MultiInspectorPanel(element=element, parent=self,
                                     embed=False, showRun=showRun, mode=mode,
                                     networkInspectorName=networkInspectorName,
                                     tabIndex=tabIndex)

    self.SetClientSize(self.panel.GetBestSize())

    menuBar, self.menuItemIDs = _inspect.createInspectorMenus()
    self.SetMenuBar(menuBar)
    self.Bind(wx.EVT_MENU, self.onMenu)

    if not focused:
      # This is the first window - center it
      self.Center()
    else:
      # Stagger the window
      while focused.GetParent():
        focused = focused.GetParent()
      self.MoveXY(*[p + 15 for p in focused.GetPositionTuple()])
    self.Show(True)

    self.Bind(wx.EVT_CLOSE, self.close)
示例#3
0
文件: GUIs.py 项目: 0x0all/nupic
  def __init__(self, experiment, tierCount=0, addInspectorButton=True):
    """
    experiment -- the experiment to be run.
    tierCount -- Number of tiers in the network, for training, including the
      sensor but not including the effector. Set by TrainingGUI but left at 0
      by InferenceGUI.
    addInspectorButton -- Whether to put an inspector button (magnifying glass)
      in the top-right. Set to False by InferenceGUI because it adds another
      panel to the right and so it adds the inspector button itself.
    """
    assert isinstance(experiment, Experiment)

    wx.Frame.__init__(self, None,
      style=wx.DEFAULT_FRAME_STYLE - wx.MAXIMIZE_BOX - wx.RESIZE_BORDER)

    # Modify several Enthought (Traits) classes to fix bugs
    patchEnthoughtClasses()

    # Set up the font use for inspector titles
    self.titleFont = self.GetFont()
    self.titleFont.SetWeight(wx.FONTWEIGHT_BOLD)
    self.titleFont.SetPointSize(self.titleFont.GetPointSize() + 2)

    self.experiment = experiment
    net = self.network = experiment.network
    #if net is None:
    #  from dbgp.client import brk; brk(port=9011)
    assert net is not None
    self.tierCount = tierCount

    multipleDatasets = not tierCount

    # Catch when the window is closed in order to shut down the inspectors
    self.Bind(wx.EVT_CLOSE, self.close)

    # Create a single panel to hold all the inspectors
    self.panel = wx.Panel(self)
    # The inspectors will be laid out left-to-right in a horizontal sizer
    self.hSizer = wx.BoxSizer(wx.HORIZONTAL)
    self.hSizer.AddSpacer(2)

    # Create the inspector button, which will be added to a sizer later
    inspectorBitmap = wx.Bitmap(getNTAImage('magnifying_glass_24_24'))
    self.inspectorBitmap = wx.StaticBitmap(self.panel, bitmap=inspectorBitmap)
    wx.EVT_LEFT_DOWN(self.inspectorBitmap, self.launchInspector)

    # Add the RuntimeInspector and its title
    runtimeSizer = wx.BoxSizer(wx.VERTICAL)
    self.title = wx.StaticText(self.panel, label=" ")
    self.title.SetFont(self.titleFont)
    self.runtimeInspector = PredictionRuntimeInspector(parent=self.panel,
      experiment=experiment, tierCount=tierCount, showProgressBar=True,
      multipleDatasets=multipleDatasets, startImmediately=False)
    # Add to a vertical sizer
    runtimeSizer.Add(self.title, flag=wx.ALL, border=3)
    runtimeSizer.Add(
      self.runtimeInspector.edit_traits(parent=self.panel,
        view=self.runtimeInspector.traits_view, kind='panel').control)
    # Add the vertical sizer to the horizontal sizer
    self.hSizer.Add(runtimeSizer, flag=wx.ALL, border=3)

    # Add a vertical line in between the inspectors
    self.hSizer.Add(wx.StaticLine(self.panel, style=wx.LI_VERTICAL),
                    flag=wx.EXPAND|wx.LEFT|wx.RIGHT, border=2)

    # Add the MiniRecordSensor Inspector
    # This has now been generalized to handle other mini inspectors
    sensorSizer = wx.BoxSizer(wx.VERTICAL)
    sensorTitle = wx.StaticText(self.panel, label='Sensor output')
    sensorTitle.SetFont(self.titleFont)
    sensor = net.regions['sensor']
    inspectorClass = getInspectorClass(sensor, "Mini%sInspector")
    self.sensorInspector = inspectorClass(parent=self.panel, region=sensor)

    # Add to a vertical sizer
    if addInspectorButton:
      # Add the title and the inspector button in a horizontal sizer
      titleSizer = wx.BoxSizer(wx.HORIZONTAL)
      titleSizer.Add(sensorTitle, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=3)
      titleSizer.AddStretchSpacer()
      titleSizer.Add(self.inspectorBitmap)
      sensorSizer.Add(titleSizer, flag=wx.EXPAND|wx.RIGHT, border=2)
    else:
      # Add the title without the inspector button
      sensorSizer.Add(sensorTitle, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=3)
    sensorSizer.AddStretchSpacer()
    sensorSizer.Add(
      self.sensorInspector.edit_traits(parent=self.panel, kind='panel').control)
    sensorSizer.AddStretchSpacer()
    # Add the vertical sizer to the horizontal sizer
    self.hSizer.Add(sensorSizer, flag=wx.LEFT|wx.TOP|wx.RIGHT|wx.EXPAND,
                    border=3)

    # Assign the horizontal sizer as the sizer for the panel
    self.panel.SetSizer(self.hSizer)

    # This list is used to unregister the inspectors when the window is closed
    self.inspectors = [self.runtimeInspector, self.sensorInspector]

    menuBar, self.menuItemIDs = _inspect.createInspectorMenus()
    self.SetMenuBar(menuBar)
    self.Bind(wx.EVT_MENU, self.onMenu)

    self.tier = -1
    self.started = False
示例#4
0
  def __init__(self, experiment, tierCount=0, addInspectorButton=True):
    """
    experiment -- the experiment to be run.
    tierCount -- Number of tiers in the network, for training, including the
      sensor but not including the effector. Set by TrainingGUI but left at 0
      by InferenceGUI.
    addInspectorButton -- Whether to put an inspector button (magnifying glass)
      in the top-right. Set to False by InferenceGUI because it adds another
      panel to the right and so it adds the inspector button itself.
    """
    assert isinstance(experiment, Experiment)

    wx.Frame.__init__(self, None,
      style=wx.DEFAULT_FRAME_STYLE - wx.MAXIMIZE_BOX - wx.RESIZE_BORDER)

    # Modify several Enthought (Traits) classes to fix bugs
    patchEnthoughtClasses()

    # Set up the font use for inspector titles
    self.titleFont = self.GetFont()
    self.titleFont.SetWeight(wx.FONTWEIGHT_BOLD)
    self.titleFont.SetPointSize(self.titleFont.GetPointSize() + 2)

    self.experiment = experiment
    net = self.network = experiment.network
    #if net is None:
    #  from dbgp.client import brk; brk(port=9011)
    assert net is not None
    self.tierCount = tierCount

    multipleDatasets = not tierCount

    # Catch when the window is closed in order to shut down the inspectors
    self.Bind(wx.EVT_CLOSE, self.close)

    # Create a single panel to hold all the inspectors
    self.panel = wx.Panel(self)
    # The inspectors will be laid out left-to-right in a horizontal sizer
    self.hSizer = wx.BoxSizer(wx.HORIZONTAL)
    self.hSizer.AddSpacer(2)

    # Create the inspector button, which will be added to a sizer later
    inspectorBitmap = wx.Bitmap(getNTAImage('magnifying_glass_24_24'))
    self.inspectorBitmap = wx.StaticBitmap(self.panel, bitmap=inspectorBitmap)
    wx.EVT_LEFT_DOWN(self.inspectorBitmap, self.launchInspector)

    # Add the RuntimeInspector and its title
    runtimeSizer = wx.BoxSizer(wx.VERTICAL)
    self.title = wx.StaticText(self.panel, label=" ")
    self.title.SetFont(self.titleFont)
    self.runtimeInspector = PredictionRuntimeInspector(parent=self.panel,
      experiment=experiment, tierCount=tierCount, showProgressBar=True,
      multipleDatasets=multipleDatasets, startImmediately=False)
    # Add to a vertical sizer
    runtimeSizer.Add(self.title, flag=wx.ALL, border=3)
    runtimeSizer.Add(
      self.runtimeInspector.edit_traits(parent=self.panel,
        view=self.runtimeInspector.traits_view, kind='panel').control)
    # Add the vertical sizer to the horizontal sizer
    self.hSizer.Add(runtimeSizer, flag=wx.ALL, border=3)

    # Add a vertical line in between the inspectors
    self.hSizer.Add(wx.StaticLine(self.panel, style=wx.LI_VERTICAL),
                    flag=wx.EXPAND|wx.LEFT|wx.RIGHT, border=2)

    # Add the MiniRecordSensor Inspector
    # This has now been generalized to handle other mini inspectors
    sensorSizer = wx.BoxSizer(wx.VERTICAL)
    sensorTitle = wx.StaticText(self.panel, label='Sensor output')
    sensorTitle.SetFont(self.titleFont)
    sensor = net.regions['sensor']
    inspectorClass = getInspectorClass(sensor, "Mini%sInspector")
    self.sensorInspector = inspectorClass(parent=self.panel, region=sensor)

    # Add to a vertical sizer
    if addInspectorButton:
      # Add the title and the inspector button in a horizontal sizer
      titleSizer = wx.BoxSizer(wx.HORIZONTAL)
      titleSizer.Add(sensorTitle, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=3)
      titleSizer.AddStretchSpacer()
      titleSizer.Add(self.inspectorBitmap)
      sensorSizer.Add(titleSizer, flag=wx.EXPAND|wx.RIGHT, border=2)
    else:
      # Add the title without the inspector button
      sensorSizer.Add(sensorTitle, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=3)
    sensorSizer.AddStretchSpacer()
    sensorSizer.Add(
      self.sensorInspector.edit_traits(parent=self.panel, kind='panel').control)
    sensorSizer.AddStretchSpacer()
    # Add the vertical sizer to the horizontal sizer
    self.hSizer.Add(sensorSizer, flag=wx.LEFT|wx.TOP|wx.RIGHT|wx.EXPAND,
                    border=3)

    # Assign the horizontal sizer as the sizer for the panel
    self.panel.SetSizer(self.hSizer)

    # This list is used to unregister the inspectors when the window is closed
    self.inspectors = [self.runtimeInspector, self.sensorInspector]

    menuBar, self.menuItemIDs = _inspect.createInspectorMenus()
    self.SetMenuBar(menuBar)
    self.Bind(wx.EVT_MENU, self.onMenu)

    self.tier = -1
    self.started = False