From 55e04e1f4066d2a4629f682a52cc9cbb151a958a Mon Sep 17 00:00:00 2001 From: tatiana Date: Thu, 11 Feb 2010 10:52:27 +0000 Subject: [PATCH] FIX: 196, error on config parser (all characters messed up) --- invesalius/data/slice_.py | 12 ++++++++++++ invesalius/gui/data_notebook.py | 2 ++ invesalius/session.py | 21 ++++++--------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index f3dd7ac..08bd0f9 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -88,15 +88,22 @@ class Slice(object): ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') def OnRemoveMasks(self, pubsub_evt): + print "slice_: OnRemoveMasks" selected_items = pubsub_evt.data + print "selected_items:", selected_items proj = Project() + print "1", proj.mask_dict for item in selected_items: proj.RemoveMask(item) + print "2", proj.mask_dict #index = self.current_mask.index + print "current_mask", self.current_mask.index if (proj.mask_dict) and (self.current_mask.index in selected_items): + print "first mask exist" self.current_mask = proj.mask_dict[0] self.SelectCurrentMask(0) elif not proj.mask_dict: + print "no mask" self.blend_filter.SetOpacity(1, 0) self.blend_filter.Update() ps.Publisher().sendMessage('Update slice viewer') @@ -208,6 +215,8 @@ class Slice(object): def __show_mask(self, pubsub_evt): # "if" is necessary because wx events are calling this before any mask # has been created + print "__show_mask" + print "self.current_mask", self.current_mask if self.current_mask: index, value = pubsub_evt.data self.ShowMask(index, value) @@ -359,6 +368,8 @@ class Slice(object): # This condition is not necessary in Linux, only under mac and windows # because combobox event is binded when the same item is selected again. #if index != self.current_mask.index: + print "SelectCurrentMask" + print "index:", index if self.current_mask and self.blend_filter and index > -1: proj = Project() future_mask = proj.GetMask(index) @@ -367,6 +378,7 @@ class Slice(object): colour = future_mask.colour #index = future_mask.index + print index self.SetMaskColour(index, colour, update=False) imagedata = future_mask.imagedata diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index c6b3c3e..c88aebd 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -324,9 +324,11 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): self.ToggleItem(evt.m_itemIndex) def OnCheckItem(self, index, flag): + print "OnCheckItem", index, flag if flag: for key in self.mask_list_index.keys(): if key != index: + print "x" self.SetItemImage(key, 0) ps.Publisher().sendMessage('Change mask selected',index) self.current_index = index diff --git a/invesalius/session.py b/invesalius/session.py index 4cc04d3..75f7825 100644 --- a/invesalius/session.py +++ b/invesalius/session.py @@ -144,19 +144,6 @@ class Session(object): for i in xrange(len(l)-const.PROJ_MAX): l.pop() - def SavePlist(self): - filename = 'session.conf' - filepath = os.join(self.tempdir, filename) - plistlib.writePlist(self.__dict__, filepath) - - def OpenPlist(self): - filename = 'session.conf' - filepath = os.join(self.tempdir, filename) - # TODO: try/except - dict = plistlib.readPlist(main_plist) - for key in dict: - setattr(self, key, dict[key]) - def GetLanguage(self): return self.language @@ -178,7 +165,9 @@ class Session(object): config.read(path) self.language = config.get('session','language') return self.language - except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): + except (ConfigParser.NoSectionError, + ConfigParser.NoOptionError, + ConfigParser.MissingSectionHeaderError): return False def ReadSession(self): @@ -197,7 +186,9 @@ class Session(object): self.tempdir = config.get('paths','tempdir') self.last_dicom_folder = config.get('paths','last_dicom_folder') return True - except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): + except(ConfigParser.NoSectionError, + ConfigParser.NoOptionError, + ConfigParser.MissingSectionHeaderError): return False -- libgit2 0.21.2