Commit b1aaf9c9282c5c87545f909ea6a09bedfec71c6f
1 parent
a2e1a20e
Exists in
master
and in
68 other branches
ENH: Changed wx.Event to pubsub
Showing
3 changed files
with
29 additions
and
20 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -35,9 +35,9 @@ class Controller(): |
35 | 35 | 'Save raycasting preset') |
36 | 36 | ps.Publisher().subscribe(self.OnOpenDicomGroup, |
37 | 37 | 'Open DICOM group') |
38 | - #ps.Publisher().subscribe(self.CancelDicomLoad, | |
39 | - # "Cancel DICOM load in the control") | |
40 | - | |
38 | + ps.Publisher().subscribe(self.Progress, "Update dicom load") | |
39 | + ps.Publisher().subscribe(self.LoadPanel, "End dicom load") | |
40 | + | |
41 | 41 | def StartImportPanel(self, pubsub_evt): |
42 | 42 | # path to directory |
43 | 43 | path = pubsub_evt.data |
... | ... | @@ -47,16 +47,20 @@ class Controller(): |
47 | 47 | reader.SetWindowEvent(self.frame) |
48 | 48 | reader.SetDirectoryPath(path) |
49 | 49 | |
50 | - self.frame.Bind(reader.evt_update_progress, self.Progress) | |
51 | - self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) | |
50 | + #self.frame.Bind(reader.evt_update_progress, self.Progress) | |
51 | + #self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) | |
52 | 52 | |
53 | 53 | def Progress(self, evt): |
54 | - if (evt.progress): | |
54 | + print evt | |
55 | + data = evt.data | |
56 | + | |
57 | + if (data): | |
55 | 58 | if not(self.progress_dialog): |
56 | 59 | self.progress_dialog = dialog.ProgressDialog( |
57 | - maximum = evt.progress[1]) | |
60 | + maximum = data[1]) | |
58 | 61 | else: |
59 | - if not(self.progress_dialog.Update(evt.progress[0])): | |
62 | + print data[0] | |
63 | + if not(self.progress_dialog.Update(data[0])): | |
60 | 64 | self.progress_dialog.Close() |
61 | 65 | self.progress_dialog = None |
62 | 66 | else: |
... | ... | @@ -66,7 +70,7 @@ class Controller(): |
66 | 70 | |
67 | 71 | |
68 | 72 | def LoadPanel(self,evt): |
69 | - patient_series = evt.value | |
73 | + patient_series = evt.data | |
70 | 74 | if patient_series: |
71 | 75 | ps.Publisher().sendMessage("Load import panel", patient_series) |
72 | 76 | first_patient = patient_series[0] | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -83,8 +83,11 @@ class ProgressDialog(object): |
83 | 83 | ps.Publisher().sendMessage("Cancel DICOM load") |
84 | 84 | |
85 | 85 | def Update(self, value): |
86 | - if(value != self.maximum): | |
87 | - self.dlg.Update(value) | |
86 | + if(value != self.maximum): | |
87 | + try: | |
88 | + self.dlg.Update(value) | |
89 | + except(wx._core.PyAssertionError): | |
90 | + pass | |
88 | 91 | return True |
89 | 92 | else: |
90 | 93 | return False | ... | ... |
invesalius/reader/dicom_reader.py
... | ... | @@ -85,7 +85,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): |
85 | 85 | nfiles = len(filenames) |
86 | 86 | |
87 | 87 | print "TOTAL FILES:", nfiles |
88 | - counter = 0.0 | |
88 | + counter = 0 | |
89 | 89 | grouper = dicom_grouper.DicomPatientGrouper() |
90 | 90 | # Retrieve only DICOM files, splited into groups |
91 | 91 | if recursive: |
... | ... | @@ -123,11 +123,11 @@ def GetDicomGroups(directory, recursive=True): |
123 | 123 | class ProgressDicomReader: |
124 | 124 | |
125 | 125 | def __init__(self): |
126 | - (self.LoadFilesProgress, EVT_LOAD_FILE_PROGRESS) = wx.lib.newevent.NewEvent() | |
127 | - (self.EndLoadFiles, EVT_END_LOAD_FILE) = wx.lib.newevent.NewEvent() | |
126 | + #(self.LoadFilesProgress, EVT_LOAD_FILE_PROGRESS) = wx.lib.newevent.NewEvent() | |
127 | + #(self.EndLoadFiles, EVT_END_LOAD_FILE) = wx.lib.newevent.NewEvent() | |
128 | 128 | |
129 | - self.evt_update_progress = EVT_LOAD_FILE_PROGRESS | |
130 | - self.evt_end_load_file = EVT_END_LOAD_FILE | |
129 | + #self.evt_update_progress = EVT_LOAD_FILE_PROGRESS | |
130 | + #self.evt_end_load_file = EVT_END_LOAD_FILE | |
131 | 131 | |
132 | 132 | ps.Publisher().subscribe(self.CancelLoad, "Cancel DICOM load") |
133 | 133 | |
... | ... | @@ -144,12 +144,14 @@ class ProgressDicomReader: |
144 | 144 | thread.start_new_thread(self.GetDicomGroups,(path,recursive)) |
145 | 145 | |
146 | 146 | def UpdateLoadFileProgress(self,cont_progress): |
147 | - evt = self.LoadFilesProgress(progress = cont_progress) | |
148 | - wx.PostEvent(self.frame, evt) | |
147 | + ps.Publisher().sendMessage("Update dicom load", cont_progress) | |
148 | + #evt = self.LoadFilesProgress(progress = cont_progress) | |
149 | + #wx.PostEvent(self.frame, evt) | |
149 | 150 | |
150 | 151 | def EndLoadFile(self, grouper): |
151 | - evt = self.EndLoadFiles(value = grouper) | |
152 | - wx.PostEvent(self.frame, evt) | |
152 | + ps.Publisher().sendMessage("End dicom load", grouper) | |
153 | + #evt = self.EndLoadFiles(value = grouper) | |
154 | + #wx.PostEvent(self.frame, evt) | |
153 | 155 | |
154 | 156 | def GetDicomGroups(self, path, recursive): |
155 | 157 | y = yGetDicomGroups(path, recursive) | ... | ... |