Exemplo n.º 1
0
 def on_analyze_images(self):
     self.__odds_and_ends_panel.Sizer.Hide(self.__analyze_images_button)
     self.__odds_and_ends_panel.Sizer.Show(self.__stop_analysis_button)
     self.__odds_and_ends_panel.Layout()
     self.pause_button.SetLabel('Pause')
     self.__panel.Sizer.Hide(self.__status_text)
     self.__panel.Sizer.Show(self.__progress_panel)
     self.__panel.Parent.Layout()
     self.__panel.Layout()
     # begin tracking progress
     self.__progress_watcher = ProgressWatcher(self.__progress_panel,
                                               self.update_progress,
                                               distributed=cpdistributed.run_distributed())
Exemplo n.º 2
0
 def __make_odds_and_ends_panel(self):
     panel = self.__odds_and_ends_panel
     self.__output_filename_text = wx.StaticText(panel,-1,'Output Filename:')
     self.__output_filename_edit_box = wx.TextCtrl(panel,-1,'DefaultOUT.mat')
     self.__allow_output_filename_overwrite_check_box = \
         wx.CheckBox(panel, label = "Allow overwrite?")
     self.__allow_output_filename_overwrite_check_box.Value = \
         cpprefs.get_allow_output_file_overwrite()
     def on_allow_checkbox(event):
         cpprefs.set_allow_output_file_overwrite(
             self.__allow_output_filename_overwrite_check_box.Value)
     self.__allow_output_filename_overwrite_check_box.Bind(
         wx.EVT_CHECKBOX, on_allow_checkbox)
     self.__write_measurements_check_box = \
         wx.CheckBox(panel, label = "Write output file?")
     self.__write_measurements_check_box.Value = \
         cpprefs.get_write_MAT_files()
     self.__show_output_filename(cpprefs.get_write_MAT_files())
     def on_write_MAT_files_checkbox(event):
         wants_write = self.__write_measurements_check_box.Value
         cpprefs.set_write_MAT_files(wants_write)
         self.__show_output_filename(wants_write)
         panel.Layout()
         
     self.__write_measurements_check_box.Bind(
         wx.EVT_CHECKBOX, on_write_MAT_files_checkbox)
     output_filename_help_button = wx.Button(panel,-1,'?', (0,0), (30,-1))
     if not cpdistributed.run_distributed():
         self.__analyze_images_button = wx.Button(panel, -1, ANALYZE_IMAGES)
     else:
         self.__analyze_images_button = wx.Button(panel, -1, START_WORK_SERVER)
     self.__stop_analysis_button = wx.Button(panel,-1,'Stop analysis')
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.AddMany([(output_filename_help_button,0,wx.ALIGN_CENTER|wx.ALL,1),
                    (self.__output_filename_text,0,wx.ALIGN_CENTER,1),
                    (self.__output_filename_edit_box,3,wx.ALL,1),
                    (self.__allow_output_filename_overwrite_check_box, 0, wx.ALIGN_CENTER | wx.ALL, 1),
                    (self.__write_measurements_check_box, 0, wx.ALIGN_CENTER | wx.ALL, 1),
                    (self.__analyze_images_button,0,wx.ALL,1),
                    (self.__stop_analysis_button, 0, wx.ALL,1)])
     sizer.Hide(self.__stop_analysis_button)
     panel.SetSizer(sizer)
     panel.Bind(wx.EVT_BUTTON,
                lambda event: self.__on_help(event, OUTPUT_FILENAME_HELP),
                output_filename_help_button)
     panel.Bind(wx.EVT_TEXT, self.__on_output_filename_changed, self.__output_filename_edit_box)
     cpprefs.add_output_file_name_listener(self.__on_preferences_output_filename_event)
     cpprefs.add_image_directory_listener(self.__on_preferences_image_directory_event)
     cpprefs.add_output_directory_listener(self.__on_preferences_output_directory_event)
     cpprefs.add_run_distributed_listener(self.__on_preferences_run_distributed_event)
     panel.Bind(wx.EVT_WINDOW_DESTROY, self.__on_destroy, panel)
Exemplo n.º 3
0
 def __on_preferences_run_distributed_event(self, event):
     self.__analyze_images_button.Label = START_WORK_SERVER if cpdistributed.run_distributed() else ANALYZE_IMAGES
     self.__analyze_images_button.Size = self.__analyze_images_button.BestSize
     self.__odds_and_ends_panel.Layout()
Exemplo n.º 4
0
    def __make_odds_and_ends_panel(self):
        panel = self.__odds_and_ends_panel
        self.__output_filename_text = wx.StaticText(panel,-1,'Output Filename:')
        self.__output_filename_edit_box = wx.TextCtrl(panel, -1, cpprefs.get_output_file_name())
        self.__allow_output_filename_overwrite_check_box = \
            wx.CheckBox(panel, label = "Allow overwrite?")
        self.__allow_output_filename_overwrite_check_box.Value = \
            cpprefs.get_allow_output_file_overwrite()
        def on_allow_checkbox(event):
            cpprefs.set_allow_output_file_overwrite(
                self.__allow_output_filename_overwrite_check_box.Value)
        self.__allow_output_filename_overwrite_check_box.Bind(
            wx.EVT_CHECKBOX, on_allow_checkbox)
        self.__write_measurements_combo_box = \
            wx.Choice(panel, choices = 
                      [WRITE_HDF_FILE, WRITE_MAT_FILE, 
                       DO_NOT_WRITE_MEASUREMENTS])
        def on_write_MAT_files_combo_box(event):
            sel = self.__write_measurements_combo_box.GetStringSelection()
            output_filename = self.__output_filename_edit_box.Value
            if sel == WRITE_HDF_FILE:
                cpprefs.set_write_MAT_files(cpprefs.WRITE_HDF5)
                if output_filename.lower().endswith('.mat'):
                    output_filename = output_filename[:-4] + u".h5"
            elif sel == WRITE_MAT_FILE:
                cpprefs.set_write_MAT_files(True)
                if output_filename.lower().endswith('.h5'):
                    output_filename = output_filename[:-3] + u".mat"
            else:
                cpprefs.set_write_MAT_files(False)
            if output_filename != self.__output_filename_edit_box.Value:
                self.__output_filename_edit_box.Value = output_filename
                cpprefs.set_output_file_name(self.__output_filename_edit_box.Value)
            self.__show_output_filename(sel != DO_NOT_WRITE_MEASUREMENTS)
            panel.Layout()
            panel.Refresh()
        # set measurements mode, then fake an event to update output
        # filename and which controls are shown.
        measurements_mode_idx = [cpprefs.WRITE_HDF5, True, False].index(cpprefs.get_write_MAT_files())
        self.__write_measurements_combo_box.SetSelection(measurements_mode_idx)
        on_write_MAT_files_combo_box(None)

        self.__write_measurements_combo_box.Bind(
            wx.EVT_CHOICE, on_write_MAT_files_combo_box)
        output_filename_help_button = wx.Button(panel,-1,'?', (0,0), (30,-1))
        if not cpdistributed.run_distributed():
            self.__analyze_images_button = wx.Button(panel, -1, ANALYZE_IMAGES)
        else:
            self.__analyze_images_button = wx.Button(panel, -1, START_WORK_SERVER)
        self.__stop_analysis_button = wx.Button(panel,-1,'Stop analysis')
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddMany([(output_filename_help_button,0,wx.ALIGN_CENTER|wx.ALL,1),
                       (self.__output_filename_text,0,wx.ALIGN_CENTER,1),
                       (self.__output_filename_edit_box,5,wx.ALL,1),
                       (self.__allow_output_filename_overwrite_check_box, 0, wx.ALIGN_CENTER | wx.ALL, 1),
                       ((1, 1), 1),
                       (wx.StaticText(panel, label = "Measurements file format:"), 0, wx.ALIGN_CENTER | wx.ALL, 1),
                       (self.__write_measurements_combo_box, 0, wx.ALIGN_CENTER | wx.ALL, 1),
                       (self.__analyze_images_button,0,wx.ALL,1),
                       (self.__stop_analysis_button, 0, wx.ALL,1)])
        sizer.Hide(self.__stop_analysis_button)
        panel.SetSizer(sizer)
        panel.Bind(wx.EVT_BUTTON,
                   lambda event: self.__on_help(event, OUTPUT_FILENAME_HELP),
                   output_filename_help_button)
        panel.Bind(wx.EVT_TEXT, self.__on_output_filename_changed, self.__output_filename_edit_box)
        cpprefs.add_output_file_name_listener(self.__on_preferences_output_filename_event)
        cpprefs.add_image_directory_listener(self.__on_preferences_image_directory_event)
        cpprefs.add_output_directory_listener(self.__on_preferences_output_directory_event)
        cpprefs.add_run_distributed_listener(self.__on_preferences_run_distributed_event)
        panel.Bind(wx.EVT_WINDOW_DESTROY, self.__on_destroy, panel)