Skip to content

Commit

Permalink
Issue #23 - title is now displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Müller committed Jun 22, 2013
1 parent f6275d7 commit 0525363
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/tools/chooseimport.py
Expand Up @@ -161,10 +161,12 @@ def OnClose(self, event=None):


def OnSelectCurves(self, buttonevent):
# Get the type of curves we want to look at
index = buttonevent.GetId() - 8000
self.buttonindex = index
curvedict = dict()
key = self.curvekeys[index]
# Get correlation curves for corresponding type
corrcurves = dict()
for i in self.curvedict[key]:
corrcurves[str(i)] = self.correlations[int(i)]
Expand Down
7 changes: 7 additions & 0 deletions src/tools/example.py
Expand Up @@ -5,6 +5,8 @@
Module tools - example
This is an example tool. You will need to edit __init__.py inside this
folder to activate it.
Add the filename (*example*) and class (*Tool*) to either of the lists
*ImpA* or *ImpB* in __init__.py.
Dimensionless representation:
unit of time : 1 ms
Expand Down Expand Up @@ -64,5 +66,10 @@ def OnPageChanged(self, page):
# This is a necessary function for PyCorrFit.
# This is stuff that should be done when the active page
# of the notebook changes.
if self.parent.notebook.GetPageCount() == 0:
# Do something when there are no pages left.
self.Disable()
return
self.Page = page


40 changes: 29 additions & 11 deletions src/tools/selectcurves.py
Expand Up @@ -71,8 +71,10 @@ def __init__(self, parent):
# This ID is given by the parent for an instance of this class
self.MyID = None
## Wrapping
curvedict = self.GetCurvedict()
self.Selector = UserSelectCurves(parent, curvedict, wrapper=self)
curvedict, labels = self.GetCurvedict()
self.labels = labels
self.Selector = UserSelectCurves(parent, curvedict,
wrapper=self, labels=labels)
# This is necessary for parent to deselect and select the tool
# in the tools menu.
self.Bind = self.Selector.Bind
Expand All @@ -88,14 +90,16 @@ def Enable(self, par=True):

def GetCurvedict(self, e=None):
curvedict = dict()
labels = dict()
N = self.parent.notebook.GetPageCount()
for i in np.arange(N):
Page = self.parent.notebook.GetPage(i)
key = Page.counter
curve = Page.dataexp
if curve is not None:
curvedict[key] = curve
return curvedict
labels[key] = Page.tabtitle.GetValue()
return curvedict, labels


def OnClose(self, event=None):
Expand All @@ -120,9 +124,10 @@ def OnPageChanged(self, page=None):
del self.Bind
self.Selector.Close()
del self.Selector
curvedict = self.GetCurvedict()
self.Selector = UserSelectCurves(self.parent,
curvedict, wrapper=self)
curvedict, labels = self.GetCurvedict()
self.labels = labels
self.Selector = UserSelectCurves(self.parent, curvedict,
wrapper=self, labels=labels)
self.Bind = self.Selector.Bind
self.Selector.SetSize(size)
self.Selector.SetPosition(pos)
Expand All @@ -149,7 +154,7 @@ def OnResults(self, keyskeep, keysrem):
# delete those pages.
warntext = "The following pages will be removed:\n"
for key in keysrem:
warntext += "- "+key+"\n"
warntext += "- "+key+" "+self.labels[key]+"\n"
dlg = wx.MessageDialog(self.parent, warntext, "Warning",
wx.OK|wx.ICON_EXCLAMATION|wx.CANCEL)
if dlg.ShowModal() == wx.ID_OK:
Expand All @@ -169,22 +174,28 @@ def OnResults(self, keyskeep, keysrem):

class UserSelectCurves(wx.Frame):
# This tool is derived from a wx.frame.
def __init__(self, parent, curvedict, wrapper=None, selkeys=None):
def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
labels=None):
"""
*curvedict* is a dictionary that contains the curves. Keys serve as
identifiers in the curve selection.
e.g.
curvelist["#1:"] = np.array[ np.array[0.0,1], np.array[0.0,.971] ...]
*parent* is the main frame
*wrapper* is the object to which the chosen keys are given back. If
it is not None, it must provide a function *OnResults*, accepting a list
of keys as an argument.
it is not None, it must provide a function *OnResults*, accepting
a list of keys as an argument.
*selkeys* items in the list *curvedict* that are preelected.
*labels* dictionary with same keys as *curvelist* - labels of the
entries in the list. If none, the keys of *curvedict* will be used.
"""
# parent is the main frame of PyCorrFit
self.parent = parent
self.wrapper = wrapper
self.curvedict = curvedict
self.selkeys = selkeys
self.labels = labels # can be None
self.curvelabels = None # filled by self.ProcessDict()
if self.selkeys is not None:
newselkeys = list()
for item in self.selkeys:
Expand Down Expand Up @@ -218,7 +229,7 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None):
# Box selection
style = wx.LB_EXTENDED
self.SelectBox = wx.ListBox(panel_bottom, size=(150,300), style=style,
choices=self.curvekeys)
choices=self.curvelabels)
for i in np.arange(len(self.curvekeys)):
self.SelectBox.SetSelection(i)
# Deselect keys that are not in self.selkeys
Expand Down Expand Up @@ -272,6 +283,13 @@ def ProcessDict(self, e=None):
else:
fstr = page_num
self.curvekeys.sort(key = fstr)
if self.labels is None:
self.curvelabels = self.curvekeys
else:
# Use given labels instead of curvekeys.
self.curvelabels = list()
for key in self.curvekeys:
self.curvelabels.append(str(key)+" "+self.labels[key])


def OnPushResults(self, e=None):
Expand Down

0 comments on commit 0525363

Please sign in to comment.