Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
7b12be21
Commit
7b12be21
authored
Apr 14, 2015
by
eric pellegrini
Browse files
Fix some import bug related to old architecture
parent
10c38dc7
Changes
45
Hide whitespace changes
Inline
Side-by-side
MDANSE/App/GUI/ConfiguratorWidgets/__init__.py
deleted
100644 → 0
View file @
10c38dc7
def
has_parent
(
window
,
target
):
if
window
==
target
:
return
True
if
window
.
TopLevelParent
==
window
:
return
False
return
has_parent
(
window
.
Parent
,
target
)
MDANSE/App/GUI/
Plugins/DataPlugin
.py
→
MDANSE/App/GUI/
Framework/Handlers/ConsoleHandler
.py
View file @
7b12be21
#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/App/GUI/
Plugins/ComponentPlugin
.py
→
MDANSE/App/GUI/
Framework/Handlers/DialogHandler
.py
View file @
7b12be21
#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
MDANSE/App/GUI/Handlers/__init__.py
→
MDANSE/App/GUI/
Framework/
Handlers/__init__.py
View file @
7b12be21
File moved
MDANSE/App/GUI/
Handler
s/ConsoleHandler.py
→
MDANSE/App/GUI/
Framework/Plugin
s/ConsoleHandler.py
View file @
7b12be21
File moved
MDANSE/App/GUI/
Handler
s/DialogHandler.py
→
MDANSE/App/GUI/
Framework/Plugin
s/DialogHandler.py
View file @
7b12be21
File moved
MDANSE/App/GUI/
Configurator
Widgets/AtomSelectionWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/AtomSelectionWidget.py
View file @
7b12be21
...
...
@@ -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
Configurat
orWidget
Error
(
"Invalid number of atom selection definitions selected"
)
raise
Configurat
ion
Error
(
"Invalid number of atom selection definitions selected"
)
return
names
[
0
]
...
...
MDANSE/App/GUI/
Configurator
Widgets/AtomTransmutationWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/AtomTransmutationWidget.py
View file @
7b12be21
File moved
MDANSE/App/GUI/
Configurator
Widgets/AxisSelectionWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/AxisSelectionWidget.py
View file @
7b12be21
...
...
@@ -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
Configurat
orWidget
Error
(
"Invalid number of axis definitions selected"
)
raise
Configurat
ion
Error
(
"Invalid number of axis definitions selected"
)
return
names
[
0
]
...
...
MDANSE/App/GUI/
Configurator
Widgets/BasisSelectionWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/BasisSelectionWidget.py
View file @
7b12be21
...
...
@@ -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
Configurat
orWidget
Error
(
"Invalid number of basis definitions selected"
)
raise
Configurat
ion
Error
(
"Invalid number of basis definitions selected"
)
return
names
[
0
]
...
...
MDANSE/App/GUI/
Configurator
Widgets/BooleanWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/BooleanWidget.py
View file @
7b12be21
...
...
@@ -32,9 +32,9 @@ Created on Mar 30, 2015
import
wx
from
MDANSE.App.GUI.
ConfiguratorWidgets.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
BooleanWidget
(
I
Configurator
Widget
):
class
BooleanWidget
(
IWidget
):
type
=
"boolean"
...
...
MDANSE/App/GUI/
Configurator
Widgets/FloatWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/FloatWidget.py
View file @
7b12be21
...
...
@@ -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
Configurat
orWidget
Error
(
"Invalid value for %r entry"
%
self
.
configurator
.
name
)
raise
Configurat
ion
Error
(
"Invalid value for %r entry"
%
self
.
configurator
.
name
)
val
=
self
.
_float
.
GetValue
()
return
val
MDANSE/App/GUI/
Configurator
Widgets/FramesWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/FramesWidget.py
View file @
7b12be21
...
...
@@ -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.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
FramesWidget
(
I
Configurator
Widget
):
class
FramesWidget
(
IWidget
):
type
=
"frames"
...
...
MDANSE/App/GUI/
Configurator
Widgets/GroupingLevelWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/GroupingLevelWidget.py
View file @
7b12be21
File moved
MDANSE/App/GUI/
ConfiguratorWidgets/IConfigurator
Widget.py
→
MDANSE/App/GUI/
Framework/Widgets/I
Widget.py
View file @
7b12be21
...
...
@@ -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
)
...
...
MDANSE/App/GUI/
Configurator
Widgets/InputDirectoryWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/InputDirectoryWidget.py
View file @
7b12be21
...
...
@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import
wx
import
wx.lib.filebrowsebutton
as
wxfile
from
MDANSE.App.GUI.
ConfiguratorWidgets.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
InputDirectoryWidget
(
I
Configurator
Widget
):
class
InputDirectoryWidget
(
IWidget
):
type
=
"input_directory"
...
...
MDANSE/App/GUI/
Configurator
Widgets/InputFileWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/InputFileWidget.py
View file @
7b12be21
...
...
@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import
wx
import
wx.lib.filebrowsebutton
as
wxfile
from
MDANSE.
App.GUI.ConfiguratorWidgets.IConfiguratorWidget
import
I
Configurat
orWidget
,
ConfiguratorWidget
Error
from
MDANSE.
Framework.Configurable
import
Configurat
ion
Error
class
InputFileWidget
(
I
Configurator
Widget
):
class
InputFileWidget
(
IWidget
):
type
=
"input_file"
...
...
@@ -59,7 +59,7 @@ class InputFileWidget(IConfiguratorWidget):
filename
=
self
.
_browser
.
GetValue
()
if
not
filename
:
raise
Configurat
orWidget
Error
(
"No input file selected"
,
self
)
raise
Configurat
ion
Error
(
"No input file selected"
,
self
)
return
filename
...
...
MDANSE/App/GUI/
Configurator
Widgets/InstrumentResolutionWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/InstrumentResolutionWidget.py
View file @
7b12be21
...
...
@@ -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.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
InstrumentResolutionDialog
(
wx
.
Dialog
):
...
...
@@ -183,7 +183,7 @@ class InstrumentResolutionDialog(wx.Dialog):
self
.
Fit
()
class
InstrumentResolutionConfigurator
(
I
Configurator
Widget
):
class
InstrumentResolutionConfigurator
(
IWidget
):
type
=
"instrument_resolution"
...
...
MDANSE/App/GUI/
Configurator
Widgets/IntegerWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/IntegerWidget.py
View file @
7b12be21
...
...
@@ -33,9 +33,9 @@ Created on Mar 30, 2015
import
wx
import
wx.lib.intctrl
as
wxintctrl
from
MDANSE.App.GUI.
ConfiguratorWidgets.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
IntegerWidget
(
I
Configurator
Widget
):
class
IntegerWidget
(
IWidget
):
type
=
"integer"
...
...
MDANSE/App/GUI/
Configurator
Widgets/InterpolationOrderWidget.py
→
MDANSE/App/GUI/
Framework/
Widgets/InterpolationOrderWidget.py
View file @
7b12be21
...
...
@@ -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.IConfigurator
Widget
import
I
Configurator
Widget
from
MDANSE.App.GUI.
Framework.Widgets.I
Widget
import
IWidget
class
InterpolationOrderWidget
(
I
Configurator
Widget
):
class
InterpolationOrderWidget
(
IWidget
):
type
=
"interpolation_order"
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment