コード例 #1
0
ファイル: visualization.py プロジェクト: jspobst/spikepy
    def _handle_unmet_requirements(self, parent_panel, unmet_requirements):
        '''
            Print onto the figure the list of unmet requirements.
        '''
        if parent_panel is not None:
            figure = parent_panel.plot_panel.figure
            figure.set_facecolor('white')
            figure.set_edgecolor('black')
            figure.clear()
        else:
            figsize = config.get_size('figure')
            figure = self.pylab.figure(figsize=figsize)
            figure.set_facecolor('white')
            figure.set_edgecolor('black')
            figure.canvas.set_window_title(self.name)

        msg = pt.CANNOT_CREATE_VISUALIZATION % \
                '\n'.join(unmet_requirements)
        figure.text(0.5, 0.5, msg, verticalalignment='center',
                horizontalalignment='center')
            
        if parent_panel is not None:
            figure.canvas.draw()
        else:
            self.pylab.show()
コード例 #2
0
ファイル: visualization.py プロジェクト: jspobst/spikepy
    def _handle_no_trial_passed(self, parent_panel):
        '''
            Print onto the figure a message stating that the visualization
        couldn't be completed because no trial was passed in.
        '''
        if parent_panel is not None:
            figure = parent_panel.plot_panel.figure
            figure.set_facecolor('white')
            figure.set_edgecolor('black')
            figure.clear()
        else:
            figsize = config.get_size('figure')
            figure = self.pylab.figure(figsize=figsize)
            figure.set_facecolor('white')
            figure.set_edgecolor('black')
            figure.canvas.set_window_title(self.name)

        msg = pt.NO_TRIAL_SELECTED 
        figure.text(0.5, 0.5, msg, verticalalignment='center',
                horizontalalignment='center')
            
        if parent_panel is not None:
            figure.canvas.draw()
        else:
            self.pylab.show()
コード例 #3
0
    def layout_ui(self):
        active_checkbox = wx.CheckBox(self, label=self.plugin.name)
        self.Bind(wx.EVT_CHECKBOX, self._activate, active_checkbox)
        f = active_checkbox.GetFont()
        f.SetWeight(wx.BOLD)
        active_checkbox.SetFont(f)

        show_hide_button = wx.Button(self, label='+', size=(26, 26))
        self.Bind(wx.EVT_BUTTON, self._show_hide, show_hide_button)
        show_hide_button.SetToolTip(wx.ToolTip(pt.SHOW_HIDE_OPTIONS))

        top_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        top_sizer.Add(active_checkbox, flag=wx.ALIGN_CENTER_VERTICAL)
        top_sizer.Add(show_hide_button, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 
                border=5)

        main_sizer = wx.BoxSizer(orient=wx.VERTICAL)
        main_sizer.Add(top_sizer, flag=wx.ALIGN_LEFT)

        control_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)

        col_sizers = []
        hidden_items = []
        for i in range(self.num_columns):
            col_sizers.append(wx.BoxSizer(orient=wx.VERTICAL))
            for ctrl_name in sorted(self.ctrls.keys())[i::self.num_columns]:
                hidden_items.append(self.ctrls[ctrl_name])
                col_sizers[-1].Add(self.ctrls[ctrl_name], 
                        flag=wx.EXPAND|wx.ALIGN_RIGHT)
                self.ctrls[ctrl_name].register_valid_entry_callback(
                        self._something_changed)
            control_sizer.Add(col_sizers[-1], proportion=1)
            if i != self.num_columns-1:
                static_line = wx.StaticText(self, style=wx.LI_VERTICAL)
                hidden_items.append(static_line)
                control_sizer.Add(static_line,
                        flag=wx.EXPAND|wx.ALL, border=3)

        main_sizer.Add(control_sizer, flag=wx.EXPAND)

        border_panel = wx.Panel(self, style=wx.BORDER_SUNKEN)
        plot_panel = PlotPanel(border_panel, figsize=config.get_size('figure'))
        bps = wx.BoxSizer(orient=wx.VERTICAL)
        bps.Add(plot_panel, proportion=1, flag=wx.EXPAND)
        border_panel.SetSizer(bps)
        main_sizer.Add(border_panel, flag=wx.EXPAND|wx.ALL, border=5) 
        self.SetSizer(main_sizer)

        self.active_checkbox = active_checkbox
        self.plot_panel = plot_panel
        self.hidden_items = hidden_items
        self.show_hide_button = show_hide_button
        self._hidden = True
        self.active = False
コード例 #4
0
ファイル: view.py プロジェクト: jspobst/spikepy
    def __init__(self, parent, session, id=wx.ID_ANY, 
                 title=pt.MAIN_FRAME_TITLE,
                 size=None,
                 style=wx.DEFAULT_FRAME_STYLE):
        plugin_manager = session.plugin_manager
        strategy_manager = session.strategy_manager
        # MAIN_FRAME_SIZE needs the wx.App() instance so can't be put 
        #   in declaration
        if size is None: 
            size = config.get_size('main_frame')
        wx.Frame.__init__(self, parent, title=title, size=size, style=style)

        # --- STRATEGY PANE ---
        vsplit = wx.SplitterWindow(self, style=wx.SP_3D)
        hsplit = wx.SplitterWindow(vsplit, style=wx.SP_3D)

        strategy_holder = BorderPanel(hsplit, style=wx.BORDER_SUNKEN)
        self.strategy_pane = StrategyPane(strategy_holder, 
                plugin_manager=plugin_manager, 
                strategy_manager=strategy_manager)
        strategy_holder.add_content(self.strategy_pane, 0)

        trial_list_holder = BorderPanel(hsplit, style=wx.BORDER_SUNKEN)
        self.trial_list = TrialGridCtrl(trial_list_holder)
        trial_list_holder.add_content(self.trial_list, 0)

        self.results_notebook = results_notebook = ResultsNotebook(
                                                    vsplit, session)
        pyshell.locals_dict['results_notebook'] = self.results_notebook

        vsplit.SplitVertically(hsplit, self.results_notebook, 400)
        hsplit.SplitHorizontally(trial_list_holder, strategy_holder, 200)

        hsplit.SetMinimumPaneSize(config['gui']['strategy_pane']['min_height'])
        vsplit.SetMinimumPaneSize(config['gui']['strategy_pane']['min_width'])
        hsplit.SetSashPosition(config['gui']['strategy_pane']['min_height'])
        vsplit.SetSashPosition(config['gui']['strategy_pane']['min_width'])

        self.Bind(wx.EVT_CLOSE, self._close_application)

        # create status bar (I'm not sure if we'll use this or not)
        self.CreateStatusBar()
        self.SetStatusText(pt.STATUS_IDLE)

        # create menu bar
        self.menubar = SpikepyMenuBar(self)
        self.SetMenuBar(self.menubar)

        pub.subscribe(self._update_status_bar, 
                      topic='UPDATE_STATUS')
コード例 #5
0
ファイル: menu_bar.py プロジェクト: jspobst/spikepy
 def _python_shell(self, event=None):
     event.Skip()
     dlg = PyShellDialog(self, size=config.get_size('pyshell'))
     dlg.Show()
コード例 #6
0
    def __init__(self, parent, message_queue, **kwargs):
        if 'style' not in kwargs.keys():
            kwargs['style'] = wx.STAY_ON_TOP

        width, height = config.get_size('main_frame')*0.75
        kwargs['style'] |= wx.RESIZE_BORDER
        kwargs['style'] |= wx.CAPTION
        kwargs['style'] |= wx.SYSTEM_MENU

        kwargs['title'] = pt.PROCESS_PROGRESS

        wx.Dialog.__init__(self, parent, **kwargs)

        self.message_queue = message_queue
        self.update_period = 200 # in ms

        info_text = wx.StaticText(self, label=pt.COMPLETION_PROGRESS % '|')
        f = info_text.GetFont()
        f.SetPointSize(10)
        f.SetFaceName('Courier 10 Pitch')
        info_text.SetFont(f)
        gauge = wx.Gauge(self, wx.ID_ANY, 100, 
                              size=(int(width*0.8),20), style=wx.GA_HORIZONTAL)
        close_button = wx.Button(self, wx.ID_CLOSE)
        close_button.Enable(False)
        self.Bind(wx.EVT_BUTTON, self.close, close_button)

        notebook = wx.Notebook(self)

        # graph panel
        graph_area = GraphArea(notebook)
        graph_area.SetMinSize((550, 280))

        # details text.
        message_text = wx.TextCtrl(notebook, style=wx.TE_MULTILINE, 
                size=(int(width*0.8), int(height*0.6)))
        f = message_text.GetFont()
        f.SetPointSize(10)
        f.SetFaceName('Courier 10 Pitch')
        message_text.SetFont(f)
        message_text.SetBackgroundColour(wx.BLACK)
        message_text.SetForegroundColour(wx.WHITE)
        message_text.Enable(False)

        notebook.AddPage(message_text, 'Log')
        notebook.AddPage(graph_area, 'Graph')
        
        # layout
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        sizer.Add(info_text, proportion=0, 
                  flag=wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, border=10)
        sizer.Add(gauge, proportion=0, 
                flag=wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.TOP|
                        wx.LEFT|wx.RIGHT, 
                border=8)
        sizer.Add(close_button, proportion=0, flag=wx.ALIGN_RIGHT|wx.ALL,
                border=8)
        sizer.Add(notebook, proportion=1, 
                  flag=wx.EXPAND|wx.ALL|wx.ALIGN_LEFT, border=10)

        self.SetSizerAndFit(sizer)

        self.message_text = message_text 
        self._num_tasks = 1
        self._num_tasks_competed = 0
        self._display_messages = []
        self._should_update = True
        self.graph_area = graph_area
        self.gauge = gauge
        self.close_button = close_button 
        self.info_text = info_text
        self._start_time = time.time()
        self._plugin_runtime = 0.0
        self._just_once = True
        self._step = 0
        self._last_len = -1

        self.Bind(wx.EVT_TIMER, self._update_processing)
        self.timer = wx.Timer(self)
        self.timer.Start(self.update_period)