From 01dea82e84ab5a50094ec16f6b2b75bcd26b0147 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 24 Dec 2014 10:54:24 +0000 Subject: [PATCH] Removed ActionPanel - all config panels are now going to be fsl.fslview.panel.ConfigPanel. Currently missing canvas propertis, just need to define layout --- fsl/fslview/actions/actionpanel.py | 66 ------------------------------ fsl/fslview/layouts.py | 24 +++++++++-- fsl/fslview/panel.py | 24 +++++++++++ fsl/fslview/views/canvaspanel.py | 28 ++++++------- 4 files changed, 59 insertions(+), 83 deletions(-) delete mode 100644 fsl/fslview/actions/actionpanel.py diff --git a/fsl/fslview/actions/actionpanel.py b/fsl/fslview/actions/actionpanel.py deleted file mode 100644 index e6e19e0cf..000000000 --- a/fsl/fslview/actions/actionpanel.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -# actionpanel.py - Build a GUI for an ActionProvider instance. -# -# Author: Paul McCarthy <pauldmccarthy@gmail.com> -# -"""This module provides the :class:`ActionPanel` class, a :class:`wx.Panel` -which contains buttons and widgets allowing the user to run the actions of, -and modify the properties of an :class:`~fsl.fslview.actions.ActionProvider` -instance. -""" - -import logging -log = logging.getLogger(__name__) - - -import wx - -import props - -import fsl.fslview.strings as strings - -class ActionPanel(wx.Panel): - """ - """ - - def __init__(self, parent, provider, propz=None, actionz=None): - - wx.Panel.__init__(self, parent) - - if propz is None: propz, _ = provider.getAllProperties() - if actionz is None: actionz = provider.getActions().keys() - - self._provider = provider - - self._propPanel = wx.Panel(self) - self._actionPanel = wx.Panel(self) - - self._propSizer = wx.GridSizer(len(propz), 2) - self._actionSizer = wx.BoxSizer(wx.HORIZONTAL) - self._mainSizer = wx.BoxSizer(wx.VERTICAL) - - self .SetSizer(self._mainSizer) - self._propPanel .SetSizer(self._propSizer) - self._actionPanel.SetSizer(self._actionSizer) - - for prop in propz: - - label = wx.StaticText(self._propPanel, - label=strings.labels[provider, prop]) - widget = props.makeWidget(self._propPanel, provider, prop) - - self._propSizer.Add(label, flag=wx.EXPAND) - self._propSizer.Add(widget, flag=wx.EXPAND) - - for action in actionz: - - button = wx.Button(self._actionPanel, - label=strings.labels[provider, action]) - self._actionSizer.Add(button, flag=wx.EXPAND) - - self._provider.getAction(action).bindToWidget( - button, wx.EVT_BUTTON, button) - - self._mainSizer.Add(self._propPanel, flag=wx.EXPAND) - self._mainSizer.Add(self._actionPanel, flag=wx.EXPAND) diff --git a/fsl/fslview/layouts.py b/fsl/fslview/layouts.py index e22990340..c6e55cc06 100644 --- a/fsl/fslview/layouts.py +++ b/fsl/fslview/layouts.py @@ -16,6 +16,7 @@ import fsl.fslview.strings as strings from fsl.fslview.profiles.orthoviewprofile import OrthoViewProfile from fsl.fslview.profiles.orthoeditprofile import OrthoEditProfile +from fsl.fslview.views.canvaspanel import CanvasPanel OrthoEditProfileLayout = props.HGroup( @@ -33,9 +34,26 @@ OrthoEditProfileLayout = props.HGroup( OrthoViewProfileLayout = props.HGroup(('mode', )) + + +CanvasPanelActionLayout = props.HGroup( + (props.Button('screenshot', text=strings.labels[CanvasPanel, 'screenshot'], callback=CanvasPanel.screenshot), + props.Button('toggleColourBar', text=strings.labels[CanvasPanel, 'toggleColourBar'], callback=CanvasPanel.toggleColourBar), + props.Button('toggleImageList', text=strings.labels[CanvasPanel, 'toggleImageList'], callback=CanvasPanel.toggleImageList), + props.Button('toggleDisplayProperties', text=strings.labels[CanvasPanel, 'toggleDisplayProperties'], callback=CanvasPanel.toggleDisplayProperties), + props.Button('toggleLocationPanel', text=strings.labels[CanvasPanel, 'toggleLocationPanel'], callback=CanvasPanel.toggleLocationPanel), + props.Button('toggleCanvasProperties', text=strings.labels[CanvasPanel, 'toggleCanvasProperties'], callback=CanvasPanel.toggleCanvasProperties)), + wrap=True, + showLabels=False) + + + + layouts = td.TypeDict({ - 'OrthoViewProfile' : OrthoViewProfileLayout, - 'OrthoEditProfile' : OrthoEditProfileLayout + 'OrthoViewProfile' : OrthoViewProfileLayout, + 'OrthoEditProfile' : OrthoEditProfileLayout, + + ('CanvasPanel', 'actions') : CanvasPanelActionLayout, +# ('CanvasPanel', 'props') : CanvasPanelTopLayout, }) - diff --git a/fsl/fslview/panel.py b/fsl/fslview/panel.py index 3a0b7d701..bd50aa39c 100644 --- a/fsl/fslview/panel.py +++ b/fsl/fslview/panel.py @@ -41,6 +41,8 @@ import fsl.fslview.actions as actions import displaycontext +import props + class FSLViewPanel(wx.Panel, actions.ActionProvider): """Superclass for FSLView view panels. @@ -94,3 +96,25 @@ class FSLViewPanel(wx.Panel, actions.ActionProvider): self._imageList = imageList self._displayCtx = displayCtx self._name = '{}_{}'.format(self.__class__.__name__, id(self)) + + +class ConfigPanel(wx.Panel): + + def __init__(self, parent, target, layout=None): + + import fsl.fslview.layouts as layouts + + wx.Panel.__init__(self, parent) + self._name = '{}_{}'.format(self.__class__.__name__, id(self)) + self._target = target + self._sizer = wx.BoxSizer(wx.HORIZONTAL) + + if layout is None: + layout = layouts.layouts[target] + + self._propPanel = props.buildGUI(self, target, view=layout) + + self._sizer.Add(self._propPanel, flag=wx.EXPAND, proportion=1) + + self.SetSizer(self._sizer) + self.Layout() diff --git a/fsl/fslview/views/canvaspanel.py b/fsl/fslview/views/canvaspanel.py index 7f319d744..3363c1e45 100644 --- a/fsl/fslview/views/canvaspanel.py +++ b/fsl/fslview/views/canvaspanel.py @@ -27,8 +27,6 @@ import props import fsl.fslview.panel as fslpanel import fsl.fslview.profiles as profiles -import fsl.fslview.actions.actionpanel as actionpanel -import fsl.fslview.profiles.profilepanel as profilepanel import fsl.fslview.displaycontext as displayctx import fsl.fslview.controls.imagelistpanel as imagelistpanel import fsl.fslview.controls.imagedisplaypanel as imagedisplaypanel @@ -201,10 +199,13 @@ class CanvasPanel(fslpanel.FSLViewPanel): displayCtx.getSyncPropertyName('imageOrder')) self.bindProps('syncVolume', displayCtx, - displayCtx.getSyncPropertyName('volume')) + displayCtx.getSyncPropertyName('volume')) + + import fsl.fslview.layouts as layouts + + self.__actionPanel = fslpanel.ConfigPanel( + self, self, layout=layouts.layouts[CanvasPanel, 'actions']) - self.__actionPanel = actionpanel.ActionPanel( - self, self, propz=[]) self.__profilePanel = wx.Panel(self) self.__canvasContainer = wx.Panel(self) self.__listLocContainer = wx.Panel(self) @@ -221,8 +222,7 @@ class CanvasPanel(fslpanel.FSLViewPanel): self.__displayPropsPanel = imagedisplaypanel.ImageDisplayPanel( self.__dispSetContainer, imageList, displayCtx) - self.__canvasPropsPanel = actionpanel.ActionPanel( - self.__dispSetContainer, self, actionz=[]) + self.__canvasPropsPanel = wx.Panel(self.__dispSetContainer) self.__listLocSizer = wx.BoxSizer(wx.HORIZONTAL) self.__listLocContainer.SetSizer(self.__listLocSizer) @@ -287,7 +287,7 @@ class CanvasPanel(fslpanel.FSLViewPanel): if self.__profilePanel is not None: self.__profilePanel.DestroyChildren() - realProfilePanel = profilepanel.ProfilePanel( + realProfilePanel = fslpanel.ConfigPanel( self.__profilePanel, self.getCurrentProfile()) sizer = wx.BoxSizer(wx.HORIZONTAL) @@ -298,27 +298,27 @@ class CanvasPanel(fslpanel.FSLViewPanel): self.__layout() - def toggleImageList(self): + def toggleImageList(self, *a): self.__imageListPanel.Show(not self.__imageListPanel.IsShown()) self.__layout() - def toggleLocationPanel(self): + def toggleLocationPanel(self, *a): self.__locationPanel.Show(not self.__locationPanel.IsShown()) self.__layout() - def toggleDisplayProperties(self): + def toggleDisplayProperties(self, *a): self.__displayPropsPanel.Show(not self.__displayPropsPanel.IsShown()) self.__layout() - def toggleCanvasProperties(self): + def toggleCanvasProperties(self, *a): self.__canvasPropsPanel .Show(not self.__canvasPropsPanel.IsShown()) self.__layout() - def toggleColourBar(self): + def toggleColourBar(self, *a): self.__showColourBar = not self.__showColourBar self.__layout() - def screenshot(self): + def screenshot(self, *a): _takeScreenShot(self._imageList, self._displayCtx, self) -- GitLab