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
573cf921
Commit
573cf921
authored
Sep 22, 2015
by
eric pellegrini
Browse files
The registry viewer and the user definition viewer are now derived from
wx.Dialog
parent
cf9e27cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
MDANSE/GUI/RegistryViewer.py
View file @
573cf921
...
...
@@ -37,11 +37,11 @@ import wx.html as wxhtml
from
MDANSE
import
PLATFORM
,
REGISTRY
class
RegistryViewer
(
wx
.
Frame
):
class
RegistryViewer
(
wx
.
Dialog
):
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
wx
.
Frame
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
size
=
(
800
,
400
),
title
=
"Registry viewer"
,
style
=
wx
.
DEFAULT_
FRAME
_STYLE
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
|
wx
.
RESIZE_BORDER
)
wx
.
Dialog
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
size
=
(
800
,
400
),
title
=
"Registry viewer"
,
style
=
wx
.
DEFAULT_
DIALOG
_STYLE
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
|
wx
.
RESIZE_BORDER
)
mainPanel
=
wx
.
Panel
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
...
...
@@ -58,7 +58,6 @@ class RegistryViewer(wx.Frame):
mainPanel
.
SetSizer
(
mainSizer
)
self
.
Bind
(
wx
.
EVT_CLOSE
,
self
.
on_quit
)
self
.
Bind
(
wx
.
EVT_TREE_ITEM_ACTIVATED
,
self
.
on_double_click_data
)
self
.
set_plugins_tree
(
self
.
_root
,
REGISTRY
.
_registry
)
...
...
@@ -90,15 +89,10 @@ class RegistryViewer(wx.Frame):
moduleDocPath
=
os
.
path
.
join
(
PLATFORM
.
help_path
(),
moduleFullName
+
'.html'
)
self
.
_info
.
LoadPage
(
moduleDocPath
)
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
)
if
d
.
ShowModal
()
==
wx
.
ID_YES
:
self
.
Destroy
()
if
__name__
==
"__main__"
:
app
=
wx
.
App
(
False
)
f
=
RegistryViewer
(
None
)
f
.
Show
()
f
.
ShowModal
()
f
.
Destroy
()
app
.
MainLoop
()
\ No newline at end of file
MDANSE/GUI/UserDefinitionViewer.py
View file @
573cf921
...
...
@@ -36,11 +36,11 @@ from MDANSE import LOGGER
from
MDANSE.Externals.pubsub
import
pub
from
MDANSE.Framework.UserDefinitionStore
import
UD_STORE
class
UserDefinitionViewer
(
wx
.
Frame
):
class
UserDefinitionViewer
(
wx
.
Dialog
):
def
__init__
(
self
,
parent
,
title
=
"User Definition Viewer"
,
ud
=
None
,
editable
=
True
):
wx
.
Frame
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
size
=
(
800
,
400
),
title
=
title
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
|
wx
.
RESIZE_BORDER
)
wx
.
Dialog
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
size
=
(
800
,
400
),
title
=
title
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
|
wx
.
RESIZE_BORDER
)
self
.
_udTree
=
{}
...
...
@@ -50,7 +50,7 @@ class UserDefinitionViewer(wx.Frame):
self
.
_root
=
self
.
_tree
.
AddRoot
(
"root"
)
self
.
set_plugins
_tree
(
self
.
_root
,
UD_STORE
)
self
.
build
_tree
(
self
.
_root
,
UD_STORE
.
definitions
)
self
.
_info
=
wx
.
TextCtrl
(
mainPanel
,
wx
.
ID_ANY
,
style
=
wx
.
TE_MULTILINE
|
wx
.
TE_READONLY
)
...
...
@@ -72,8 +72,6 @@ class UserDefinitionViewer(wx.Frame):
self
.
Bind
(
wx
.
EVT_TREE_BEGIN_LABEL_EDIT
,
self
.
on_try_rename
,
self
.
_tree
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_save_ud
,
self
.
_save
)
self
.
Bind
(
wx
.
EVT_CLOSE
,
self
.
on_quit
)
if
ud
is
not
None
:
self
.
expand_ud
(
ud
)
...
...
@@ -95,8 +93,8 @@ class UserDefinitionViewer(wx.Frame):
else
:
return
1
+
self
.
get_item_level
(
parent
)
def
set_plugins
_tree
(
self
,
node
,
data
):
def
build
_tree
(
self
,
node
,
data
):
for
k
,
v
in
data
.
items
():
dataItem
=
wx
.
TreeItemData
(
v
)
...
...
@@ -105,7 +103,7 @@ class UserDefinitionViewer(wx.Frame):
self
.
_tree
.
SetItemTextColour
(
subnode
,
'blue'
)
if
isinstance
(
v
,
dict
):
self
.
set_plugins
_tree
(
subnode
,
v
)
self
.
build
_tree
(
subnode
,
v
)
def
find_ud
(
self
,
baseitem
,
itemNames
):
...
...
@@ -170,14 +168,12 @@ class UserDefinitionViewer(wx.Frame):
currentItemName
=
str
(
self
.
_tree
.
GetItemText
(
currentItem
))
print
"on_delete"
,
currentItemName
if
level
==
1
:
UD_STORE
.
remove_
target
(
currentItemName
)
UD_STORE
.
remove_
definition
(
currentItemName
)
elif
level
==
2
:
targetItem
=
self
.
_tree
.
GetItemParent
(
currentItem
)
targetItemName
=
str
(
self
.
_tree
.
GetItemText
(
targetItem
))
UD_STORE
.
remove_
sec
tion
(
targetItemName
,
currentItemName
)
UD_STORE
.
remove_
defini
tion
(
targetItemName
,
currentItemName
)
elif
level
==
3
:
sectionItem
=
self
.
_tree
.
GetItemParent
(
currentItem
)
sectionItemName
=
str
(
self
.
_tree
.
GetItemText
(
sectionItem
))
...
...
@@ -236,14 +232,9 @@ class UserDefinitionViewer(wx.Frame):
UD_STORE
.
set_definition
(
targetItemName
,
sectionItemName
,
newItemName
,
currentItemData
.
GetData
())
UD_STORE
.
remove_definition
(
targetItemName
,
sectionItemName
,
currentItemName
)
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
)
if
d
.
ShowModal
()
==
wx
.
ID_YES
:
self
.
Destroy
()
if
__name__
==
"__main__"
:
app
=
wx
.
App
(
False
)
f
=
UserDefinitionViewer
(
None
,
ud
=
[
'protein_in_periodic_universe.nc'
,
'atom_selection'
,
"sfdfdfsd"
],
editable
=
True
)
f
.
Show
()
f
.
ShowModal
()
f
.
Destroy
()
app
.
MainLoop
()
\ No newline at end of file
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