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
cc4ef5db
Commit
cc4ef5db
authored
Sep 17, 2015
by
eric pellegrini
Browse files
Bug fix in periodictable and elements database applications
parent
dc1410c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
MDANSE/Data/ElementsDatabase.py
View file @
cc4ef5db
...
...
@@ -373,8 +373,10 @@ class ElementsDatabase(object):
:type save: bool
'''
if
not
self
.
_data
.
has_key
(
ename
):
self
.
_data
[
ename
]
=
collections
.
OrderedDict
([(
pname
,
prop
())
for
pname
,
prop
in
self
.
_properties
.
iteritems
()])
if
self
.
_data
.
has_key
(
ename
):
raise
ElementsDatabaseError
(
"The element %r is already registered in the database."
%
ename
)
self
.
_data
[
ename
]
=
collections
.
OrderedDict
([(
pname
,
prop
())
for
pname
,
prop
in
self
.
_properties
.
iteritems
()])
# Create the corresponding MMTK entry
create_mmtk_atom_entry
(
ename
,
symbol
=
self
.
_data
[
ename
][
"symbol"
],
mass
=
self
.
_data
[
ename
][
"atomic_weight"
])
...
...
MDANSE/GUI/ElementsDatabaseEditor.py
View file @
cc4ef5db
...
...
@@ -35,7 +35,7 @@ import os
import
wx
import
wx.grid
as
wxgrid
from
MDANSE
import
ELEMENTS
from
MDANSE
import
ELEMENTS
,
LOGGER
from
MDANSE.Core.Singleton
import
Singleton
class
PropertyDialog
(
wx
.
Dialog
):
...
...
@@ -289,7 +289,8 @@ class ElementsDatabaseEditor(wx.Frame):
if
d
.
ShowModal
()
==
wx
.
ID_CANCEL
:
return
ename
=
d
.
GetValue
()
# Get rid of wxpython unicode string formatting
ename
=
str
(
d
.
GetValue
())
if
not
ename
:
return
...
...
@@ -309,7 +310,10 @@ class ElementsDatabaseEditor(wx.Frame):
pname
,
pdefault
=
d
.
GetValue
()
if
not
pname
:
return
return
# Get rid of wxpython unicode string formatting
pname
=
str
(
pname
)
self
.
_database
.
add_column
(
pname
,
pdefault
)
...
...
MDANSE/GUI/MainFrame.py
View file @
cc4ef5db
...
...
@@ -81,7 +81,7 @@ def excepthook(error, message, tback):
trace
=
'
\n
'
.
join
(
trace
)
LOGGER
(
trace
,
'error'
,[
'console'
])
LOGGER
(
trace
,
'error'
,[
'console'
,
'dialog'
])
class
MainFrame
(
wx
.
Frame
):
...
...
MDANSE/GUI/PeriodicTableViewer.py
View file @
cc4ef5db
...
...
@@ -426,29 +426,23 @@ class PeriodicTableViewer(wx.Frame):
for
i
in
_COLS
:
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
str
(
i
),
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
SetBackgroundColour
((
230
,
230
,
220
))
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
0
,
i
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
for
i
,
v
in
enumerate
(
_ROWS
):
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
str
(
v
),
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
SetBackgroundColour
((
230
,
230
,
220
))
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
i
+
1
,
0
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
"*"
,
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
6
,
3
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
"**"
,
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
7
,
3
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
"*"
,
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
9
,
3
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
wid
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
value
=
"**"
,
size
=
(
40
,
40
),
style
=
wx
.
ALIGN_CENTER_HORIZONTAL
|
wx
.
EXPAND
|
wx
.
TE_READONLY
|
wx
.
NO_BORDER
)
wid
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
on_select_element
)
mainSizer
.
Add
(
wid
,
(
10
,
3
),
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER
|
wx
.
FIXED_MINSIZE
|
wx
.
EXPAND
,
border
=
1
)
# The panel that will contain the short info about a selected element.
...
...
@@ -484,9 +478,6 @@ class PeriodicTableViewer(wx.Frame):
self
.
Bind
(
wx
.
EVT_CLOSE
,
self
.
on_quit
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_open_database
,
edit
)
def
on_fake_event
(
self
,
event
):
pass
def
on_quit
(
self
,
event
):
d
=
wx
.
MessageDialog
(
None
,
'Do you really want to quit ?'
,
'Question'
,
wx
.
YES_NO
|
wx
.
YES_DEFAULT
|
wx
.
ICON_QUESTION
)
...
...
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