View
All the files related to the GUI should be placed within the View package. This is the third leg of the MVC design pattern. If the Model is properly built, the Views are relatively simple PyQt objects. It is important to point out that if there is any logic of the experiment that goes into the view, the code is going to become harder to share, unless it is for the exact same purpose.
Start GUI
Convenience function to wrap the initialization of a window. The Experiment class should be created outside and passed as argument.
>>> experiment = Experiment()
>>> experiment.load_config('filename')
>>> experiment.load_daq()
>>> start_gui(experiment)
- PFTL.view.start_gui.start_gui(experiment)[source]
Starts a GUI for the ScanWindow using the provided experiment. :param Experiment experiment: Experiment object with a loaded config.
Main Window
This is the central code for the user interface of Python for the Lab. The design of the window is specifcied in its own .ui file, generated with Qt Designer.
- class PFTL.view.main_window.MainWindow(experiment=None)[source]
Bases:
QMainWindowMain Window for the user interface
- Parameters:
experiment (Experiment) – Experiment model, can be left empty just for testing. Should be instantiated and initialized before passing it.
- experiment
The experiment object
- Type:
- plot_widget
Widget to hold the plot
- Type:
pg.PlotWidget
- plot
The real plot that can be updated with new data
- Type:
pg.PlotWidget.plotItem
- start_button
The start button
- Type:
QPushButton
- start_scan()[source]
Wrapper that updates the values from the UI (start, stop, num_steps, delay, channel_in, channel_out) before starting the scan.
Warning
There is a bug in this code (left for students to find out and sort it). If a user changes the values on the UI and presses “start” again, the metadata will store the new values, not the proper ones.
- stop_scan()[source]
Stops the scan. It is wrapping the
stop_scan()method. The only reason to do it this way is in case stopping a scan requires more work, for example stopping timers to prevent useless updates, etc.