def CreateItem(self, parent):
        """Returns an IPythonShell Panel"""
        self._log = wx.GetApp().GetLog()
        self._log("[xPyShell][info] Creating IPythonShell instance for Shelf")
        #main_win = wx.GetApp().GetMainWindow()
        #parent.AddPage(self.history_panel,'IPythonHistory',False)

        splitter = wx.SplitterWindow(parent, -1, style=wx.SP_LIVE_UPDATE)

        self.history_panel = IPythonHistoryPanel(splitter)
        self.history_panel.setOptionTrackerHook(self.OptionSave)

        self.ipython_panel = IPShellWidget(splitter, background_color="BLACK")
        #user_ns=locals(),user_global_ns=globals(),)
        self.ipython_panel.setOptionTrackerHook(self.OptionSave)
        self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)

        options_ipython = self.ipython_panel.getOptions()
        for key in options_ipython.keys():
            saved_value = profiler.Profile_Get('IPython.' + key)
            if saved_value is not None:
                options_ipython[key]['value'] = saved_value

        options_history = self.history_panel.getOptions()
        for key in options_history.keys():
            saved_value = profiler.Profile_Get('IPython.' + key)
            if saved_value is not None:
                options_history[key]['value'] = saved_value

        self.ipython_panel.reloadOptions(options_ipython)
        self.history_panel.reloadOptions(options_history)

        splitter.SetMinimumPaneSize(20)
        splitter.SplitVertically(self.ipython_panel, self.history_panel, -100)
        #splitter.SplitVertically(frame, self.history_panel, -100)

        ### for better split window sizing behavior
        self._splitter = splitter
        shell_window = splitter.GetWindow1()
        shell_window.SetMinSize((500, 0))

        history_window = splitter.GetWindow2()
        history_window.SetMinSize((100, 0))

        splitter.SetSashGravity(0.7)

        return splitter
Exemplo n.º 2
0
    def CreateItem(self, parent):
                     
        
        """Returns an IPythonShell Panel"""
        self._log = wx.GetApp().GetLog()
        self._log("[xPyShell][info] Creating IPythonShell instance for Shelf")
        #main_win = wx.GetApp().GetMainWindow()
        #parent.AddPage(self.history_panel,'IPythonHistory',False)
        
        splitter = wx.SplitterWindow(parent, -1, style = wx.SP_LIVE_UPDATE)
        
        self.history_panel    = IPythonHistoryPanel(splitter)
        self.history_panel.setOptionTrackerHook(self.OptionSave)
        
        self.ipython_panel    = IPShellWidget(splitter, background_color="BLACK")
                                              #user_ns=locals(),user_global_ns=globals(),)
        self.ipython_panel.setOptionTrackerHook(self.OptionSave)
        self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
        
        options_ipython = self.ipython_panel.getOptions()
        for key in options_ipython.keys():
            saved_value = profiler.Profile_Get('IPython.'+key)
            if saved_value is not None:
                options_ipython[key]['value'] = saved_value

        options_history = self.history_panel.getOptions()
        for key in options_history.keys():
            saved_value = profiler.Profile_Get('IPython.'+key)
            if saved_value is not None:
                options_history[key]['value'] = saved_value
        
        self.ipython_panel.reloadOptions(options_ipython)
        self.history_panel.reloadOptions(options_history)


        splitter.SetMinimumPaneSize(20)
        splitter.SplitVertically(self.ipython_panel, self.history_panel, -100)
        #splitter.SplitVertically(frame, self.history_panel, -100)
        
        ### for better split window sizing behavior
        self._splitter = splitter
        shell_window = splitter.GetWindow1()
        shell_window.SetMinSize((500,0))
      
        history_window = splitter.GetWindow2()
        history_window.SetMinSize((100,0))
        
        splitter.SetSashGravity(0.7)
        
        return splitter
Exemplo n.º 3
0
class xPyShell(plugin.Plugin):
    
    """Adds menu items"""
    def PlugIt(self, parent):
        """Implements MainWindowI's PlugIt Method"""
        self._mw = parent
        
        # bindings for menu items
        binding_run = u"\t"+u"F5"
        binding_dbg = u"\t"+u"F4"
        EdMenuBar.keybinder.SetBinding(ID_RUN_IPYTHON,binding_run)
        EdMenuBar.keybinder.SetBinding(ID_DBG_IPYTHON,binding_dbg)
        
        # add menu items
        em = self._mw.GetMenuBar().GetMenuByName("tools")
       
        em.Insert(0,ID_DBG_IPYTHON, _("Debug in iPython")+\
                        EdMenuBar.keybinder.GetBinding(ID_DBG_IPYTHON),
                        _("Debug the current file in iPython"))
        em.Insert(0,ID_RUN_IPYTHON, _("Run in iPython")+\
                        EdMenuBar.keybinder.GetBinding(ID_RUN_IPYTHON),
                        _("Run the current file in iPython"))
        


        
    def GetMenuHandlers(self):
        """Returns the event handler for this plugins menu entry"""
        return [(ID_RUN_IPYTHON, self.OnRuniPython), (ID_DBG_IPYTHON, self.OnDebugiPython)]

    
    def OnDebugiPython(self, evt):
        """Handles the menu event generated by our new menu entry"""
        
        # save stc control for current and future external uses
        notebook = self._mw.GetNotebook()
        config.ed_stc = notebook.GetCurrentCtrl()
        
               
        # collect bookmarks
        bmlist = config.ed_stc.GetBookmarks()
        
        # for future breakpoints, make margin wider
        config.ed_stc.SetMarginWidth(0,20)
        
        # automated debugger input
        self.ipython_panel.IP.dbginput = []
        self.ipython_panel.IP.dbginput.append('s')
        if bmlist:
            for bkpoint in bmlist:
                self.ipython_panel.IP.dbginput.append('break '+str(bkpoint+1))
        
        
        # run the file in ipython
        filepath = config.ed_stc.GetFileName()
        
        self.ipython_panel.text_ctrl.write('%run -d '+filepath)
        self.ipython_panel.stateDoExecuteLine()
    
    def OnRuniPython(self, evt):
        """Handles the menu event generated by our new menu entry"""
        
        # save stc control for current and future external uses
        notebook = self._mw.GetNotebook()
        config.ed_stc = notebook.GetCurrentCtrl()
        
        # run the file in ipython
        filepath = config.ed_stc.GetFileName()
        self.ipython_panel.text_ctrl.write('%run '+filepath)
        self.ipython_panel.stateDoExecuteLine()
        
    
    
    
    
    
    """Adds a PyShell to the Shelf"""
    plugin.Implements(iface.ShelfI, iface.MainWindowI)
    #plugin.Implements(iface.ShelfI)
    ID_IPYSHELL = wx.NewId()

    __name__ = u'xPyShell'

    def AllowMultiple(self):
        """IPythonShell allows multiple instances"""
        return True

    def OptionSave(self,key,value):
        profiler.Profile_Set('IPython.'+key, value)
        
    def CreateItem(self, parent):
                     
        
        """Returns an IPythonShell Panel"""
        self._log = wx.GetApp().GetLog()
        self._log("[xPyShell][info] Creating IPythonShell instance for Shelf")
        #main_win = wx.GetApp().GetMainWindow()
        #parent.AddPage(self.history_panel,'IPythonHistory',False)
        
        splitter = wx.SplitterWindow(parent, -1, style = wx.SP_LIVE_UPDATE)
        
        self.history_panel    = IPythonHistoryPanel(splitter)
        self.history_panel.setOptionTrackerHook(self.OptionSave)
        
        self.ipython_panel    = IPShellWidget(splitter, background_color="BLACK")
                                              #user_ns=locals(),user_global_ns=globals(),)
        self.ipython_panel.setOptionTrackerHook(self.OptionSave)
        self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
        
        options_ipython = self.ipython_panel.getOptions()
        for key in options_ipython.keys():
            saved_value = profiler.Profile_Get('IPython.'+key)
            if saved_value is not None:
                options_ipython[key]['value'] = saved_value

        options_history = self.history_panel.getOptions()
        for key in options_history.keys():
            saved_value = profiler.Profile_Get('IPython.'+key)
            if saved_value is not None:
                options_history[key]['value'] = saved_value
        
        self.ipython_panel.reloadOptions(options_ipython)
        self.history_panel.reloadOptions(options_history)


        splitter.SetMinimumPaneSize(20)
        splitter.SplitVertically(self.ipython_panel, self.history_panel, -100)
        #splitter.SplitVertically(frame, self.history_panel, -100)
        
        ### for better split window sizing behavior
        self._splitter = splitter
        shell_window = splitter.GetWindow1()
        shell_window.SetMinSize((500,0))
      
        history_window = splitter.GetWindow2()
        history_window.SetMinSize((100,0))
        
        splitter.SetSashGravity(0.7)
        
        return splitter

        #self._log("[xPyShell][info] IPythonShell succesfully created")
        #return self.ipython_panel

    def GetId(self):
        return xPyShell.ID_IPYSHELL

    def GetMenuEntry(self, menu):
        return wx.MenuItem(menu, xPyShell.ID_IPYSHELL,
                           xPyShell.__name__, 
                           _("Open an IPython Shell"))

    def GetName(self):
        return xPyShell.__name__

    def IsStockable(self):
        return True
class xPyShell(plugin.Plugin):
    """Adds menu items"""
    def PlugIt(self, parent):
        """Implements MainWindowI's PlugIt Method"""
        self._mw = parent

        # bindings for menu items
        binding_run = u"\t" + u"F5"
        binding_dbg = u"\t" + u"F4"
        EdMenuBar.keybinder.SetBinding(ID_RUN_IPYTHON, binding_run)
        EdMenuBar.keybinder.SetBinding(ID_DBG_IPYTHON, binding_dbg)

        # add menu items
        em = self._mw.GetMenuBar().GetMenuByName("tools")

        em.Insert(0,ID_DBG_IPYTHON, _("Debug in iPython")+\
                        EdMenuBar.keybinder.GetBinding(ID_DBG_IPYTHON),
                        _("Debug the current file in iPython"))
        em.Insert(0,ID_RUN_IPYTHON, _("Run in iPython")+\
                        EdMenuBar.keybinder.GetBinding(ID_RUN_IPYTHON),
                        _("Run the current file in iPython"))

    def GetMenuHandlers(self):
        """Returns the event handler for this plugins menu entry"""
        return [(ID_RUN_IPYTHON, self.OnRuniPython),
                (ID_DBG_IPYTHON, self.OnDebugiPython)]

    def OnDebugiPython(self, evt):
        """Handles the menu event generated by our new menu entry"""

        # save stc control for current and future external uses
        notebook = self._mw.GetNotebook()
        config.ed_stc = notebook.GetCurrentCtrl()

        # collect bookmarks
        bmlist = config.ed_stc.GetBookmarks()

        # for future breakpoints, make margin wider
        config.ed_stc.SetMarginWidth(0, 20)

        # automated debugger input
        self.ipython_panel.IP.dbginput = []
        self.ipython_panel.IP.dbginput.append('s')
        if bmlist:
            for bkpoint in bmlist:
                self.ipython_panel.IP.dbginput.append('break ' +
                                                      str(bkpoint + 1))

        # run the file in ipython
        filepath = config.ed_stc.GetFileName()

        self.ipython_panel.text_ctrl.write('%run -d ' + filepath)
        self.ipython_panel.stateDoExecuteLine()

    def OnRuniPython(self, evt):
        """Handles the menu event generated by our new menu entry"""

        # save stc control for current and future external uses
        notebook = self._mw.GetNotebook()
        config.ed_stc = notebook.GetCurrentCtrl()

        # run the file in ipython
        filepath = config.ed_stc.GetFileName()
        self.ipython_panel.text_ctrl.write('%run ' + filepath)
        self.ipython_panel.stateDoExecuteLine()

    """Adds a PyShell to the Shelf"""
    plugin.Implements(iface.ShelfI, iface.MainWindowI)
    #plugin.Implements(iface.ShelfI)
    ID_IPYSHELL = wx.NewId()

    __name__ = u'xPyShell'

    def AllowMultiple(self):
        """IPythonShell allows multiple instances"""
        return True

    def OptionSave(self, key, value):
        profiler.Profile_Set('IPython.' + key, value)

    def CreateItem(self, parent):
        """Returns an IPythonShell Panel"""
        self._log = wx.GetApp().GetLog()
        self._log("[xPyShell][info] Creating IPythonShell instance for Shelf")
        #main_win = wx.GetApp().GetMainWindow()
        #parent.AddPage(self.history_panel,'IPythonHistory',False)

        splitter = wx.SplitterWindow(parent, -1, style=wx.SP_LIVE_UPDATE)

        self.history_panel = IPythonHistoryPanel(splitter)
        self.history_panel.setOptionTrackerHook(self.OptionSave)

        self.ipython_panel = IPShellWidget(splitter, background_color="BLACK")
        #user_ns=locals(),user_global_ns=globals(),)
        self.ipython_panel.setOptionTrackerHook(self.OptionSave)
        self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)

        options_ipython = self.ipython_panel.getOptions()
        for key in options_ipython.keys():
            saved_value = profiler.Profile_Get('IPython.' + key)
            if saved_value is not None:
                options_ipython[key]['value'] = saved_value

        options_history = self.history_panel.getOptions()
        for key in options_history.keys():
            saved_value = profiler.Profile_Get('IPython.' + key)
            if saved_value is not None:
                options_history[key]['value'] = saved_value

        self.ipython_panel.reloadOptions(options_ipython)
        self.history_panel.reloadOptions(options_history)

        splitter.SetMinimumPaneSize(20)
        splitter.SplitVertically(self.ipython_panel, self.history_panel, -100)
        #splitter.SplitVertically(frame, self.history_panel, -100)

        ### for better split window sizing behavior
        self._splitter = splitter
        shell_window = splitter.GetWindow1()
        shell_window.SetMinSize((500, 0))

        history_window = splitter.GetWindow2()
        history_window.SetMinSize((100, 0))

        splitter.SetSashGravity(0.7)

        return splitter

        #self._log("[xPyShell][info] IPythonShell succesfully created")
        #return self.ipython_panel

    def GetId(self):
        return xPyShell.ID_IPYSHELL

    def GetMenuEntry(self, menu):
        return wx.MenuItem(menu, xPyShell.ID_IPYSHELL, xPyShell.__name__,
                           _("Open an IPython Shell"))

    def GetName(self):
        return xPyShell.__name__

    def IsStockable(self):
        return True