Example #1
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: wxRTFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        # Menu Bar
        self.rtframe_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.NewId(), "Ejecutar", "", wx.ITEM_NORMAL)
        self.rtframe_menubar.Append(wxglade_tmp_menu, "Archivo")
        self.SetMenuBar(self.rtframe_menubar)

        # Menu Bar end
        self.rtframe_statusbar = self.CreateStatusBar(1, 0)
        self.rtshell = IPShellWidget(self)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.evt_run_file, id=-1)
    def CreateItem(self, parent):
        """Returns an IPythonShell Panel"""
        self._log = wx.GetApp().GetLog()
        self._log("[IPyShell][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)

        return splitter

        self._log("[IPyShell][info] IPythonShell succesfully created")
        return self.ipython_panel
Example #3
0
 def __init__(self, parent, id, title):
     wx.Window.__init__(self, parent, id, style=wx.NO_BORDER, name=title)
     self._sizer = wx.BoxSizer(wx.VERTICAL)
     self.shell = IPShellWidget(
         self, intro='Welcome to the FaceFX IPython Shell.\n\n')
     # Turn on STC completion and turn off threading.
     self.shell.options['completion']['value'] = 'STC'
     self.shell.options['threading']['value'] = 'False'
     self.shell.reloadOptions(self.shell.options)
     # Turn off the annoying 80 column vertical line.
     self.shell.text_ctrl.SetEdgeMode(wx.stc.STC_EDGE_NONE)
     self.color_palette = FxStudio.getColorPalette()
     self.shell.text_ctrl.StyleSetBackground(
         wx.stc.STC_STYLE_DEFAULT, self.color_palette['BaseColour1'])
     for style in self.shell.text_ctrl.ANSI_STYLES.values():
         self.shell.text_ctrl.StyleSetBackground(
             style[0], self.color_palette['BaseColour1'])
     self.shell.text_ctrl.SetCaretForeground('WHITE')
     self.shell.text_ctrl.SetWindowStyle(
         self.shell.text_ctrl.GetWindowStyle() | wx.NO_BORDER)
     self.shell.text_ctrl.Refresh()
     ip = IPython.ipapi.get()
     ip.ex('from FxStudio import *')
     self._sizer.Add(self.shell, 1, wx.EXPAND)
     self.SetSizer(self._sizer)
     self.Bind(wx.EVT_SIZE, self.onSize)
     # Hook into the underlying STC and add in the missing mouse capture lost event handler
     # to prevent C++ wxWidgets code from asserting. Note that there's not much we can
     # do about the selection weirdness that happens if this state is triggered.
     self.shell.text_ctrl.Bind(wx.EVT_MOUSE_CAPTURE_LOST,
                               self.onMouseCaptureLost)
     self.SetAutoLayout(1)
     self.output = FaceFXOnDemandOutputWindow(title="output")
     sys.stdout = self.output
     sys.stderr = self.output
     FxStudio.dockInMainWindowNotebook(self, "Python")
Example #4
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 title="WxIPython",
                 pos=wx.DefaultPosition,
                 size=(800, 600),
                 style=wx.DEFAULT_FRAME_STYLE,
                 sync_ok=False):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        self._mgr = wx.aui.AuiManager()

        # notify PyAUI which frame to use
        self._mgr.SetManagedWindow(self)

        #create differents panels and make them persistant
        self.history_panel = IPythonHistoryPanel(self)

        self.history_panel.setOptionTrackerHook(self.optionSave)

        self.ipython_panel = IPShellWidget(self, background_color="BLACK")
        #self.ipython_panel    = IPShellWidget(self,background_color = "WHITE")
        if (sync_ok):
            self.ipython_panel2 = IPythonXController(self)
        else:
            self.ipython_panel2 = None
        self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
        self.ipython_panel.setStatusTrackerHook(self.updateStatus)
        self.ipython_panel.setAskExitHandler(self.OnExitDlg)
        self.ipython_panel.setOptionTrackerHook(self.optionSave)

        #Create a notebook to display different IPython shell implementations
        self.nb = wx.aui.AuiNotebook(self)

        self.optionLoad()

        self.statusbar = self.createStatus()
        self.createMenu()

        ########################################################################
        ### add the panes to the manager
        # main panels
        self._mgr.AddPane(self.nb, wx.CENTER, "IPython Shells")
        self.nb.AddPage(self.ipython_panel, "IPython0 Shell")
        if (sync_ok):
            self.nb.AddPage(self.ipython_panel2, "IPython1 Synchroneous Shell")

        self._mgr.AddPane(self.history_panel, wx.RIGHT, "IPython history")

        # now we specify some panel characteristics
        self._mgr.GetPane(self.ipython_panel).CaptionVisible(True)
        self._mgr.GetPane(self.history_panel).CaptionVisible(True)
        self._mgr.GetPane(self.history_panel).MinSize((200, 400))

        # tell the manager to "commit" all the changes just made
        self._mgr.Update()

        #global event handling
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, self.OnShowIPythonPanel, id=wx.ID_HIGHEST + 1)
        self.Bind(wx.EVT_MENU, self.OnShowHistoryPanel, id=wx.ID_HIGHEST + 2)
        self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_HIGHEST + 3)
        self.Bind(wx.EVT_MENU, self.OnShowAllPanel, id=wx.ID_HIGHEST + 6)

        warn_text = 'Hello from IPython and wxPython.\n'
        warn_text += 'Please Note that this work is still EXPERIMENTAL\n'
        warn_text += 'It does NOT emulate currently all the IPython functions.\n'
        warn_text += "\nIf you use MATPLOTLIB with show() you'll need to deactivate the THREADING option.\n"
        if (not sync_ok):
            warn_text += "\n->No twisted package detected, IPython1 example deactivated."

        dlg = wx.MessageDialog(self, warn_text, 'Warning Box',
                               wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()