Commit 7b12be21 authored by eric pellegrini's avatar eric pellegrini
Browse files

Fix some import bug related to old architecture

parent 10c38dc7
def has_parent(window, target):
if window == target:
return True
if window.TopLevelParent == window:
return False
return has_parent(window.Parent, target)
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: pellegrini
'''
import wx
import wx.aui as wxaui
from MDANSE import REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.Plugins.IPlugin import IPlugin, plugin_parent
class DataPlugin(IPlugin):
type = 'data'
ancestor = None
def __init__(self, parent, datakey):
IPlugin.__init__(self, parent, wx.ID_ANY)
self._datakey = datakey
self._dataProxy = DATA_CONTROLLER[self._datakey]
self._mgr.Bind(wx.EVT_CHILD_FOCUS, self.on_changing_pane)
self._currentWindow = self
def build_panel(self):
pass
def plug(self, standalone=False):
pass
@property
def currentWindow(self):
return self._currentWindow
@property
def datakey(self):
return self._datakey
@datakey.setter
def datakey(self, key):
self._datakey = key
@property
def dataproxy(self):
return self._dataProxy
def drop(self, pluginName):
# If no plugin match the name of the dropped plugin, do nothing.
plugin = REGISTRY["plugin"].get(pluginName,None)
if plugin is None:
return
if not issubclass(self.__class__,REGISTRY['plugin'][plugin.ancestor]):
return
plugin = plugin(self)
self._mgr.AddPane(plugin, wxaui.AuiPaneInfo().Caption(getattr(plugin, "label", pluginName)))
self._mgr.Update()
plugin.plug()
plugin.SetFocus()
def has_parent(self, window):
return False
def on_changing_pane(self, event):
window = plugin_parent(event.GetWindow())
if window is None:
return
self._currentWindow = window
pub.sendMessage(('set_plugins_tree'), message= window)
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 10, 2015
@author: pellegrini
'''
import logging
import wx
from MDANSE.Framework.Handlers.IHandler import IHandler
from MDANSE.Logging.Formatters import Formatter
class ConsoleHandler(IHandler, logging.Handler):
"""Sets up a GUI handler for the nMOLDYN logger.
Emits the logging message to the nMOLDYN GUI console.
@note: inherits from logging.Handler class that sets a generic handler.
"""
type = "console"
COLORS = {'DEBUG' : wx.GREEN,
'INFO' : wx.BLACK,
'WARNING' : wx.BLUE,
'ERROR' : wx.RED,
'CRITICAL' : wx.RED,
'FATAL' : wx.RED}
def __init__(self, window):
'''
The constructor.
@param console: the parent widget for the textctrl.
@type console: wx widget
'''
logging.Handler.__init__(self)
self.setFormatter(Formatter())
self._window = window
# Creates a wx text attribute.
self.style = wx.TextAttr()
# Set its font to a non proporiotnal font.
self.style.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL))
def emit(self, record):
"""
Send the log message to a wx.TextCtrl widget.
@param record: the log message.
@type record: logging.LogRecord
"""
self.style.SetTextColour(ConsoleHandler.COLORS.get(record.levelname,wx.BLACK))
# Set the the created text attribute as the default style for the text ctrl.
self._window.SetDefaultStyle(self.style)
# Append the log message to the text ctrl.
self._window.AppendText(self.format(record))
self._window.AppendText("\n")
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: pellegrini
'''
from MDANSE.App.GUI.Plugins.IPlugin import IPlugin
class ComponentPlugin(IPlugin):
type = None
@property
def datakey(self):
return self.parent.datakey
@property
def dataproxy(self):
return self.parent.dataproxy
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 10, 2015
@author: pellegrini
'''
import logging
import wx
from MDANSE.Framework.Handlers.IHandler import IHandler
class DialogHandler(IHandler, logging.Handler):
type = "dialog"
ICONS = {"DEBUG" : wx.ICON_INFORMATION,
"CRITICAL" : wx.ICON_ERROR,
"ERROR" : wx.ICON_ERROR,
"INFO" : wx.ICON_INFORMATION,
"WARNING" : wx.ICON_WARNING,
}
def emit(self, record):
icon = DialogHandler.ICONS[record.levelname]
d = wx.MessageDialog(None, message=self.format(record), style=wx.OK|wx.STAY_ON_TOP|icon)
d.ShowModal()
\ No newline at end of file
......@@ -31,8 +31,8 @@ Created on Mar 30, 2015
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class AtomSelectionWidget(UserDefinitionWidget):
......@@ -54,7 +54,7 @@ class AtomSelectionWidget(UserDefinitionWidget):
return None
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of atom selection definitions selected")
raise ConfigurationError("Invalid number of atom selection definitions selected")
return names[0]
......
......@@ -31,8 +31,8 @@ Created on Mar 30, 2015
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class AxisSelectionWidget(UserDefinitionWidget):
......@@ -51,7 +51,7 @@ class AxisSelectionWidget(UserDefinitionWidget):
names = self._selections.GetControl().GetCheckedStrings()
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of axis definitions selected")
raise ConfigurationError("Invalid number of axis definitions selected")
return names[0]
......
......@@ -31,8 +31,8 @@ Created on Mar 30, 2015
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class BasisSelectionWidget(UserDefinitionWidget):
......@@ -51,7 +51,7 @@ class BasisSelectionWidget(UserDefinitionWidget):
names = self._selections.GetControl().GetCheckedStrings()
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of basis definitions selected")
raise ConfigurationError("Invalid number of basis definitions selected")
return names[0]
......
......@@ -32,9 +32,9 @@ Created on Mar 30, 2015
import wx
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class BooleanWidget(IConfiguratorWidget):
class BooleanWidget(IWidget):
type = "boolean"
......
......@@ -32,8 +32,9 @@ Created on Mar 30, 2015
import wx
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI.ConfiguratorWidgets.StringWidget import StringWidget
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
class FloatWidget(StringWidget):
......@@ -60,7 +61,7 @@ class FloatWidget(StringWidget):
try:
_ = float(self._float.GetValue())
except ValueError:
raise ConfiguratorWidgetError("Invalid value for %r entry" % self.configurator.name)
raise ConfigurationError("Invalid value for %r entry" % self.configurator.name)
val = self._float.GetValue()
return val
......@@ -36,9 +36,9 @@ import wx.lib.intctrl as wxintctrl
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class FramesWidget(IConfiguratorWidget):
class FramesWidget(IWidget):
type = "frames"
......
......@@ -35,12 +35,8 @@ import abc
import wx
from MDANSE import REGISTRY
from MDANSE.Core.Error import Error
class ConfiguratorWidgetError(Error):
pass
class IConfiguratorWidget(wx.Panel):
class IWidget(wx.Panel):
__metaclass__ = REGISTRY
......@@ -62,42 +58,34 @@ class IConfiguratorWidget(wx.Panel):
self.build_panel()
@property
def configurator(self):
return self._configurator
@property
def label(self):
return self._label
@property
def name(self):
return self._name
@abc.abstractmethod
def initialize(self):
pass
@abc.abstractmethod
def get_widget_value(self):
pass
@abc.abstractmethod
def set_widget_value(self, value):
pass
@abc.abstractmethod
def add_widgets(self):
pass
def build_panel(self):
self._staticBox = wx.StaticBox(self, wx.ID_ANY, label=self.label)
......
......@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import wx
import wx.lib.filebrowsebutton as wxfile
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class InputDirectoryWidget(IConfiguratorWidget):
class InputDirectoryWidget(IWidget):
type = "input_directory"
......
......@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import wx
import wx.lib.filebrowsebutton as wxfile
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget, ConfiguratorWidgetError
from MDANSE.Framework.Configurable import ConfigurationError
class InputFileWidget(IConfiguratorWidget):
class InputFileWidget(IWidget):
type = "input_file"
......@@ -59,7 +59,7 @@ class InputFileWidget(IConfiguratorWidget):
filename = self._browser.GetValue()
if not filename:
raise ConfiguratorWidgetError("No input file selected", self)
raise ConfigurationError("No input file selected", self)
return filename
......
......@@ -44,7 +44,7 @@ from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.ComboWidgets.ConfigurationPanel import ConfigurationPanel
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class InstrumentResolutionDialog(wx.Dialog):
......@@ -183,7 +183,7 @@ class InstrumentResolutionDialog(wx.Dialog):
self.Fit()
class InstrumentResolutionConfigurator(IConfiguratorWidget):
class InstrumentResolutionConfigurator(IWidget):
type = "instrument_resolution"
......
......@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import wx
import wx.lib.intctrl as wxintctrl
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class IntegerWidget(IConfiguratorWidget):
class IntegerWidget(IWidget):
type = "integer"
......
......@@ -37,9 +37,9 @@ from MDANSE.Externals.pubsub import pub
from MDANSE.Mathematics.Signal import INTERPOLATION_ORDER
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class InterpolationOrderWidget(IConfiguratorWidget):
class InterpolationOrderWidget(IWidget):
type = "interpolation_order"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment