Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
b7c6f956
Commit
b7c6f956
authored
11 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Added some styles to elistbox.py
parent
a0cb2772
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/elistbox.py
+62
-29
62 additions, 29 deletions
fsl/utils/elistbox.py
with
62 additions
and
29 deletions
fsl/utils/elistbox.py
+
62
−
29
View file @
b7c6f956
...
@@ -56,6 +56,15 @@ ListRemoveEvent, EVT_ELB_REMOVE_EVENT = wxevent.NewEvent()
...
@@ -56,6 +56,15 @@ ListRemoveEvent, EVT_ELB_REMOVE_EVENT = wxevent.NewEvent()
ListMoveEvent
,
EVT_ELB_MOVE_EVENT
=
wxevent
.
NewEvent
()
ListMoveEvent
,
EVT_ELB_MOVE_EVENT
=
wxevent
.
NewEvent
()
# Do not allow new items to be added.
ELB_NO_ADD
=
1
# Do not allow items to be removed.
ELB_NO_REMOVE
=
2
# Do not allow items to be reordered.
ELB_NO_MOVE
=
4
class
EditableListBox
(
wx
.
Panel
):
class
EditableListBox
(
wx
.
Panel
):
"""
"""
An EditableListBox contains a ListBox containing some items,
An EditableListBox contains a ListBox containing some items,
...
@@ -66,53 +75,73 @@ class EditableListBox(wx.Panel):
...
@@ -66,53 +75,73 @@ class EditableListBox(wx.Panel):
- parent: wx parent object
- parent: wx parent object
- choices: list of strings, the items in the list
- choices: list of strings, the items in the list
- clientData: list of data associated with the list items.
- clientData: list of data associated with the list items.
- style: Style bitmask - accepts ELB_NO_ADD, ELB_NO_REMOVE,
and ELB_NO_MOVE.
"""
"""
def
__init__
(
def
__init__
(
self
,
self
,
parent
,
parent
,
choices
,
choices
,
clientData
=
None
):
clientData
=
None
,
style
=
0
):
wx
.
Panel
.
__init__
(
self
,
parent
)
wx
.
Panel
.
__init__
(
self
,
parent
)
addSupport
=
not
(
style
&
ELB_NO_ADD
)
removeSupport
=
not
(
style
&
ELB_NO_REMOVE
)
moveSupport
=
not
(
style
&
ELB_NO_MOVE
)
noButtons
=
not
any
((
addSupport
,
removeSupport
,
moveSupport
))
if
clientData
is
None
:
clientData
=
[
None
]
*
len
(
choices
)
if
clientData
is
None
:
clientData
=
[
None
]
*
len
(
choices
)
self
.
listBox
=
wx
.
ListBox
(
# The list box containing the list of items
self
,
style
=
wx
.
LB_SINGLE
|
wx
.
LB_NEEDED_SB
)
self
.
listBox
=
wx
.
ListBox
(
self
,
style
=
wx
.
LB_SINGLE
|
wx
.
LB_NEEDED_SB
)
self
.
listBox
.
Bind
(
wx
.
EVT_LISTBOX
,
self
.
_itemSelected
)
for
choice
,
data
in
zip
(
choices
,
clientData
):
for
choice
,
data
in
zip
(
choices
,
clientData
):
self
.
listBox
.
Append
(
choice
,
data
)
self
.
listBox
.
Append
(
choice
,
data
)
self
.
buttonPanel
=
wx
.
Panel
(
self
)
# A panel containing buttons for doing stuff with the list
if
not
noButtons
:
self
.
upButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25B2
'
,
self
.
buttonPanel
=
wx
.
Panel
(
self
)
style
=
wx
.
BU_EXACTFIT
)
self
.
buttonPanelSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
downButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25BC
'
,
self
.
buttonPanel
.
SetSizer
(
self
.
buttonPanelSizer
)
style
=
wx
.
BU_EXACTFIT
)
self
.
addButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
+
'
,
# Buttons for moving the selected item up/down
style
=
wx
.
BU_EXACTFIT
)
if
moveSupport
:
self
.
removeButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
-
'
,
self
.
upButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25B2
'
,
style
=
wx
.
BU_EXACTFIT
)
style
=
wx
.
BU_EXACTFIT
)
self
.
downButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
u
'
\u25BC
'
,
self
.
listBox
.
Bind
(
wx
.
EVT_LISTBOX
,
self
.
_itemSelected
)
style
=
wx
.
BU_EXACTFIT
)
self
.
upButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_moveItemUp
)
self
.
upButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_moveItemUp
)
self
.
downButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_moveItemDown
)
self
.
downButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_moveItemDown
)
self
.
addButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_addItem
)
self
.
removeButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_removeItem
)
self
.
buttonPanelSizer
.
Add
(
self
.
upButton
,
flag
=
wx
.
EXPAND
)
self
.
buttonPanelSizer
.
Add
(
self
.
downButton
,
flag
=
wx
.
EXPAND
)
self
.
buttonPanelSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
buttonPanel
.
SetSizer
(
self
.
buttonPanelSizer
)
# Button for adding new items
self
.
buttonPanelSizer
.
Add
(
self
.
upButton
,
flag
=
wx
.
EXPAND
)
if
addSupport
:
self
.
buttonPanelSizer
.
Add
(
self
.
downButton
,
flag
=
wx
.
EXPAND
)
self
.
addButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
+
'
,
self
.
buttonPanelSizer
.
Add
(
self
.
addButton
,
flag
=
wx
.
EXPAND
)
style
=
wx
.
BU_EXACTFIT
)
self
.
buttonPanelSizer
.
Add
(
self
.
removeButton
,
flag
=
wx
.
EXPAND
)
self
.
addButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_addItem
)
self
.
buttonPanelSizer
.
Add
(
self
.
addButton
,
flag
=
wx
.
EXPAND
)
# Button for removing the selected item
if
removeSupport
:
self
.
removeButton
=
wx
.
Button
(
self
.
buttonPanel
,
label
=
'
-
'
,
style
=
wx
.
BU_EXACTFIT
)
self
.
removeButton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
_removeItem
)
self
.
buttonPanelSizer
.
Add
(
self
.
removeButton
,
flag
=
wx
.
EXPAND
)
self
.
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
SetSizer
(
self
.
sizer
)
self
.
SetSizer
(
self
.
sizer
)
self
.
sizer
.
Add
(
self
.
buttonPanel
,
flag
=
wx
.
EXPAND
)
if
not
noButtons
:
self
.
sizer
.
Add
(
self
.
listBox
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
sizer
.
Add
(
self
.
buttonPanel
,
flag
=
wx
.
EXPAND
)
self
.
sizer
.
Add
(
self
.
listBox
,
flag
=
wx
.
EXPAND
,
proportion
=
1
)
self
.
sizer
.
Layout
()
self
.
sizer
.
Layout
()
...
@@ -208,6 +237,8 @@ class EditableListBox(wx.Panel):
...
@@ -208,6 +237,8 @@ class EditableListBox(wx.Panel):
idx
,
choice
,
data
=
self
.
_getSelection
()
idx
,
choice
,
data
=
self
.
_getSelection
()
log
.
debug
(
'
ListAddEvent (idx: {}; choice: {})
'
.
format
(
idx
,
choice
))
ev
=
ListAddEvent
(
idx
=
idx
,
choice
=
choice
,
data
=
data
)
ev
=
ListAddEvent
(
idx
=
idx
,
choice
=
choice
,
data
=
data
)
wx
.
PostEvent
(
self
,
ev
)
wx
.
PostEvent
(
self
,
ev
)
...
@@ -226,6 +257,8 @@ class EditableListBox(wx.Panel):
...
@@ -226,6 +257,8 @@ class EditableListBox(wx.Panel):
self
.
listBox
.
Delete
(
idx
)
self
.
listBox
.
Delete
(
idx
)
self
.
listBox
.
SetSelection
(
wx
.
NOT_FOUND
)
self
.
listBox
.
SetSelection
(
wx
.
NOT_FOUND
)
log
.
debug
(
'
ListRemoveEvent (idx: {}; choice: {})
'
.
format
(
idx
,
choice
))
ev
=
ListRemoveEvent
(
idx
=
idx
,
choice
=
choice
,
data
=
data
)
ev
=
ListRemoveEvent
(
idx
=
idx
,
choice
=
choice
,
data
=
data
)
wx
.
PostEvent
(
self
,
ev
)
wx
.
PostEvent
(
self
,
ev
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment