Beispiel #1
0
 def OnLinkClicked(self, linkinfo):
     href = linkinfo.Href
     if href.startswith("#"):
         super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
     elif href.startswith('http://'):
         webbrowser.open(href)
     elif href.startswith('pref:'):
         if 'no_display' in href:
             cpprefs.set_startup_blurb(False)
             self.SetPage('')
             self.BackgroundColour = cpprefs.get_background_color()
     elif href.startswith('load:'):
         pipeline_filename = href[5:]
         try:
             wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     elif href.startswith('loadexample:'):
         # Same as "Load", but specific for example pipelines so the user can be directed as to what to do next.
         pipeline_filename = href[12:]
         
         try:
             import cellprofiler.modules.loaddata
             fd = urllib.urlopen(pipeline_filename)
             def fn(fd=fd):
                 pipeline = wx.GetApp().frame.pipeline
                 pipeline.load(fd)
                 for module in pipeline.modules():
                     if isinstance(module, cellprofiler.modules.loaddata.LoadData):
                         # Would prefer to call LoadData's do_reload but not sure how at this point
                         global header_cache
                         header_cache = {}
                         try:
                             module.open_csv()
                         except:
                             pass
                 wx.MessageBox('Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
             wx.CallAfter(fn)             
         #try:
             #wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
             #wx.CallAfter(wx.MessageBox,
                          #'Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     else:
         newpage = content.find_link(href)
         if newpage is not None:
             self.SetPage(newpage)
             self.BackgroundColour = cpprefs.get_background_color()
         else:
             super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
Beispiel #2
0
 def on_paint(self, event):
     dc = wx.BufferedPaintDC(self)
     dc.SetBackground(wx.Brush(cpprefs.get_background_color()))
     dc.Clear()
     self.draw_groove(dc)
     self.draw_ticks(dc)
     self.draw_marker(dc)
     event.Skip()
 def on_paint(self, event):
     dc = wx.BufferedPaintDC(self)
     dc.SetBackground(wx.Brush(cpprefs.get_background_color()))
     dc.Clear()
     self.draw_groove(dc)
     self.draw_ticks(dc)
     self.draw_marker(dc)
     event.Skip()
Beispiel #4
0
 def __init__(self,
              parent,
              id=-1,
              value=0,
              min_value=0,
              max_value=100,
              start_value=0,
              stop_value=100,
              value_names=None,
              pos=wx.DefaultPosition,
              size=wx.DefaultSize,
              style=wx.TAB_TRAVERSAL | wx.NO_BORDER,
              name=MOVIE_SLIDER_NAME_STR):
     """Construct the movie slider
     
     parent      - parent control to the movie slider
     id          - window ID assigned to the top-level window
     value       - initial position of the slider
     min_value   - minimum allowed value for selection
     max_value   - maximum allowed value for selection
     stop_value  - play will continue until the stop
     value_names - sequence of names for each possible value
     pos         - position for control (2-tuple)
     size        - size of control (2-tuple)
     style       - style for panel window
     name        - window's name
     """
     super(MovieSlider, self).__init__(parent, id, pos, size, style, name)
     self.BackgroundColour = cpprefs.get_background_color()
     self.value_names = value_names
     sizer = wx.BoxSizer(wx.VERTICAL)
     self.SetSizer(sizer)
     self.slider = SliderCtl(self,
                             value=value,
                             min_value=min_value,
                             max_value=max_value,
                             start_value=start_value,
                             stop_value=stop_value,
                             value_names=value_names,
                             size=(50, -1),
                             style=wx.SL_VERTICAL | wx.SL_AUTOTICKS)
     sizer.Add(self.slider, 1, wx.EXPAND)
     #controls_sizer = wx.BoxSizer(wx.HORIZONTAL)
     # sizer.Add(controls_sizer,0,wx.ALIGN_CENTER_HORIZONTAL)
     #self.skip_start_button = self.make_bitmap_button(BUTTON_SKIPSTART)
     #controls_sizer.Add(self.skip_start_button,0,wx.SHAPED)
     # self.play_button = self.make_bitmap_button(BUTTON_PLAY)
     #controls_sizer.Add(self.play_button, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
     #self.skip_end_button = self.make_bitmap_button(BUTTON_SKIPEND)
     #controls_sizer.Add(self.skip_end_button,0,wx.SHAPED)
     #self.Bind(wx.EVT_BUTTON, self.on_play_pressed, self.play_button)
     self.Bind(EVT_VALUE_CHANGED, self.on_slider_value_changed, self.slider)
     self.state = STATE_PAUSED
    def __init__(self, parent,
                 id = -1,
                 value = 0,
                 min_value  = 0,
                 max_value  = 100,
                 start_value = 0,
                 stop_value = 100,
                 value_names = None,
                 pos = wx.DefaultPosition,
                 size = wx.DefaultSize,
                 style = wx.TAB_TRAVERSAL|wx.NO_BORDER,
                 name=MOVIE_SLIDER_NAME_STR):
        """Construct the movie slider

        parent      - parent control to the movie slider
        id          - window ID assigned to the top-level window
        value       - initial position of the slider
        min_value   - minimum allowed value for selection
        max_value   - maximum allowed value for selection
        stop_value  - play will continue until the stop
        value_names - sequence of names for each possible value
        pos         - position for control (2-tuple)
        size        - size of control (2-tuple)
        style       - style for panel window
        name        - window's name
        """
        super(MovieSlider,self).__init__(parent, id, pos, size, style, name)
        self.BackgroundColour = cpprefs.get_background_color()
        self.value_names = value_names
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.slider = SliderCtl(self,
                                value = value,
                                min_value = min_value,
                                max_value = max_value,
                                start_value = start_value,
                                stop_value = stop_value,
                                value_names = value_names,
                                size=(50, -1),
                                style=wx.SL_VERTICAL|wx.SL_AUTOTICKS)
        sizer.Add(self.slider,1,wx.EXPAND)
        #controls_sizer = wx.BoxSizer(wx.HORIZONTAL)
        # sizer.Add(controls_sizer,0,wx.ALIGN_CENTER_HORIZONTAL)
        #self.skip_start_button = self.make_bitmap_button(BUTTON_SKIPSTART)
        #controls_sizer.Add(self.skip_start_button,0,wx.SHAPED)
        # self.play_button = self.make_bitmap_button(BUTTON_PLAY)
        #controls_sizer.Add(self.play_button, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
        #self.skip_end_button = self.make_bitmap_button(BUTTON_SKIPEND)
        #controls_sizer.Add(self.skip_end_button,0,wx.SHAPED)
        #self.Bind(wx.EVT_BUTTON, self.on_play_pressed, self.play_button)
        self.Bind(EVT_VALUE_CHANGED, self.on_slider_value_changed, self.slider)
        self.state = STATE_PAUSED
Beispiel #6
0
 def OnLinkClicked(self, linkinfo):
     href = linkinfo.Href
     if href.startswith("#"):
         super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
     elif href.startswith('http://'):
         webbrowser.open(href)
     elif href.startswith('pref:'):
         if 'no_display' in href:
             cpprefs.set_startup_blurb(False)
             self.SetPage('')
             self.BackgroundColour = cpprefs.get_background_color()
     elif href.startswith('load:'):
         pipeline_filename = href[5:]
         try:
             wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     elif href.startswith('loadexample:'):
         # Same as "Load", but specific for example pipelines so the user can be directed as to what to do next.
         pipeline_filename = href[12:]
         try:
             wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
             wx.CallAfter(wx.MessageBox,
                          'Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     else:
         newpage = content.find_link(href)
         if newpage is not None:
             self.SetPage(newpage)
             self.BackgroundColour = cpprefs.get_background_color()
         else:
             super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
Beispiel #7
0
def on_sashwindow_paint(event):
    assert isinstance(event, wx.PaintEvent)
    window = event.EventObject
    assert isinstance(window, wx.SashWindow)
    dc = wx.PaintDC(window)
    dc.BeginDrawing()
    dc.Background = wx.Brush(get_background_color())
    dc.Clear()
    art = PyAuiDockArt()
    w, h = window.GetClientSizeTuple()
    for edge, orientation in (
        (wx.SASH_LEFT, wx.VERTICAL),
        (wx.SASH_TOP, wx.HORIZONTAL),
        (wx.SASH_RIGHT, wx.VERTICAL),
        (wx.SASH_BOTTOM, wx.HORIZONTAL)):
        if window.GetSashVisible(edge):
            margin = window.GetEdgeMargin(edge)
            pane_info = wx.aui.AuiPaneInfo()
            pane_info.Gripper(True)
            if orientation == wx.VERTICAL:
                sy = 0
                sh = h
                sw = margin
                gw = GRIPPER_HEIGHT
                gh = GRIPPER_SIZE
                gy = (h - GRIPPER_SIZE) / 2
                pane_info.GripperTop(False)
                if edge == wx.SASH_LEFT:
                    gx = sx = 0
                else:
                    sx = w - margin
                    gx = w - gw
            else:
                sx = 0
                sw = w
                sh = margin
                gw = GRIPPER_SIZE
                gh = GRIPPER_HEIGHT
                gx = (w - GRIPPER_SIZE) / 2
                pane_info.GripperTop(True)
                if edge == wx.SASH_TOP:
                    gy = sy = 0
                else:
                    sy = h - margin
                    gy = h - gh
            art.DrawSash(dc, window, orientation, wx.Rect(sx, sy, sw, sh))
            art.DrawGripper(dc, window, wx.Rect(gx, gy, gw, gh), pane_info)
    dc.EndDrawing()
Beispiel #8
0
def on_splitter_paint(event):
    assert isinstance(event, wx.PaintEvent)
    window = event.EventObject
    assert isinstance(window, wx.SplitterWindow)
    dc = wx.PaintDC(window)
    dc.BeginDrawing()
    dc.Background = wx.Brush(get_background_color())
    dc.Clear()
    art = PyAuiDockArt()
    pane_info = wx.aui.AuiPaneInfo()
    pane_info.Gripper(True)
    w, h = window.GetClientSizeTuple()
    margin = window.GetSashSize()
    pos = window.GetSashPosition()
    if window.GetSplitMode() == wx.SPLIT_VERTICAL:
        pane_info.GripperTop(False)
        sy = 0
        sh = h
        sw = margin
        gw = GRIPPER_HEIGHT
        sx = pos - margin/2
        gx = pos - gw / 2
        gy = (h - GRIPPER_SIZE) / 2
        gh = GRIPPER_SIZE
        orientation = wx.VERTICAL
    else:
        pane_info.GripperTop(True)
        sx = 0
        sw = h
        sh = margin
        gh = GRIPPER_HEIGHT
        sy = pos - margin / 2
        gx = (w - GRIPPER_SIZE) / 2
        gy = pos - GRIPPER_SIZE / 2
        gw = GRIPPER_SIZE
        orientation = wx.HORIZONTAL
    art.DrawSash(dc, window, orientation, wx.Rect(sx, sy, sw, sh))
    art.DrawGripper(dc, window, wx.Rect(gx, gy, gw, gh), pane_info)
    
Beispiel #9
0
    def OnLinkClicked(self, linkinfo):
        href = linkinfo.Href
        if href.startswith("#"):
            super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
        elif href.startswith('http://'):
            webbrowser.open(href)
        elif href.startswith('pref:'):
            if 'no_display' in href:
                cpprefs.set_startup_blurb(False)
                self.SetPage('')
                self.BackgroundColour = cpprefs.get_background_color()
        elif href.startswith('load:'):
            pipeline_filename = href[5:]
            try:
                wx.CallAfter(wx.GetApp().frame.pipeline.load,
                             urllib2.urlopen(pipeline_filename))
            except:
                wx.MessageBox('CellProfiler was unable to load %s' %
                              pipeline_filename,
                              "Error loading pipeline",
                              style=wx.OK | wx.ICON_ERROR)
        elif href.startswith('loadexample:'):
            # Same as "Load", but specific for example pipelines so the user can be directed as to what to do next.
            pipeline_filename = href[12:]

            try:
                import cellprofiler.modules.loaddata
                fd = urllib.urlopen(pipeline_filename)

                def fn(fd=fd):
                    pipeline = wx.GetApp().frame.pipeline
                    pipeline.load(fd)
                    for module in pipeline.modules():
                        if isinstance(module,
                                      cellprofiler.modules.loaddata.LoadData):
                            # Would prefer to call LoadData's do_reload but not sure how at this point
                            global header_cache
                            header_cache = {}
                            try:
                                module.open_csv()
                            except:
                                pass
                    wx.MessageBox(
                        'Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.',
                        '', wx.ICON_INFORMATION)

                wx.CallAfter(fn)
            #try:
            #wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
            #wx.CallAfter(wx.MessageBox,
            #'Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
            except:
                wx.MessageBox('CellProfiler was unable to load %s' %
                              pipeline_filename,
                              "Error loading pipeline",
                              style=wx.OK | wx.ICON_ERROR)
        else:
            newpage = content.find_link(href)
            if newpage is not None:
                self.SetPage(newpage)
                self.BackgroundColour = cpprefs.get_background_color()
            else:
                super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     wx.html.HtmlWindow.__init__(self, *args, **kwargs)
     self.HTMLBackgroundColour = cpprefs.get_background_color()
Beispiel #11
0
    def __init__(self, *args, **kwds):
        '''Instantiate a data tool frame
        
        module_name: name of module to instantiate
        measurements_file_name: name of measurements file
        '''
        assert kwds.has_key("module_name"), "DataToolFrame() needs a module_name argument"
        assert kwds.has_key("measurements_file_name"), "DataToolFrame() needs a measurements_file_name argument"
        module_name = kwds["module_name"]
        measurements_file_name = kwds["measurements_file_name"]

        kwds_copy = kwds.copy()
        del kwds_copy["module_name"]
        del kwds_copy["measurements_file_name"]
        kwds_copy["title"]="%s data tool"%module_name
        wx.Frame.__init__(self, *args, **kwds_copy)
        self.module = instantiate_module(module_name)
        self.pipeline = cpp.Pipeline()
        if h5py.is_hdf5(measurements_file_name):
            self.workspace = cpw.Workspace(self.pipeline, self.module, None, None, None,
                                           None)
            self.workspace.load(measurements_file_name, True)
            self.measurements = self.workspace.measurements
        else:
            self.pipeline.load(measurements_file_name)
            self.load_measurements(measurements_file_name)
            self.workspace = cpw.Workspace(self.pipeline, self.module, None, None,
                                           self.measurements, None)
        
        self.module.module_num = len(self.pipeline.modules())+1
        self.pipeline.add_module(self.module)

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        module_panel = wx.lib.scrolledpanel.ScrolledPanel(self,-1,style=wx.SUNKEN_BORDER)
        module_panel.BackgroundColour = cpprefs.get_background_color()
        self.BackgroundColour = cpprefs.get_background_color()

        self.module_view = ModuleView(module_panel, self.workspace, True)
        self.module_view.set_selection(self.module.module_num)
        def on_change(caller, event):
            setting = event.get_setting()
            proposed_value = event.get_proposed_value()
            setting.value = proposed_value
            self.pipeline.edit_module(event.get_module().module_num, False)
            self.module_view.reset_view()
        self.module_view.add_listener(on_change)

        #
        # Add a panel for the "run" button
        #
        panel = wx.Panel(self)
        panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button = wx.Button(panel, label = "Run")

        self.sizer.Add(module_panel, 1, wx.EXPAND)
        self.sizer.Add(panel, 0, wx.EXPAND)

        panel_sizer.AddStretchSpacer()
        panel_sizer.Add(button, 0, wx.RIGHT, button.Size[1])
        panel.SetSizer(panel_sizer)

        wx.EVT_BUTTON(self, button.Id, self.on_run)
        #
        # Add a file menu
        #
        file_menu = wx.Menu()
        file_menu.Append(ID_FILE_LOAD_MEASUREMENTS, "&Load measurements")
        file_menu.Append(ID_FILE_SAVE_MEASUREMENTS, "&Save measurements")
        file_menu.Append(ID_FILE_EXIT, "E&xit")
        self.MenuBar = wx.MenuBar()
        self.MenuBar.Append(file_menu, "&File")
        self.Bind(wx.EVT_MENU, self.on_load_measurements, id=ID_FILE_LOAD_MEASUREMENTS)
        self.Bind(wx.EVT_MENU, self.on_save_measurements, id=ID_FILE_SAVE_MEASUREMENTS)
        self.Bind(wx.EVT_MENU, self.on_exit, id=ID_FILE_EXIT)
        accelerators = wx.AcceleratorTable([
            (wx.ACCEL_CMD, ord("W"), ID_FILE_EXIT),
            (wx.ACCEL_CMD, ord("O"), ID_FILE_LOAD_MEASUREMENTS),
            (wx.ACCEL_CMD, ord("S"), ID_FILE_SAVE_MEASUREMENTS)])
        self.SetAcceleratorTable(accelerators)
        #
        # Add an image menu
        #
        image_menu = wx.Menu()
        image_menu.Append(ID_IMAGE_CHOOSE, "&Choose")
        self.MenuBar.Append(image_menu, "&Image")
        self.Bind(wx.EVT_MENU, self.on_image_choose, id=ID_IMAGE_CHOOSE)
        
        self.SetSizer(self.sizer)
        self.Size = (self.module_view.get_max_width(), self.Size[1])
        module_panel.Layout()
        self.Show()
        self.tbicon = wx.TaskBarIcon()
        self.tbicon.SetIcon(get_cp_icon(), "CellProfiler2.0")
        self.SetIcon(get_cp_icon())
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     wx.html.HtmlWindow.__init__(self, *args, **kwargs)
     self.HTMLBackgroundColour = cpprefs.get_background_color()
Beispiel #13
0
    def __init__(self, *args, **kwds):
        '''Instantiate a data tool frame
        
        module_name: name of module to instantiate
        measurements_file_name: name of measurements file
        '''
        assert kwds.has_key(
            "module_name"), "DataToolFrame() needs a module_name argument"
        assert kwds.has_key(
            "measurements_file_name"
        ), "DataToolFrame() needs a measurements_file_name argument"
        module_name = kwds["module_name"]
        measurements_file_name = kwds["measurements_file_name"]

        kwds_copy = kwds.copy()
        del kwds_copy["module_name"]
        del kwds_copy["measurements_file_name"]
        kwds_copy["title"] = "%s data tool" % module_name
        wx.Frame.__init__(self, *args, **kwds_copy)
        self.module = instantiate_module(module_name)
        self.module.use_as_data_tool = True
        self.pipeline = cpp.Pipeline()
        if h5py.is_hdf5(measurements_file_name):
            self.workspace = cpw.Workspace(self.pipeline, self.module, None,
                                           None, None, None)
            self.workspace.load(measurements_file_name, True)
            self.measurements = self.workspace.measurements
        else:
            self.pipeline.load(measurements_file_name)
            self.load_measurements(measurements_file_name)
            self.workspace = cpw.Workspace(self.pipeline, self.module, None,
                                           None, self.measurements, None)

        self.module.module_num = len(self.pipeline.modules()) + 1
        self.pipeline.add_module(self.module)

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        module_panel = wx.lib.scrolledpanel.ScrolledPanel(
            self, -1, style=wx.SUNKEN_BORDER)
        module_panel.BackgroundColour = cpprefs.get_background_color()
        self.BackgroundColour = cpprefs.get_background_color()

        self.module_view = ModuleView(module_panel, self.workspace, True)
        self.module_view.set_selection(self.module.module_num)

        def on_change(caller, event):
            setting = event.get_setting()
            proposed_value = event.get_proposed_value()
            setting.value = proposed_value
            self.pipeline.edit_module(event.get_module().module_num, False)
            self.module_view.reset_view()
            self.module_view.request_validation()

        self.module_view.add_listener(on_change)

        #
        # Add a panel for the "run" button
        #
        panel = wx.Panel(self)
        panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button = wx.Button(panel, label="Run")

        self.sizer.Add(module_panel, 1, wx.EXPAND)
        self.sizer.Add(panel, 0, wx.EXPAND)

        panel_sizer.AddStretchSpacer()
        panel_sizer.Add(button, 0, wx.RIGHT, button.Size[1])
        panel.SetSizer(panel_sizer)

        wx.EVT_BUTTON(self, button.Id, self.on_run)
        #
        # Add a file menu
        #
        file_menu = wx.Menu()
        file_menu.Append(ID_FILE_LOAD_MEASUREMENTS, "&Load measurements")
        file_menu.Append(ID_FILE_SAVE_MEASUREMENTS, "&Save measurements")
        file_menu.Append(ID_FILE_EXIT, "E&xit")
        self.MenuBar = wx.MenuBar()
        self.MenuBar.Append(file_menu, "&File")
        self.Bind(wx.EVT_MENU,
                  self.on_load_measurements,
                  id=ID_FILE_LOAD_MEASUREMENTS)
        self.Bind(wx.EVT_MENU,
                  self.on_save_measurements,
                  id=ID_FILE_SAVE_MEASUREMENTS)
        self.Bind(wx.EVT_MENU, self.on_exit, id=ID_FILE_EXIT)
        accelerators = wx.AcceleratorTable([
            (wx.ACCEL_CMD, ord("W"), ID_FILE_EXIT),
            (wx.ACCEL_CMD, ord("O"), ID_FILE_LOAD_MEASUREMENTS),
            (wx.ACCEL_CMD, ord("S"), ID_FILE_SAVE_MEASUREMENTS)
        ])
        self.SetAcceleratorTable(accelerators)
        #
        # Add an image menu
        #
        image_menu = wx.Menu()
        image_menu.Append(ID_IMAGE_CHOOSE, "&Choose")
        self.MenuBar.Append(image_menu, "&Image")
        self.Bind(wx.EVT_MENU, self.on_image_choose, id=ID_IMAGE_CHOOSE)

        self.SetSizer(self.sizer)
        self.Size = (self.module_view.get_max_width(), self.Size[1])
        module_panel.Layout()
        self.Show()
        self.tbicon = wx.TaskBarIcon()
        self.tbicon.SetIcon(get_cp_icon(), "CellProfiler2.0")
        self.SetIcon(get_cp_icon())
Beispiel #14
0
 def OnLinkClicked(self, linkinfo):
     href = linkinfo.Href
     if href.startswith("#"):
         super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
     elif href.startswith('http://'):
         webbrowser.open(href)
     elif href.startswith('pref:'):
         if 'no_display' in href:
             cpprefs.set_startup_blurb(False)
             # Find the parent frame and, if it's the welcome screen frame,
             # "close" it (= hide it)
             #
             parent = self.Parent
             while parent is not None:
                 if parent.Name == WELCOME_SCREEN_FRAME:
                     parent.Close()
                     break
                 parent = parent.Parent
     elif href.startswith('help:'):
         href = linkinfo.Href[7:]
         html_str = WELCOME_HELP[href]
         html_str += '<p>Go <a href="startup_main">back</a> to the welcome screen.</p>'
         self.SetPage(html_str)
         self.BackgroundColour = cpprefs.get_background_color()
     elif href.startswith('load:'):
         pipeline_filename = href[5:]
         try:
             fd = urllib2.urlopen(pipeline_filename)
             if fd.code < 200 or fd.code > 299:
                 wx.MessageBox(
                 "Sorry, the link, \"%s\" is broken, please contact the webmaster" % 
                 pipeline_filename,
                 caption = "Unable to access pipeline via internet",
                 style = wx.OK | wx.ICON_INFORMATION)
                 return
             wx.CallAfter(wx.GetApp().frame.pipeline.load, fd)
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     elif href.startswith('loadexample:'):
         # Same as "Load", but specific for example pipelines so the user can be directed as to what to do next.
         pipeline_filename = href[12:]
         
         try:
             import cellprofiler.modules.loaddata
             fd = urllib.urlopen(pipeline_filename)
             if fd.code < 200 or fd.code > 299:
                 wx.MessageBox(
                 "Sorry, the link, \"%s\" is broken, please contact the webmaster" % 
                 pipeline_filename,
                 caption = "Unable to access pipeline via internet",
                 style = wx.OK | wx.ICON_INFORMATION)
                 return
             def fn(fd=fd):
                 pipeline = wx.GetApp().frame.pipeline
                 pipeline.load(fd)
                 for module in pipeline.modules():
                     if isinstance(module, cellprofiler.modules.loaddata.LoadData):
                         # Would prefer to call LoadData's do_reload but not sure how at this point
                         global header_cache
                         header_cache = {}
                         try:
                             module.open_csv()
                         except:
                             pass
                 wx.MessageBox('Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
             wx.CallAfter(fn)             
         #try:
             #wx.CallAfter(wx.GetApp().frame.pipeline.load, urllib2.urlopen(pipeline_filename))
             #wx.CallAfter(wx.MessageBox,
                          #'Now that you have loaded an example pipeline, press the "Analyze images" button to access and process a small image set from the CellProfiler website so you can see how CellProfiler works.', '', wx.ICON_INFORMATION)
         except:
             wx.MessageBox(
                 'CellProfiler was unable to load %s' %
                 pipeline_filename, "Error loading pipeline",
                 style = wx.OK | wx.ICON_ERROR)
     else:
         newpage = content.find_link(href)
         if newpage is not None:
             self.SetPage(newpage)
             self.BackgroundColour = cpprefs.get_background_color()
         else:
             super(HtmlClickableWindow, self).OnLinkClicked(linkinfo)
Beispiel #15
0
    def run(self, workspace):
        """Run the module
        
        workspace    - The workspace contains
            pipeline     - instance of cpp for this run
            image_set    - the images in the image set being processed
            object_set   - the objects (labeled masks) in this image set
            measurements - the measurements for this run
            frame        - the parent frame to whatever frame is created. None means don't draw.
        """
        if workspace.pipeline.in_batch_mode():
            return

        if self.action != cpw.DISPOSITION_CONTINUE:
            #
            # Tell the pipeline to pause after we return
            #
            workspace.disposition = cpw.DISPOSITION_PAUSE
            #
            # Make a frame to hold the resume button
            #
            frame = wx.Frame(None, title="Pause CellProfiler")
            frame.BackgroundColour = cpprefs.get_background_color()

            #
            # Register to hear about the run ending so we can clean up
            #
            def on_pipeline_event(caller, event):
                if isinstance(event, cpp.EndRunEvent):
                    frame.Close()

            workspace.pipeline.add_listener(on_pipeline_event)

            #
            # Make sure we stop listening when the window closes
            #
            def on_close(event):
                if workspace.disposition == cpw.DISPOSITION_PAUSE:
                    workspace.disposition = self.action.value
                workspace.pipeline.remove_listener(on_pipeline_event)
                frame.Destroy()

            frame.Bind(wx.EVT_CLOSE, on_close)
            #
            # Make the UI:
            super_sizer = wx.BoxSizer(wx.VERTICAL)
            frame.SetSizer(super_sizer)
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            super_sizer.Add(sizer, 0, wx.EXPAND)
            sizer.Add(
                wx.StaticBitmap(
                    frame, -1,
                    wx.ArtProvider.GetBitmap(wx.ART_INFORMATION,
                                             wx.ART_MESSAGE_BOX)), 0,
                wx.EXPAND | wx.ALL, 5)
            sizer.Add(
                wx.StaticText(
                    frame, -1,
                    """Press "Resume" to continue processing.\nPress "Cancel" to stop."""
                ), 0, wx.EXPAND | wx.ALL, 5)
            super_sizer.Add(wx.StaticLine(frame), 0,
                            wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
            sizer = wx.StdDialogButtonSizer()
            super_sizer.Add(sizer, 0, wx.EXPAND)
            resume_id = 100
            cancel_id = 101
            resume_button = wx.Button(frame, resume_id, "Resume")
            sizer.AddButton(resume_button)
            sizer.SetAffirmativeButton(resume_button)
            cancel_button = wx.Button(frame, cancel_id, "Cancel")
            sizer.AddButton(cancel_button)
            sizer.SetNegativeButton(cancel_button)
            sizer.Realize()
            frame.Fit()

            def on_resume(event):
                if self.action == cpw.DISPOSITION_PAUSE:
                    workspace.disposition = cpw.DISPOSITION_CONTINUE
                else:
                    workspace.disposition = self.action.value
                frame.Close()

            def on_cancel(event):
                workspace.disposition = cpw.DISPOSITION_CANCEL
                frame.Close()

            frame.Bind(wx.EVT_BUTTON, on_resume, id=resume_id)
            frame.Bind(wx.EVT_BUTTON, on_cancel, id=cancel_id)
            frame.Show()
 def run(self, workspace):
     """Run the module
     
     workspace    - The workspace contains
         pipeline     - instance of cpp for this run
         image_set    - the images in the image set being processed
         object_set   - the objects (labeled masks) in this image set
         measurements - the measurements for this run
         frame        - the parent frame to whatever frame is created. None means don't draw.
     """
     if workspace.pipeline.in_batch_mode():
         return
     
     if self.action != cpw.DISPOSITION_CONTINUE:
         #
         # Tell the pipeline to pause after we return
         #
         workspace.disposition = cpw.DISPOSITION_PAUSE
         #
         # Make a frame to hold the resume button
         #
         frame = wx.Frame(None,title="Pause CellProfiler")
         frame.BackgroundColour = cpprefs.get_background_color()
         #
         # Register to hear about the run ending so we can clean up
         #
         def on_pipeline_event(caller, event):
             if isinstance(event, cpp.EndRunEvent):
                 frame.Close()
         workspace.pipeline.add_listener(on_pipeline_event)
         #
         # Make sure we stop listening when the window closes
         #
         def on_close(event):
             if workspace.disposition == cpw.DISPOSITION_PAUSE:
                 workspace.disposition = self.action.value
             workspace.pipeline.remove_listener(on_pipeline_event)
             frame.Destroy()
         frame.Bind(wx.EVT_CLOSE, on_close)
         #
         # Make the UI:
         super_sizer = wx.BoxSizer(wx.VERTICAL)
         frame.SetSizer(super_sizer)
         sizer = wx.BoxSizer(wx.HORIZONTAL)
         super_sizer.Add(sizer, 0, wx.EXPAND)
         sizer.Add(wx.StaticBitmap(frame, -1, 
                                   wx.ArtProvider.GetBitmap(wx.ART_INFORMATION,
                                                            wx.ART_MESSAGE_BOX)),
                   0, wx.EXPAND | wx.ALL, 5)
         sizer.Add(wx.StaticText(frame,-1, """Press "Resume" to continue processing.\nPress "Cancel" to stop."""),
                   0, wx.EXPAND | wx.ALL, 5)
         super_sizer.Add(wx.StaticLine(frame), 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
         sizer = wx.StdDialogButtonSizer()
         super_sizer.Add(sizer, 0, wx.EXPAND)
         resume_id = 100
         cancel_id = 101
         resume_button = wx.Button(frame, resume_id, "Resume")
         sizer.AddButton(resume_button)
         sizer.SetAffirmativeButton(resume_button)
         cancel_button = wx.Button(frame, cancel_id, "Cancel")
         sizer.AddButton(cancel_button)
         sizer.SetNegativeButton(cancel_button)
         sizer.Realize()
         frame.Fit()
         
         def on_resume(event):
             if self.action == cpw.DISPOSITION_PAUSE:
                 workspace.disposition = cpw.DISPOSITION_CONTINUE
             else:
                 workspace.disposition = self.action.value
             frame.Close()
         
         def on_cancel(event):
             workspace.disposition = cpw.DISPOSITION_CANCEL
             frame.Close()
         
         frame.Bind(wx.EVT_BUTTON, on_resume, id=resume_id)
         frame.Bind(wx.EVT_BUTTON, on_cancel, id=cancel_id)
         frame.Show()