Exemple #1
0
    def __init__(self,
                 parent,
                 region,
                 tabChangeCallback=None,
                 tabs=defaultTabs):

        RuntimeListener.__init__(self)

        self.parent = parent
        self.region = region
        self.tabChangeCallback = tabChangeCallback

        patchEnthoughtClasses()

        # Remove incompatible tabs
        self.tabs = [tab for tab in tabs if tab.isRegionSupported(region)]

        # Create tab instances
        self.tabs = [tab(region) for tab in self.tabs]

        # Strip titles from tab views, but save them for use as tab labels
        self.titles = []
        for tab in self.tabs:
            self.titles.append(tab.traits_view.title)
            tab.traits_view.title = ""

        # Add a trait for each tab
        for i, tab in enumerate(self.tabs):
            self.add_trait('tab%d' % i, tab)

        # Set the handler for each tab if it is not specified
        for tab in self.tabs:
            if not tab.traits_view.handler:
                tab.traits_view.handler = RegionInspectorTabHandler

        # Create the view
        items = [
            Item('tab%d' % i,
                 editor=InstanceEditor(view=tab.traits_view),
                 style='custom',
                 show_label=False,
                 springy=True) for i, tab in enumerate(self.tabs)
        ]
        if len(self.tabs) == 1:
            args = [items[0]]
        else:
            args = [
                Group(item, label=self.titles[i])
                for i, item in enumerate(items)
            ]
        self.handler = RegionInspectorHandler()
        kwargs = dict(handler=self.handler,
                      buttons=NoButtons,
                      title=self.region.getName())
        self.traits_view = View(*args, **kwargs)

        self.activeTabIndex = 0
        self.tabNeedsUpdate = [True] * len(self.tabs)
        self.tabNeedsSwitch = [False] * len(self.tabs)
        self.initCompleted = True
Exemple #2
0
    def __init__(self, parent, network):

        RuntimeListener.__init__(self)

        self.parent = parent
        self.network = network

        patchEnthoughtClasses()
  def __init__(self, parent, network):

    RuntimeListener.__init__(self)

    self.parent = parent
    self.network = network

    patchEnthoughtClasses()
  def __init__(self, parent, region, tabChangeCallback=None, tabs=defaultTabs):

    RuntimeListener.__init__(self)

    self.parent = parent
    self.region = region
    self.tabChangeCallback = tabChangeCallback

    patchEnthoughtClasses()

    # Remove incompatible tabs
    self.tabs = [tab for tab in tabs if tab.isRegionSupported(region)]

    # Create tab instances
    self.tabs = [tab(region) for tab in self.tabs]

    # Strip titles from tab views, but save them for use as tab labels
    self.titles = []
    for tab in self.tabs:
      self.titles.append(tab.traits_view.title)
      tab.traits_view.title = ""

    # Add a trait for each tab
    for i, tab in enumerate(self.tabs):
      self.add_trait('tab%d' % i, tab)

    # Set the handler for each tab if it is not specified
    for tab in self.tabs:
      if not tab.traits_view.handler:
        tab.traits_view.handler = RegionInspectorTabHandler

    # Create the view
    items = [Item('tab%d' % i,
                  editor=InstanceEditor(view=tab.traits_view),
                  style='custom',
                  show_label=False,
                  springy=True)
             for i, tab in enumerate(self.tabs)]
    if len(self.tabs) == 1:
      args = [items[0]]
    else:
      args = [Group(item, label=self.titles[i]) for i, item in enumerate(items)]
    self.handler = RegionInspectorHandler()
    kwargs = dict(handler=self.handler,
                  buttons=NoButtons,
                  title=self.region.getName())
    self.traits_view = View(*args, **kwargs)

    self.activeTabIndex = 0
    self.tabNeedsUpdate = [True] * len(self.tabs)
    self.tabNeedsSwitch = [False] * len(self.tabs)
    self.initCompleted = True
Exemple #5
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
Exemple #6
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