Exemple #1
0
class ManualBeamTiltWobbleDialog(ManualFocusDialog):
        def moreOnInit(self):
                self.beamtilt = True
                self.settingsdialog = ManualBeamTiltWobbleSettingsDialog(self, 'Manual Beam Tilt Wobble Settings', 'Settings')

        def moreToolbar(self):
                bitmap = leginon.gui.wx.Icons.icon('beamtiltget')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_GET_BEAMTILT, bitmap, shortHelpString='Rotation Center From Scope')
                bitmap = leginon.gui.wx.Icons.icon('beamtiltset')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_SET_BEAMTILT, bitmap, shortHelpString='Rotation Center To Scope')

                self.toolbar.Bind(wx.EVT_TOOL, self.onRotationCenterFromScope, id=leginon.gui.wx.ToolBar.ID_GET_BEAMTILT)
                self.toolbar.Bind(wx.EVT_TOOL, self.onRotationCenterToScope, id=leginon.gui.wx.ToolBar.ID_SET_BEAMTILT)

        def initParameterChoice(self):
                self.parameter_choice = Choice(self.toolbar, -1, choices=['Beam Tilt X','Beam Tilt Y','Defocus', 'Stage Z'])
                par = 'Beam Tilt X'
                self.parameter_choice.SetStringSelection(par)
                threading.Thread(target=self.node.setParameterChoice, args=(par,)).start()

        def onSettingsTool(self, evt):
                self.settingsdialog.maskradius.SetValue(self.node.maskradius)
                self.settingsdialog.increment.SetValue(self.node.increment)
                self.settingsdialog.tiltdelta.SetValue(self.node.tiltdelta)
                #self.MakeModal(False)
                if self.settingsdialog.ShowModal() == wx.ID_OK:
                        self.node.maskradius = self.settingsdialog.maskradius.GetValue()
                        self.node.increment = self.settingsdialog.increment.GetValue()
                        self.node.increment = self.settingsdialog.increment.GetValue()
                        self.node.tiltdelta = self.settingsdialog.tiltdelta.GetValue()
                #self.MakeModal(True)

        def onRotationCenterToScope(self, evt):
                self._manualEnable(False)
                threading.Thread(target=self.node.rotationCenterToScope).start()

        def onRotationCenterFromScope(self, evt):
                self._manualEnable(False)
                threading.Thread(target=self.node.rotationCenterFromScope).start()
