Skip to content
Snippets Groups Projects
Commit 01dea82e authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Removed ActionPanel - all config panels are now

going to be fsl.fslview.panel.ConfigPanel. Currently missing canvas
propertis, just need to define layout
parent fec43363
No related branches found
No related tags found
No related merge requests found
#!/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)
......@@ -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,
})
......@@ -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()
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment