Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
5977036a
Commit
5977036a
authored
Jul 23, 2015
by
eric pellegrini
Browse files
Simplified the outputfiles widget and its related configurator
parent
8871cc38
Changes
2
Hide whitespace changes
Inline
Side-by-side
MDANSE/App/GUI/Framework/Widgets/OutputFilesWidget.py
View file @
5977036a
...
...
@@ -47,16 +47,9 @@ class OutputFilesWidget(IWidget):
def
add_widgets
(
self
):
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
startDirectory
=
os
.
getcwd
()
self
.
_dirname
=
wxfile
.
DirBrowseButton
(
self
.
_widgetPanel
,
wx
.
ID_ANY
,
startDirectory
=
startDirectory
,
newDirectory
=
True
)
self
.
_dirname
.
SetValue
(
startDirectory
)
label
=
wx
.
StaticText
(
self
.
_widgetPanel
,
label
=
"Basename"
,
style
=
wx
.
ALIGN_LEFT
)
self
.
_filename
=
wxfile
.
FileBrowseButton
(
self
.
_widgetPanel
,
wx
.
ID_ANY
,
fileMode
=
wx
.
FD_SAVE
|
wx
.
FD_OVERWRITE_PROMPT
,
labelText
=
"Basename"
)
self
.
_basename
=
wx
.
TextCtrl
(
self
.
_widgetPanel
,
value
=
""
)
self
.
_formats
=
wx
.
combo
.
ComboCtrl
(
self
.
_widgetPanel
,
value
=
"output formats"
,
style
=
wx
.
CB_READONLY
)
tcp
=
ComboCheckbox
(
self
.
_configurator
.
formats
)
...
...
@@ -65,11 +58,9 @@ class OutputFilesWidget(IWidget):
hSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
hSizer
.
Add
(
label
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
,
5
)
hSizer
.
Add
(
self
.
_basename
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
hSizer
.
Add
(
self
.
_formats
,
0
,
wx
.
ALL
,
5
)
hSizer
.
Add
(
self
.
_filename
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
hSizer
.
Add
(
self
.
_formats
,
0
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
sizer
.
Add
(
self
.
_dirname
,
0
,
wx
.
ALL
|
wx
.
EXPAND
)
sizer
.
Add
(
hSizer
,
0
,
wx
.
ALL
|
wx
.
EXPAND
,
0
)
pub
.
subscribe
(
self
.
on_set_trajectory
,
(
"set_trajectory"
))
...
...
@@ -78,13 +69,11 @@ class OutputFilesWidget(IWidget):
def
get_widget_value
(
self
):
dirname
=
self
.
_dirname
.
GetValue
()
basename
=
self
.
_basename
.
GetValue
().
strip
()
filename
=
self
.
_filename
.
GetValue
()
formats
=
self
.
_formats
.
GetPopupControl
().
GetControl
().
GetCheckedStrings
()
return
(
dirname
,
bas
ename
,
formats
)
return
(
fil
ename
,
formats
)
def
on_set_trajectory
(
self
,
message
):
...
...
@@ -92,5 +81,9 @@ class OutputFilesWidget(IWidget):
if
not
window
in
self
.
Parent
.
widgets
.
values
():
return
self
.
_basename
.
SetValue
(
"output_%s"
%
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]))
\ No newline at end of file
trajectoryDir
=
os
.
path
.
dirname
(
filename
)
basename
=
"output_%s"
%
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
self
.
_filename
.
SetValue
(
os
.
path
.
join
(
trajectoryDir
,
basename
))
MDANSE/Framework/Configurators/OutputFilesConfigurator.py
View file @
5977036a
...
...
@@ -75,16 +75,13 @@ class OutputFilesConfigurator(IConfigurator):
if the output directory, 2nd element the basename and 3rd element a list of file formats.
:type value: 3-tuple
'''
dirname
,
basename
,
formats
=
value
if
not
dirname
:
dirname
=
os
.
getcwd
()
root
,
formats
=
value
if
not
basename
:
raise
ConfiguratorError
(
"empty
base
name for the output file."
,
self
)
root
=
os
.
path
.
join
(
dirname
,
basename
)
if
not
root
:
raise
ConfiguratorError
(
"empty
root
name for the output file."
,
self
)
dirname
=
os
.
path
.
dirname
(
root
)
try
:
PLATFORM
.
create_directory
(
dirname
)
...
...
@@ -102,7 +99,7 @@ class OutputFilesConfigurator(IConfigurator):
if
not
REGISTRY
[
"format"
].
has_key
(
fmt
):
raise
ConfiguratorError
(
"the output file format %r is not registered as a valid file format."
%
fmt
,
self
)
self
[
"
root
"
]
=
root
self
[
'
root
'
]
=
root
self
[
"formats"
]
=
formats
self
[
"files"
]
=
[
"%s%s"
%
(
root
,
REGISTRY
[
"format"
][
f
].
extension
)
for
f
in
formats
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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