self._init_sizers() self.currentControl = None self.controller.update_current() self.controller.update_selection() self.controller.select_current() def Refresh(self): self.controller.update_current() self.controller.update_selection() self.controller.select_current() def needs_apply(self): """Return True if the panel needs to be applied, because a setting changed.""" return (self.controller.current_gon_copy != model.instrument.inst.goniometer) #==================================================================================== if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.goniometer.initialize_goniometers() import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelGoniometer) pnl.SetClientSize(wx.Size(1200,1200)) app.MainLoop()
#------------------------------------------------------------------------------- def SetData(self, data_x, data_y): """ Sets the data to plot in the coverage. Does not redraw. data_x: numpy array of x values for the points. data_y: list of numpy arrays with the y values. data_y[0] is measured once or more, data_y[1] is measured twice, etc.""" self.data_x = data_x self.data_y = data_y #Ensure the slice is still valid. self.CheckSlice() if __name__ == '__main__': import gui_utils (app, sc) = gui_utils.test_my_gui(SliceControl) sc.use_slice = True sc.energy_mode = True data_x = np.arange(-50, 20, 5) print data_x data_y = [] for i in xrange(4): data_y.append( data_x*0 ) sc.SetData(data_x, data_y) sc.Refresh() app.frame.SetClientSize(wx.Size(700,500)) app.MainLoop()
self.handler = None self.control = config_gui.cfg.edit_traits(parent=self, view=view, kind='subpanel', handler=self.handler, context={'cg':config_gui.cfg, 'c':model.config.cfg}).control self.boxSizerAll.InsertWindow(0, self.control, 1, border=8, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP) self.GetSizer().Layout() def OnButtonOKButton(self, event): self.Close() event.Skip() def OnButtonCancelButton(self, event): #Revert the configs back to what we saved config_gui.cfg.copy_traits(self.starting_config_gui) model.config.cfg.copy_traits(self.starting_model_config) #Close it. self.Close() event.Skip() #-------------------------------------------------------------------- if __name__ == '__main__': #Test routine import gui_utils (app, frm) = gui_utils.test_my_gui(DialogPreferences) app.MainLoop()
#=========================================================================== def on_slider(event): global slid print "Scroll End: ", slid.Value def on_slider_scroll(event): global slid print "Scrolling ", slid.Value if __name__ == '__main__': import gui_utils global slid (app, slid) = gui_utils.test_my_gui(ValueSlider, floats=2) slid.Bind(EVT_VALUE_SLIDER_CHANGED, on_slider) slid.Bind(EVT_VALUE_SLIDER_CHANGING, on_slider_scroll) app.MainLoop() # #Test routine # from wxPython.wx import * # # class MyApp(wxApp): # def OnInit(self): # frame = wxFrame(NULL, -1, "Hello from wxPython") # frame.Show(true) # self.vs = ValueSlider(parent=frame, id=wx.NewId(), pos=wx.Point(0,0), size=wx.Size(200,60), style=0, name="slider") # self.vs.Bind(EVT_VALUE_SLIDER_CHANGED, self.Changed2) # self.vs.SetLabel("Phi:") # self.SetTopWindow(frame) # return true
# This is intentionally empty, because we are using the combination # of wx.BufferedPaintDC + an empty OnEraseBackground event to # reduce flicker pass #------------------------------------------------------------------------------- def SetData(self, data_x, data_y): """ Sets the data to plot in the coverage. Does not redraw. data_x: numpy array of x values for the points. data_y: list of numpy arrays with the y values. data_y[0] is measured once or more, data_y[1] is measured twice, etc.""" self.data_x = data_x self.data_y = data_y #Ensure the slice is still valid. self.CheckSlice() if __name__ == '__main__': import gui_utils (app, sc) = gui_utils.test_my_gui(SliceControl) sc.use_slice = True sc.energy_mode = True data_x = np.arange(-50, 20, 5) print data_x data_y = [] for i in xrange(4): data_y.append(data_x * 0) sc.SetData(data_x, data_y) sc.Refresh() app.frame.SetClientSize(wx.Size(700, 500)) app.MainLoop()
if res != wx.ID_YES: self.range_settings.automatic = False #Disable automatic if its on return #Do it! self.apply_crystal_range() event.Skip() def OnButtonRevertRangeButton(self, event): #Go back to what is saved in there. self.range_settings.read_from_exp(model.experiment.exp) event.Skip() if __name__=="__main__": model.crystals._initialize() #Test routine model.instrument.inst = model.instrument.Instrument() model.experiment.exp = model.experiment.Experiment(model.instrument.inst) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelSample) app.MainLoop()
#---------------------------------------------------------------------------------- def __init__(self, parent): #wx.Panel.__init__(self, parent, id, pos, size, style, name) self._init_ctrls(parent) #Create a controller self.controller = TryPositionController(self) #Make all the slider controls using this self.controller.on_goniometer_changed() #---------------------------------------------------------------------------------- def OnCheckAddCheckbox(self, event): self.controller.set_add_position(self.checkAdd.GetValue()) event.Skip() def OnButtonSaveButton(self, event): self.controller.add_to_list() event.Skip() if __name__ == '__main__': import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelTryPosition) app.MainLoop()
_instance = None event.Skip() #------------------------------------------------------------------------- def OncheckBoxFollowWindowCheck(self, event): """Change the following window setting.""" b = self.checkBoxFollowWindow.GetValue() if b: import frame_qspace_view if hasattr(self, 'follower'): self.follower.rebind(self.follower.parent, self, position=self.follower.position) else: self.follower = gui_utils.follow_window(self.parent_frame, self, position=gui_utils.FOLLOW_SIDE_TOP) else: if hasattr(self, 'follower'): self.follower.unbind() if not event is None: event.Skip() if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.experiment.exp = model.experiment.Experiment(model.instrument.inst) model.experiment.exp.initialize_reflections() import gui_utils (app, pnl) = gui_utils.test_my_gui(FrameReflectionInfo) # app.frame.SetClientSize(wx.Size(500, 200)) # pnl.set_reflection_measurements(None) # pnl.set_hkl(1,2,3) app.MainLoop()
event.Skip() def OnButtonOptimizeButton(self, event): """Start optimizing using GA.""" dop = model.optimize_coverage.DetectorOptimizationParameters() if dop.configure_traits(): #User clicked OKAY, do optimization det_list = model.optimize_coverage.optimize_detector_choice( dop, gui=True) #This will check the boxes as well as update the other ui windows. self.controller.select_detector_list(det_list) event.Skip() def OnButtonLoadDetectors(self, event): self.controller.load_detectors_dialog() event.Skip() #==================================================================================== if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.goniometer.initialize_goniometers() # frame3d = DetectorView3D(self, wx.NewId()) # frame3d.display() # sys.exit() import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelDetectors) app.MainLoop()
self.plotControl = PlotPanelGAStats(self.panelStatus) self._init_sizers() def __init__(self, parent): #The view controller self.controller = OptimizerController(self) self._init_ctrls(parent) #Initial update. self.controller.update() #Clear axes self.controller.plot_data() #--- Parameters ---- self.params_control = self.controller.params.edit_traits(parent=self.panelParams,kind='subpanel').control self.boxSizerParams.Insert(2, self.params_control, 0, border=1, flag=wx.EXPAND) self.boxSizerParams.Layout() if __name__ == "__main__": import gui_utils (app, frm) = gui_utils.test_my_gui(FrameOptimizer) frm.Raise() app.MainLoop()
def OnGridExpGridLabelLeftDClick(self, event): self.controller.label_dclick(event) event.Skip() def OnButtonRefreshListButton(self, event): self.controller.update_grid() event.Skip() if __name__ == "__main__": #Ok, create the instrument model.instrument.inst = model.instrument.Instrument("model/TOPAZ_geom_all_2011.csv") model.instrument.inst.make_qspace() #Initialize the instrument and experiment model.experiment.exp = model.experiment.Experiment(model.instrument.inst) # import numpy as np # for i in np.deg2rad(np.arange(0, 36, 12)): # model.instrument.inst.simulate_position(list([i,i,i])) # pd = dict() # for pos in model.instrument.inst.positions: # pd[ id(pos) ] = True # display_thread.NextParams[model.experiment.PARAM_POSITIONS] = model.experiment.ParamPositions(pd) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelExperiment) app.frame.SetClientSize(wx.Size(700,500)) app.MainLoop()
def OnGridExpGridLabelLeftClick(self, event): event.Skip() def OnGridExpGridLabelLeftDClick(self, event): self.controller.label_dclick(event) event.Skip() def OnButtonRefreshListButton(self, event): self.controller.update_grid() event.Skip() if __name__ == "__main__": #Ok, create the instrument model.instrument.inst = model.instrument.Instrument( "model/TOPAZ_geom_all_2011.csv") model.instrument.inst.make_qspace() #Initialize the instrument and experiment model.experiment.exp = model.experiment.Experiment(model.instrument.inst) # import numpy as np # for i in np.deg2rad(np.arange(0, 36, 12)): # model.instrument.inst.simulate_position(list([i,i,i])) # pd = dict() # for pos in model.instrument.inst.positions: # pd[ id(pos) ] = True # display_thread.NextParams[model.experiment.PARAM_POSITIONS] = model.experiment.ParamPositions(pd) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelExperiment) app.frame.SetClientSize(wx.Size(700, 500)) app.MainLoop()
def Refresh(self): self.handler.revert() self.original_params = copy.copy(self.params) #Make sure it doesn't think something changed. def OnbuttonApplyButton(self, event): self.handler.apply() self.original_params = copy.copy(self.params) event.Skip() def OnButtonQuitButton(self, event): self.handler.revert() event.Skip() def needs_apply(self): """Return True if the panel needs to be applied, because a setting changed.""" return (self.original_params != self.params) # =========================================================================================== # =========================================================================================== # =========================================================================================== if __name__ == '__main__': import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelStartup) app.frame.SetClientSize(wx.Size(700,500)) app.MainLoop()
dlg.Destroy() event.Skip() def OnButtonOptimizeButton(self, event): """Start optimizing using GA.""" dop = model.optimize_coverage.DetectorOptimizationParameters() if dop.configure_traits(): #User clicked OKAY, do optimization det_list = model.optimize_coverage.optimize_detector_choice(dop, gui=True) #This will check the boxes as well as update the other ui windows. self.controller.select_detector_list(det_list) event.Skip() def OnButtonLoadDetectors(self, event): self.controller.load_detectors_dialog() event.Skip() #==================================================================================== if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.goniometer.initialize_goniometers() # frame3d = DetectorView3D(self, wx.NewId()) # frame3d.display() # sys.exit() import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelDetectors) app.MainLoop()
self.mouse_pos = self.get_detector_coords(event.X, event.Y) #Send a continuous event? if event.LeftIsDown() and not np.any(np.isnan(self.mouse_pos)): clickEvent = DetectorClickMoved(data=self.mouse_pos) self.GetEventHandler().ProcessEvent(clickEvent) if self.show_coordinates: self.Refresh() #--------------------------------------------------------------------------- def OnLeftUp(self, event): """Called when clicking on the detector face.""" self.mouse_pos = self.get_detector_coords(event.X, event.Y) if not np.any(np.isnan(self.mouse_pos)): clickEvent = DetectorClicked(data=self.mouse_pos) self.GetEventHandler().ProcessEvent(clickEvent) #=========================================================================== if __name__ == "__main__": import gui_utils (app, pnl) = gui_utils.test_my_gui(DetectorPlot) app.frame.SetClientSize(wx.Size(500, 700)) det = model.detectors.FlatDetector("Modified det") det.width = 250 det.height = 125 pnl.set_detector(det) app.MainLoop()
event.Skip() def OnCheckSymmetryCheckbox(self, event): self.controller.set_symmetry( self.checkSymmetry.GetValue() ) event.Skip() def OnCheckShowRedundancyCheckbox(self, event): self.controller.show_redundancy( self.checkShowRedundancy.GetValue() ) event.Skip() # =========================================================================================== # =========================================================================================== # =========================================================================================== if __name__ == '__main__': #Ok, create the instrument model.instrument.inst = model.instrument.InstrumentInelastic("../instruments/TOPAZ_geom_all_2011.csv") model.instrument.inst.make_qspace() #Initialize the instrument and experiment model.experiment.exp = model.experiment.Experiment(model.instrument.inst) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelQspaceOptions) app.frame.SetClientSize(wx.Size(700,500)) app.MainLoop()
self.controller.change_masking_settings() event.Skip() def OnChangeMaskingSettings(self, event): self.controller.change_masking_settings() event.Skip() def OnChangeDisplaySettings(self, event): self.controller.change_display_settings() event.Skip() # =========================================================================================== # =========================================================================================== # =========================================================================================== if __name__ == '__main__': #Ok, create the instrument model.instrument.inst = model.instrument.Instrument("../instruments/TOPAZ_detectors_2010.csv") model.instrument.inst.make_qspace() #Initialize the instrument and experiment model.experiment.exp = model.experiment.Experiment(model.instrument.inst) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelReflectionsViewOptions) app.frame.SetClientSize(wx.Size(700,500)) app.MainLoop()
if b: dlg = wx.MessageDialog( self, "The number of reflections given by this range, %s, is very large. Are you sure?" % gui_utils.print_large_number(n), "Too Many Reflections", wx.YES_NO | wx.ICON_INFORMATION) res = dlg.ShowModal() dlg.Destroy() if res != wx.ID_YES: self.range_settings.automatic = False #Disable automatic if its on return #Do it! self.apply_crystal_range() event.Skip() def OnButtonRevertRangeButton(self, event): #Go back to what is saved in there. self.range_settings.read_from_exp(model.experiment.exp) event.Skip() if __name__ == "__main__": model.crystals._initialize() #Test routine model.instrument.inst = model.instrument.Instrument() model.experiment.exp = model.experiment.Experiment(model.instrument.inst) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelSample) app.MainLoop()
def OnMouseMove(self, event): self.mouse_pos = self.get_detector_coords(event.X, event.Y) #Send a continuous event? if event.LeftIsDown() and not np.any(np.isnan(self.mouse_pos)): clickEvent = DetectorClickMoved(data=self.mouse_pos) self.GetEventHandler().ProcessEvent(clickEvent) if self.show_coordinates: self.Refresh() #--------------------------------------------------------------------------- def OnLeftUp(self, event): """Called when clicking on the detector face.""" self.mouse_pos = self.get_detector_coords(event.X, event.Y) if not np.any(np.isnan(self.mouse_pos)): clickEvent = DetectorClicked(data=self.mouse_pos) self.GetEventHandler().ProcessEvent(clickEvent) #=========================================================================== if __name__ == "__main__": import gui_utils (app, pnl) = gui_utils.test_my_gui(DetectorPlot) app.frame.SetClientSize(wx.Size(500, 700)) det = model.detectors.FlatDetector("Modified det") det.width = 250 det.height = 125 pnl.set_detector(det) app.MainLoop()
self.map_thread.abort() event.Skip() #------------------------------------------------------------ def calculation_callback(self, step, percent): if step<=0: s = "Map calculation complete." else: s = "Calculating map, step %d, %.0f%% done."%(step, percent*100) self.statusBar.SetStatusText(s) #=========================================================================== def show_placer_frame(parent, refl, meas): """Show the reflection placer frame with the given values as starting points.""" frm = FrameReflectionPlacer(parent, refl, meas) frm.Show() return frm #=========================================================================== if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument(model.config.cfg.default_detector_filename) model.experiment.exp = model.experiment.Experiment(model.instrument.inst) model.experiment.exp.initialize_reflections() import gui_utils refl = Reflection( (1,1,-6), np.array([1,1,-6]) ) (app, pnl) = gui_utils.test_my_gui(FrameReflectionPlacer, refl, None) app.frame.SetClientSize(wx.Size(500, 850)) app.MainLoop()
self.original_params = copy.copy(self.params) def Refresh(self): self.handler.revert() self.original_params = copy.copy( self.params) #Make sure it doesn't think something changed. def OnbuttonApplyButton(self, event): self.handler.apply() self.original_params = copy.copy(self.params) event.Skip() def OnButtonQuitButton(self, event): self.handler.revert() event.Skip() def needs_apply(self): """Return True if the panel needs to be applied, because a setting changed.""" return (self.original_params != self.params) # =========================================================================================== # =========================================================================================== # =========================================================================================== if __name__ == '__main__': import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelStartup) app.frame.SetClientSize(wx.Size(700, 500)) app.MainLoop()
def __init__(self, parent): self.controller = PanelGoniometerController(self) self._init_ctrls(parent) self._init_sizers() self.currentControl = None self.controller.update_current() self.controller.update_selection() self.controller.select_current() def Refresh(self): self.controller.update_current() self.controller.update_selection() self.controller.select_current() def needs_apply(self): """Return True if the panel needs to be applied, because a setting changed.""" return (self.controller.current_gon_copy != model.instrument.inst.goniometer) #==================================================================================== if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.goniometer.initialize_goniometers() import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelGoniometer) pnl.SetClientSize(wx.Size(1200, 1200)) app.MainLoop()
self.Destroy() else: event.Veto() def OnStatusBarUpdate(self, message): """Called when we receive a message that the statusbar needs updating.""" #print message self.statusBar_main.SetStatusText(message.data) def OnScriptCommand(self, message): """Called to execute a scripted GUI command.""" # @type call FunctionCall call = message.data #Call that function call.function(*call.args, **call.kwargs) def OnIdle(self, event): self.count += 1 #print "Idle", self.count event.Skip() #-------------------------------------------------------------------- if __name__ == '__main__': #Test routine model.instrument.inst = model.instrument.Instrument( model.config.cfg.default_detector_filename) model.experiment.exp = model.experiment.Experiment(model.instrument.inst) (app, frm) = gui_utils.test_my_gui(FrameMain) app.MainLoop()
def OnCheckUseEquivalent(self, event): #Update the measurements. self.set_reflection_measurements(self.refl) event.Skip() if __name__ == "__main__": model.instrument.inst = model.instrument.Instrument() model.experiment.exp = model.experiment.Experiment(model.instrument.inst) model.experiment.exp.initialize_reflections() import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelReflectionInfo) app.frame.SetClientSize(wx.Size(300, 500)) #@type refl Reflection refl = model.reflections.Reflection( (1,2,3), np.array([1,2,3])) for i in xrange(7): refl.measurements.append( (1,2,3,4,5,6) ) for i in xrange(4): rrm = ReflectionRealMeasurement() rrm.detector_num = i rrm.integrated = i*11.0 rrm.sigI = i*0.5 rrm.wavelength = i+.23 rrm.distance = i+.45 rrm.horizontal = 10+i rrm.vertical = -10-i rrm.measurement_num = i+1000
def OnStatusBarUpdate(self, message): """Called when we receive a message that the statusbar needs updating.""" #print message self.statusBar_main.SetStatusText(message.data) def OnScriptCommand(self, message): """Called to execute a scripted GUI command.""" # @type call FunctionCall call = message.data #Call that function call.function(*call.args, **call.kwargs) def OnIdle(self, event): self.count += 1 #print "Idle", self.count event.Skip() #-------------------------------------------------------------------- if __name__ == '__main__': #Test routine model.instrument.inst = model.instrument.Instrument(model.config.cfg.default_detector_filename) model.experiment.exp = model.experiment.Experiment(model.instrument.inst) (app, frm) = gui_utils.test_my_gui(FrameMain) app.MainLoop()
event.Skip() def OnCheckInvertCheckbox(self, event): self.controller.set_invert(self.checkInvert.GetValue()) event.Skip() def OnCheckSymmetryCheckbox(self, event): self.controller.set_symmetry(self.checkSymmetry.GetValue()) event.Skip() def OnCheckShowRedundancyCheckbox(self, event): self.controller.show_redundancy(self.checkShowRedundancy.GetValue()) event.Skip() # =========================================================================================== # =========================================================================================== # =========================================================================================== if __name__ == '__main__': #Ok, create the instrument model.instrument.inst = model.instrument.InstrumentInelastic( "../instruments/TOPAZ_geom_all_2011.csv") model.instrument.inst.make_qspace() #Initialize the instrument and experiment model.experiment.exp = model.experiment.Experiment(model.instrument.inst) import gui_utils (app, pnl) = gui_utils.test_my_gui(PanelQspaceOptions) app.frame.SetClientSize(wx.Size(700, 500)) app.MainLoop()