From ebc6dc2f995d074a41d7309888e2a105e3deb636 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 12 Aug 2015 17:52:28 +0100 Subject: [PATCH] Python shell panel. Added for debugging, but super cool! --- fsl/data/strings.py | 2 ++ fsl/fslview/controls/__init__.py | 1 + fsl/fslview/controls/shellpanel.py | 46 ++++++++++++++++++++++++++++++ fsl/fslview/views/canvaspanel.py | 6 +++- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 fsl/fslview/controls/shellpanel.py diff --git a/fsl/data/strings.py b/fsl/data/strings.py index 9db04c5ec..764631925 100644 --- a/fsl/data/strings.py +++ b/fsl/data/strings.py @@ -146,6 +146,7 @@ titles = TypeDict({ 'HistogramControlPanel' : 'Histogram control', 'ClusterPanel' : 'Cluster browser', 'OverlayInfoPanel' : 'Overlay information', + 'ShellPanel' : 'Python shell', 'LookupTablePanel.loadLut' : 'Select a lookup table file', 'LookupTablePanel.labelExists' : 'Label already exists', @@ -172,6 +173,7 @@ actions = TypeDict({ 'CanvasPanel.toggleLookupTablePanel' : 'Lookup tables', 'CanvasPanel.toggleClusterPanel' : 'Cluster browser', 'CanvasPanel.toggleOverlayInfo' : 'Overlay information', + 'CanvasPanel.toggleShell' : 'Python shell', 'OrthoPanel.toggleOrthoToolBar' : 'View properties', 'OrthoPanel.toggleProfileToolBar' : 'Edit toolbar', diff --git a/fsl/fslview/controls/__init__.py b/fsl/fslview/controls/__init__.py index 39ad296b6..e2f22af9f 100644 --- a/fsl/fslview/controls/__init__.py +++ b/fsl/fslview/controls/__init__.py @@ -17,6 +17,7 @@ from histogramcontrolpanel import HistogramControlPanel from clusterpanel import ClusterPanel from canvassettingspanel import CanvasSettingsPanel from overlayinfopanel import OverlayInfoPanel +from shellpanel import ShellPanel from orthotoolbar import OrthoToolBar from orthoprofiletoolbar import OrthoProfileToolBar diff --git a/fsl/fslview/controls/shellpanel.py b/fsl/fslview/controls/shellpanel.py new file mode 100644 index 000000000..acee82431 --- /dev/null +++ b/fsl/fslview/controls/shellpanel.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# shellpanel.py - +# +# Author: Paul McCarthy <pauldmccarthy@gmail.com> +# + +import wx + +import wx.py.shell as wxshell + +import fsl.fslview.panel as fslpanel + + +class ShellPanel(fslpanel.FSLViewPanel): + + def __init__(self, parent, overlayList, displayCtx, sceneOpts): + fslpanel.FSLViewPanel.__init__(self, parent, overlayList, displayCtx) + + lcls = { + 'displayCtx' : displayCtx, + 'overlayList' : overlayList, + 'sceneOpts' : sceneOpts, + } + + shell = wxshell.Shell( + self, + introText='\nFSLEyes python shell\n' + 'Available variables are:\n' + ' - overlayList\n' + ' - displayCtx\n' + ' - sceneOpts\n\n', + locals=lcls) + + font = shell.GetFont() + + shell.SetFont(font.Larger()) + + sizer = wx.BoxSizer(wx.HORIZONTAL) + self.SetSizer(sizer) + + sizer.Add(shell, flag=wx.EXPAND, proportion=1) + + + def destroy(self): + fslpanel.FSLViewPanel.destroy(self) diff --git a/fsl/fslview/views/canvaspanel.py b/fsl/fslview/views/canvaspanel.py index 7a1903fd0..4a7284676 100644 --- a/fsl/fslview/views/canvaspanel.py +++ b/fsl/fslview/views/canvaspanel.py @@ -85,7 +85,11 @@ class CanvasPanel(viewpanel.ViewPanel): location=wx.TOP)), ('toggleLookupTablePanel', lambda *a: self.togglePanel( fslcontrols.LookupTablePanel, - location=wx.TOP))] + location=wx.TOP)), + ('toggleShell', lambda *a: self.togglePanel( + fslcontrols.ShellPanel, + self.getSceneOptions(), + location=wx.BOTTOM))] actionz = collections.OrderedDict(actionz + extraActions.items()) viewpanel.ViewPanel.__init__( -- GitLab