Exemple #2
0
class ManualFocusDialog(wx.Frame):
        def __init__(self, parent, node, title='Manual Focus'):
                wx.Frame.__init__(self, parent, -1, title, size=(650,600),
                        style=wx.DEFAULT_FRAME_STYLE|wx.RESIZE_BORDER)
                self.node = node
                self.center = (256,256)
                self.toolbar = wx.ToolBar(self, -1)

                bitmap = leginon.gui.wx.Icons.icon('settings')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_SETTINGS, bitmap, shortHelpString='Settings')

                self.toolbar.AddSeparator()

                bitmap = leginon.gui.wx.Icons.icon('play')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_PLAY, bitmap, shortHelpString='Play')
                bitmap = leginon.gui.wx.Icons.icon('pause')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_PAUSE, bitmap, shortHelpString='Pause')
                bitmap = leginon.gui.wx.Icons.icon('stop')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_STOP, bitmap, shortHelpString='Stop')

                self.toolbar.AddSeparator()

                self.initParameterChoice()
                self.toolbar.AddControl(self.parameter_choice)
                bitmap = leginon.gui.wx.Icons.icon('plus')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_PLUS, bitmap,
                        shortHelpString='Increment up')
                bitmap = leginon.gui.wx.Icons.icon('minus')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_MINUS, bitmap,
                        shortHelpString='Increment down')

                self.toolbar.AddSeparator()

                self.value = FloatEntry(self.toolbar, -1, allownone=False, chars=6, value='0.0')
                self.toolbar.AddControl(self.value)
                # size is defined because some wxPython installation lack good wxDefaultSize
                self.toolbar.AddControl(wx.StaticText(self.toolbar, -1, ' m',size=(20,20)))
                bitmap = leginon.gui.wx.Icons.icon('instrumentset')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_VALUE, bitmap,
                        shortHelpString='Set instrument')

                self.toolbar.AddSeparator()

                bitmap = leginon.gui.wx.Icons.icon('instrumentsetnew')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_RESET, bitmap,
                        shortHelpString='Reset Defocus')

                self.toolbar.AddSeparator()

                bitmap = leginon.gui.wx.Icons.icon('instrumentget')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_GET_INSTRUMENT, bitmap,
                        shortHelpString='Eucentric from instrument')

                bitmap = leginon.gui.wx.Icons.icon('instrumentset')
                self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_SET_INSTRUMENT, bitmap,
                        shortHelpString='Eucentric to instrument')

                self.moreToolbar()

                self.SetToolBar(self.toolbar)
                self.toolbar.Realize()

                self.imagepanel = leginon.gui.wx.TargetPanel.FFTTargetImagePanel(self, -1,imagesize=(512,512))

                self.imagepanel.addTypeTool('Image', display=True)
                self.imagepanel.addTypeTool('Power', display=True)
                self.imagepanel.selectiontool.setDisplayed('Power', True)

                self.statusbar = wx.StatusBar(self, -1)
                self.SetStatusBar(self.statusbar)

                self.Fit()
                #self.SetAutoLayout(True)

                self.settingsdialog = ManualFocusSettingsDialog(self, 'Manual Focus Settings', 'Settings')

                self.Bind(leginon.gui.wx.Events.EVT_PLAYER, self.onPlayer)
                self.Bind(wx.EVT_TOOL, self.onSettingsTool, id=leginon.gui.wx.ToolBar.ID_SETTINGS)
                self.Bind(wx.EVT_TOOL, self.onPlayTool, id=leginon.gui.wx.ToolBar.ID_PLAY)
                self.Bind(wx.EVT_TOOL, self.onPauseTool, id=leginon.gui.wx.ToolBar.ID_PAUSE)
                self.Bind(wx.EVT_TOOL, self.onStopTool, id=leginon.gui.wx.ToolBar.ID_STOP)
                self.Bind(wx.EVT_TOOL, self.onPlusTool, id=leginon.gui.wx.ToolBar.ID_PLUS)
                self.Bind(wx.EVT_TOOL, self.onMinusTool, id=leginon.gui.wx.ToolBar.ID_MINUS)
                self.Bind(wx.EVT_TOOL, self.onValueTool, id=leginon.gui.wx.ToolBar.ID_VALUE)
                self.Bind(wx.EVT_TOOL, self.onResetTool, id=leginon.gui.wx.ToolBar.ID_RESET)
                self.Bind(wx.EVT_TOOL, self.onGetInstrumentTool, id=leginon.gui.wx.ToolBar.ID_GET_INSTRUMENT)
                self.Bind(wx.EVT_TOOL, self.onSetInstrumentTool, id=leginon.gui.wx.ToolBar.ID_SET_INSTRUMENT)
                self.Bind(wx.EVT_CLOSE, self.onClose)
                self.Bind(leginon.gui.wx.Events.EVT_SET_IMAGE, self.onSetImage)
                self.Bind(leginon.gui.wx.Events.EVT_MANUAL_UPDATED, self.onManualUpdated)
                self.Bind(leginon.gui.wx.ImagePanelTools.EVT_SHAPE_FOUND, self.onShapeFound, self.imagepanel)
                self.Bind(leginon.gui.wx.ImagePanelTools.EVT_IMAGE_CLICKED, self.onImageClicked,
                                                        self.imagepanel)
                self.parameter_choice.Bind(wx.EVT_CHOICE, self.onParameterChoice)
                self.moreOnInit()

        def moreToolbar(self):
                pass

        def moreOnInit(self):
                self.beamtilt = False
                pass

        def initParameterChoice(self):
                self.parameter_choice = Choice(self.toolbar, -1, choices=['Defocus', 'Stage Z'])
                par = 'Defocus'
                self.parameter_choice.SetStringSelection(par)
                threading.Thread(target=self.node.setParameterChoice, args=(par,)).start()

        def onParameterChoice(self,evt):
                par = self.parameter_choice.GetStringSelection()
                threading.Thread(target=self.node.setParameterChoice, args=(par,)).start()

        def onSettingsTool(self, evt):
                self.settingsdialog.maskradius.SetValue(self.node.maskradius)
                self.settingsdialog.increment.SetValue(self.node.increment)
                print 'set increment to ',self.node.increment
                #self.MakeModal(False)
                if self.settingsdialog.ShowModal() == wx.ID_OK:
                        self.node.maskradius = self.settingsdialog.maskradius.GetValue()
                        self.node.increment = self.settingsdialog.increment.GetValue()
                        self.node.increment = self.settingsdialog.increment.GetValue()
                #self.MakeModal(True)

        def onPlayTool(self, evt):
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, False)
                self.node.manualplayer.play()

        def onPauseTool(self, evt):
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, False)
                self.node.manualplayer.pause()

        def onStopTool(self, evt):
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, False)
                self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, False)
                self.node.manualplayer.stop()

        def onPlayer(self, evt):
                if evt.state == 'play':
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, False)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, True)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, True)
                elif evt.state == 'pause':
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, True)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, False)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, True)
                elif evt.state == 'stop':
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PLAY, True)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_PAUSE, True)
                        self.toolbar.EnableTool(leginon.gui.wx.ToolBar.ID_STOP, False)

        def _manualEnable(self, enable):
                self.toolbar.Enable(enable)

        def onManualUpdated(self, evt):
                self._manualEnable(True)

        def manualUpdated(self):
                evt = leginon.gui.wx.Events.ManualUpdatedEvent()
                self.GetEventHandler().AddPendingEvent(evt)

        def onPlusTool(self, evt):
                self._manualEnable(False)
                par = self.parameter_choice.GetStringSelection()
                threading.Thread(target=self.node.onFocusUp, args=(par,)).start()

        def onMinusTool(self, evt):
                self._manualEnable(False)
                par = self.parameter_choice.GetStringSelection()
                threading.Thread(target=self.node.onFocusDown, args=(par,)).start()

        def onValueTool(self, evt):
                self._manualEnable(False)
                value = self.value.GetValue()
                threading.Thread(target=self.node.setFocus, args=(value,)).start()

        def onResetTool(self, evt):
                self._manualEnable(False)
                threading.Thread(target=self.node.onResetDefocus).start()

        def onGetInstrumentTool(self, evt):
                self._manualEnable(False)
                threading.Thread(target=self.node.onEucentricFromScope).start()

        def onSetInstrumentTool(self, evt):
                self._manualEnable(False)
                threading.Thread(target=self.node.onChangeToEucentric).start()

        def onClose(self, evt):
                self.node.manualplayer.stop()

        def onSetImage(self, evt):
                self.imagepanel.setImageType(evt.typename, evt.image)

        def onNewPixelSize(self, pixelsize,center,hightension):
                idcevt = leginon.gui.wx.ImagePanelTools.ImageNewPixelSizeEvent(self.imagepanel, pixelsize,center,hightension)
                self.imagepanel.GetEventHandler().AddPendingEvent(idcevt)
                self.center = center
                self.pixelsize = pixelsize
                self.hightension = hightension

        def onShapeFound(self, evt):
                centers = [(self.center['y'],self.center['x']),]
                idcevt = leginon.gui.wx.ImagePanelTools.ShapeNewCenterEvent(self.imagepanel, centers)
                self.imagepanel.GetEventHandler().AddPendingEvent(idcevt)
                threading.Thread(target=self.node.estimateAstigmation, args=(evt.params,)).start()

        def onImageClicked(self, evt):
                if not self.imagepanel.selectiontool.isDisplayed('Power'):
                        return
                resolution = 1/math.sqrt(((evt.xy[0]-self.center['x'])*self.pixelsize['x'])**2+((evt.xy[1]-self.center['y'])*self.pixelsize['y'])**2)
                defocus = fftfun.calculateDefocus(self.hightension,1/resolution)
                self.node.increment = defocus
                self.settingsdialog.increment.SetValue(self.node.increment)
class Panel(leginon.gui.wx.Node.Panel,
            leginon.gui.wx.Instrument.SelectionMixin):
    icon = 'navigator'

    def __init__(self, *args, **kwargs):
        leginon.gui.wx.Node.Panel.__init__(self, *args, **kwargs)
        leginon.gui.wx.Instrument.SelectionMixin.__init__(self)

        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_SETTINGS,
                             'settings',
                             shortHelpString='Settings')
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_ACQUIRE,
                             'acquire',
                             shortHelpString='Acquire')
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_STAGE_LOCATIONS,
                             'stagelocations',
                             shortHelpString='Stage Locations')
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_MEASURE,
                             'ruler',
                             shortHelpString='Test stage reproducibility')

        self.toolbar.AddSeparator()
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_RESET_XY,
                             'xy',
                             shortHelpString='Reset stage X,Y to 0,0')
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_RESET_Z,
                             'z',
                             shortHelpString='Reset stage Z to 0')
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_RESET_ALPHA,
                             'alpha',
                             shortHelpString='Reset stage alpha tilt to 0')

        # image
        self.imagepanel = leginon.gui.wx.TargetPanel.ClickAndTargetImagePanel(
            self, -1)
        self.imagepanel.addTypeTool('Image', display=True)
        self.imagepanel.selectiontool.setDisplayed('Image', True)
        self.imagepanel.addTypeTool('Correlation', display=True)
        self.imagepanel.addTargetTool('Peak', wx.Colour(255, 0, 0))

        self.szmain.Add(self.imagepanel, (0, 0), (1, 1), wx.EXPAND)

        self.szmain.AddGrowableRow(0)
        self.szmain.AddGrowableCol(0)

        self.SetSizer(self.szmain)
        self.SetAutoLayout(True)
        self.SetupScrolling()

        self.Bind(EVT_LOCATIONS, self.onLocations)

    def onNodeInitialized(self):
        leginon.gui.wx.Instrument.SelectionMixin.onNodeInitialized(self)
        self.locationsdialog = StageLocationsDialog(self, self.node)

        movetypes = self.node.calclients.keys()
        self.cmovetype = Choice(self.toolbar, -1, choices=movetypes)
        self.cmovetype.SetStringSelection(self.node.settings['move type'])
        ## make sure node setting is a value that is in the choice list
        self.node.settings['move type'] = self.cmovetype.GetStringSelection()
        self.cmovetype.SetToolTip(wx.ToolTip('Navigion Parameter'))
        self.toolbar.InsertControl(2, self.cmovetype)

        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onSettingsTool,
                          id=leginon.gui.wx.ToolBar.ID_SETTINGS)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onAcquireTool,
                          id=leginon.gui.wx.ToolBar.ID_ACQUIRE)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onStageLocationsTool,
                          id=leginon.gui.wx.ToolBar.ID_STAGE_LOCATIONS)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onReproTest,
                          id=leginon.gui.wx.ToolBar.ID_MEASURE)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onResetXY,
                          id=leginon.gui.wx.ToolBar.ID_RESET_XY)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onResetZ,
                          id=leginon.gui.wx.ToolBar.ID_RESET_Z)
        self.toolbar.Bind(wx.EVT_TOOL,
                          self.onResetAlpha,
                          id=leginon.gui.wx.ToolBar.ID_RESET_ALPHA)
        self.cmovetype.Bind(wx.EVT_CHOICE, self.onMoveTypeChoice)
        self.Bind(leginon.gui.wx.ImagePanelTools.EVT_IMAGE_CLICKED,
                  self.onImageClicked, self.imagepanel)
        self.test_dialog = ReproTestDialog(self)
        self.Bind(EVT_TEST, self.onReproTest, self)

    def onResetXY(self, evt):
        self.node.onResetXY()

    def onResetZ(self, evt):
        self.node.onResetZ()

    def onResetAlpha(self, evt):
        self.node.onResetAlpha()

    def onReproTest(self, evt):
        self.test_dialog.Show()

    def onMoveTypeChoice(self, evt):
        self.node.settings['move type'] = evt.GetString()

    def onSettingsTool(self, evt):
        dialog = SettingsDialog(self, show_basic=True)
        dialog.ShowModal()
        dialog.Destroy()

    def _acquisitionEnable(self, enable):
        self.toolbar.Enable(enable)

    def onAcquisitionDone(self, evt):
        self._acquisitionEnable(True)

    def onAcquireTool(self, evt):
        self._acquisitionEnable(False)
        threading.Thread(target=self.node.uiAcquireImage).start()

    def onStageLocationsTool(self, evt):
        self.locationsdialog.ShowModal()

    def onImageClicked(self, evt):
        self._acquisitionEnable(False)
        threading.Thread(target=self.node.navigate, args=(evt.xy, )).start()

    def navigateDone(self):
        evt = leginon.gui.wx.ImagePanel.ImageClickDoneEvent(self.imagepanel)
        self.imagepanel.GetEventHandler().AddPendingEvent(evt)
        self.acquisitionDone()

    def onLocations(self, evt):
        self.locationsdialog.setLocations(evt.locations)

    def locationsEvent(self, locations):
        evt = LocationsEvent(self, locations)
        self.GetEventHandler().AddPendingEvent(evt)
Exemple #4
0
class SelectionPanel(wx.Panel):
	def __init__(self, parent, passive=False):
		'''
		passive means that selecting an instrument does not actually set the 
		parent node's instrument.  You still must get the selection and set
		your instrument yourself.  Also, if the node's instrument changes,
		this gui will not reflect that change.  Useful if you want an 
		instrument selection that is used conditionally.
		'''
		wx.Panel.__init__(self, parent, -1)
		sb = wx.StaticBox(self, -1, 'Instrument')
		self.sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

		self.nonestring = 'None'
		self.passive = passive

		self.ctem = Choice(self, -1, choices=[self.nonestring])
		self.cccdcamera = Choice(self, -1, choices=[self.nonestring])

		sz = wx.GridBagSizer(3, 3)
		label = wx.StaticText(self, -1, 'TEM')
		sz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.ctem, (0, 1), (1, 1), wx.ALIGN_CENTER|wx.EXPAND)
		label = wx.StaticText(self, -1, 'Digital Camera')
		sz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.cccdcamera, (1, 1), (1, 1), wx.ALIGN_CENTER|wx.EXPAND)

		sz.AddGrowableCol(1)

		self.sbsz.Add(sz, 0, wx.EXPAND|wx.ALL, 5)

		self.SetSizer(self.sbsz)
		self.SetAutoLayout(True)

		self.Bind(leginon.gui.wx.Events.EVT_SET_TEMS, self.onSetTEMs)
		self.Bind(leginon.gui.wx.Events.EVT_SET_CCDCAMERAS, self.onSetCCDCameras)
		if not passive:
			self.Bind(wx.EVT_CHOICE, self.onTEMChoice, self.ctem)
			self.Bind(wx.EVT_CHOICE, self.onCCDCameraChoice, self.cccdcamera)
			self.Bind(leginon.gui.wx.Events.EVT_SET_TEM, self.onSetTEM)
			self.Bind(leginon.gui.wx.Events.EVT_SET_CCDCAMERA, self.onSetCCDCamera)

	def setProxy(self, proxy):
		self.proxy = proxy
		if self.proxy is None:
			tem = None
			ccdcamera = None
			tems = []
			ccdcameras = []
		else:
			tem = self.proxy.getTEMName()
			tems = self.proxy.getTEMNames()
			ccdcamera = self.proxy.getCCDCameraName()
			ccdcameras = self.proxy.getCCDCameraNames()
		self.setTEMs(tems)
		self.setTEM(tem)
		self.setCCDCameras(ccdcameras)
		self.setCCDCamera(ccdcamera)

	def GetValue(self):
		value = {}
		value['tem'] = str(self.getTEM())
		value['ccdcamera'] = str(self.getCCDCamera())
		return value

	def SetValue(self, value):
		tem = value['tem']
		ccdcamera = value['ccdcamera']
		if tem == 'None':
			tem = None
		if ccdcamera == 'None':
			ccdcamera = None
		self.setTEM(tem)
		self.setCCDCamera(ccdcamera)

	def getTEM(self):
		tem = self.ctem.GetStringSelection()
		if tem == self.nonestring:
			tem = None
		return tem

	def setTEM(self, tem):
		if tem is None:
			tem = self.nonestring
		elif self.ctem.FindString(tem) == wx.NOT_FOUND:
			tem = self.nonestring
		self.ctem.SetStringSelection(tem)
		if not self.ctem.IsEnabled():
			self.ctem.Enable(True)

	def onSetTEM(self, evt):
		self.setTEM(evt.name)

	def setTEMs(self, tems):
		string = self.ctem.GetStringSelection()
		self.ctem.Freeze()
		self.ctem.Clear()
		self.ctem.AppendItems([self.nonestring] + tems)
		if self.ctem.FindString(string) == wx.NOT_FOUND:
			string = self.nonestring
		self.ctem.SetStringSelection(string)
		self.ctem.Thaw()
		self.sbsz.Layout()

	def onSetTEMs(self, evt):
		self.setTEMs(evt.names)

	def getCCDCamera(self):
		ccdcamera = self.cccdcamera.GetStringSelection()
		if ccdcamera == self.nonestring:
			ccdcamera = None
		return ccdcamera

	def setCCDCamera(self, ccdcamera):
		if ccdcamera is None:
			ccdcamera = self.nonestring
		elif self.cccdcamera.FindString(ccdcamera) == wx.NOT_FOUND:
			ccdcamera = self.nonestring
		self.cccdcamera.SetStringSelection(ccdcamera)
		if not self.cccdcamera.IsEnabled():
			self.cccdcamera.Enable(True)

	def onSetCCDCamera(self, evt):
		self.setCCDCamera(evt.name)

	def setCCDCameras(self, ccdcameras):
		string = self.cccdcamera.GetStringSelection()
		self.cccdcamera.Freeze()
		self.cccdcamera.Clear()
		self.cccdcamera.AppendItems([self.nonestring] + ccdcameras)
		if self.cccdcamera.FindString(string) == wx.NOT_FOUND:
			string = self.nonestring
		self.cccdcamera.SetStringSelection(string)
		self.cccdcamera.Thaw()
		self.sbsz.Layout()

	def onSetCCDCameras(self, evt):
		self.setCCDCameras(evt.names)

	def onTEMChoice(self, evt):
		string = evt.GetString()
		if string == self.nonestring:
			tem = None
		else:
			tem = string
		evt = leginon.gui.wx.Events.TEMChangeEvent(self, name=tem)
		if not self.passive:
			self.GetEventHandler().AddPendingEvent(evt)

	def onCCDCameraChoice(self, evt):
		string = evt.GetString()
		if string == self.nonestring:
			ccdcamera = None
		else:
			ccdcamera = string
		if not self.passive:
			evt = leginon.gui.wx.Events.CCDCameraChangeEvent(self, name=ccdcamera)
			self.GetEventHandler().AddPendingEvent(evt)