Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BaseBrowser = import_qt('.._common', 'mantidqt.widgets', 'FitPropertyBrowser')
class FitPropertyBrowserBase(BaseBrowser):
def __init__(self, parent=None):
super(FitPropertyBrowserBase, self).__init__(parent)
self.init()
class FitPropertyBrowser(FitPropertyBrowserBase):
"""
A wrapper around C++ FitPropertyBrowser with added graphical peak editing tool.
"""
closing = Signal()
def __init__(self, canvas, toolbar_manager, parent=None):
super(FitPropertyBrowser, self).__init__(parent)
self.init()
self.setFeatures(self.DockWidgetMovable)
self.canvas = canvas
# The toolbar state manager to be passed to the peak editing tool
self.toolbar_manager = toolbar_manager
# The peak editing tool
self.tool = None
# The name of the fit result workspace
self.fit_result_ws_name = ""
# Pyplot line for the guess curve
self.guess_line = None
# Map the indices of the markers in the peak editing tool to the peak function prefixes
# (in the form f0.f1...)
# Create custom QSpinBox
class QW_QSpinBox(QW.QSpinBox, QW_QAbstractSpinBox):
pass
# Create custom label class with more signals
class QW_QLabel(QW.QLabel):
"""
Defines the :class:`~QW_QLabel` class.
This class provides default settings and extra options for the
:class:`~PyQt5.QtWidgets.QLabel` class.
"""
mousePressed = QC.Signal()
# Override the mousePressEvent to emit a signal whenever it is triggered
def mousePressEvent(self, event):
self.mousePressed.emit()
event.accept()
# Create custom QMenu class that swaps the order of inputs
class QW_QMenu(QW.QMenu):
"""
Defines the :class:`~QW_QMenu` class.
This class provides default settings and extra options for the
:class:`~PyQt5.QtWidgets.QMenu` class.
"""
class Column(IntEnum):
Number = 0
Name = 1
LastActive = 2
class PlotSelectorView(QWidget):
"""
The view to the plot selector, a PyQt widget.
"""
# A signal to capture when keys are pressed
deleteKeyPressed = Signal(int)
enterKeyPressed = Signal(int)
def __init__(self, presenter, parent=None):
"""
Initialise a new instance of PlotSelectorWidget
:param presenter: The presenter controlling this view
:param parent: Optional - the parent QWidget
running as a unit test, in which case skip file dialogs
"""
super(PlotSelectorView, self).__init__(parent)
self.presenter = presenter
# This mutex prevents multiple operations on the table at the
# same time. Wrap code in - with QMutexLocker(self.mutex):
self.mutex = QMutex()
self.active_plot_number = -1
directory, so we may need several servers. This class manages all these
servers.
Attributes
----------
dark_theme : bool
Whether notebooks should be rendered using the dark theme.
servers : list of ServerProcess
List of servers managed by this object.
"""
# A server has started and is now accepting requests
sig_server_started = Signal()
# We tried to start a server but it took too long to start up
sig_server_timed_out = Signal()
# We tried to start a server but an error occurred
sig_server_errored = Signal()
def __init__(self, dark_theme=False):
"""
Construct a ServerManager.
Parameters
----------
dark_theme : bool, optional
Whether notebooks should be rendered using the dark theme.
The default is False.
"""
super().__init__()
self.dark_theme = dark_theme
"""
CONF_SECTION = 'editor'
CONFIGWIDGET_CLASS = EditorConfigPage
CONF_FILE = False
TEMPFILE_PATH = get_conf_path('temp.py')
TEMPLATE_PATH = get_conf_path('template.py')
DISABLE_ACTIONS_WHEN_HIDDEN = False # SpyderPluginWidget class attribute
# Signals
run_in_current_ipyclient = Signal(str, str, str,
bool, bool, bool, bool, bool)
run_cell_in_ipyclient = Signal(str, object, str, bool)
debug_cell_in_ipyclient = Signal(str, object, str, bool)
exec_in_extconsole = Signal(str, bool)
redirect_stdio = Signal(bool)
open_dir = Signal(str)
breakpoints_saved = Signal()
run_in_current_extconsole = Signal(str, str, str, bool, bool)
open_file_update = Signal(str)
# This signal is fired for any focus change among all editor stacks
sig_editor_focus_changed = Signal()
def __init__(self, parent, ignore_last_opened_files=False):
SpyderPluginWidget.__init__(self, parent)
self.__set_eol_chars = True
# Creating template if it doesn't already exist
if not osp.isfile(self.TEMPLATE_PATH):
if os.name == "nt":
shebang = []
def set_spyder_breakpoints(self):
"""Set Spyder breakpoints into debugging session"""
return self.ask_monitor("set_spyder_breakpoints()")
def is_running(self):
"""Check if parent is running"""
return self.parent().is_running()
class ExternalPythonShell(ExternalShellBase):
"""External Shell widget: execute Python script in a separate process"""
SHELL_CLASS = ExtPythonShellWidget
sig_pdb = Signal(str, int)
open_file = Signal(str, int)
started = Signal()
sig_finished = Signal()
def __init__(self, parent=None, fname=None, wdir=None,
interact=False, debug=False, post_mortem=False,
path=[], python_args='',
arguments='', stand_alone=None,
umr_enabled=True, umr_namelist=[], umr_verbose=True,
pythonstartup=None, pythonexecutable=None,
external_interpreter=False,
monitor_enabled=True, mpl_backend=None, ets_backend='qt4',
qt_api=None, merge_output_channels=False,
colorize_sys_stderr=False,
light_background=True,
menu_actions=None, show_buttons_inside=True,
show_elapsed_time=True):
assert qt_api in (None, 'pyqt', 'pyside', 'pyqt5')
to Qt Widgets.
In ScopeFoundry we represent the values in an object called a
`LoggedQuantity`. A :class:`LoggedQuantity` is a class that contains a
value, a `bool`, `float`, `int`, `str` etc that is part of an application's
state. In the case of microscope and equipment control, these also can
represent the state of a piece of hardware. These are very useful objects
because the are the central location of the value contained within. All
graphical interface views will be guaranteed to be consistent with the `LQ`
state. The data of these quantities will also be saved in datafiles created
by ScopeFoundry.
"""
# signal sent when value has been updated
updated_value = QtCore.Signal((float,),(int,),(bool,), (), (str,),)
# signal sent when value has been updated, sends text representation
updated_text_value = QtCore.Signal(str)
# emits the index of the value in self.choices
updated_choice_index_value = QtCore.Signal(int)
# signal sent when min max range updated
updated_min_max = QtCore.Signal((float,float),(int,int), (),)
# signal sent when read only (ro) status has changed
updated_readonly = QtCore.Signal((bool,), (),)
def __init__(self, name, dtype=float,
hardware_read_func=None, hardware_set_func=None,
initial=0, fmt="%g", si=False,
ro = False, # read only flag
unit = None,
spinbox_decimals = 2,
class CameraODMRGui(GUIBase):
"""
This is the GUI Class for ODMR measurements
"""
_modclass = 'CameraODMRGui'
_modtype = 'gui'
# declare connectors
odmrlogic1 = Connector(interface='ODMRLogic')
savelogic = Connector(interface='SaveLogic')
camera_logic = Connector(interface='CameraLogic')
sigVideoStart = QtCore.Signal()
sigVideoStop = QtCore.Signal()
sigAreaChanged = QtCore.Signal(list)
timer = QtCore.QTimer()
sigDoCameraFit = QtCore.Signal(str, object, object, int)
def __init__(self, config, **kwargs):
super().__init__(config=config, **kwargs)
def on_activate(self):
""" Definition, configuration and initialisation of the ODMR GUI.
This init connects all the graphic modules, which were created in the
*.ui file and configures the event handling between the modules.
"""
self._odmr_logic = self.odmrlogic1()
self._camera_logic = self.camera_logic()
# config
_ai_counter = ConfigOption("AI_counter", None, missing="warn")
# 3D
_ao_channel = ConfigOption("3D_3rd_Axis", None, missing="warn")
scan_resolution_3D = ConfigOption('3D_scan_resolution', 1e-6, missing="warn")
start_voltage_3D = ConfigOption('3D_start_voltage', 0, missing="warn")
end_voltage_3D = ConfigOption('3D_end_voltage', 1, missing="warn")
_3D_smoothing_steps = ConfigOption('smoothing_parameter', 0, missing="info")
# Todo: add /check QTCore Signals (not all have functions yet)
# signals
signal_start_stepping = QtCore.Signal()
signal_stop_stepping = QtCore.Signal()
signal_continue_stepping = QtCore.Signal()
signal_step_lines_next = QtCore.Signal(bool)
signal_start_3D_stepping = QtCore.Signal()
signal_step_lines_finesse_next = QtCore.Signal(bool)
signal_image_updated = QtCore.Signal()
signal_change_position = QtCore.Signal(str)
signal_data_saved = QtCore.Signal()
signal_tilt_correction_active = QtCore.Signal(bool)
signal_tilt_correction_update = QtCore.Signal()
signal_draw_figure_completed = QtCore.Signal()
signal_position_changed = QtCore.Signal()
signal_step_scan_stopped = QtCore.Signal()
signal_sort_count_data = QtCore.Signal(tuple, int)
signal_sort_count_data_3D = QtCore.Signal(tuple, int)
sigImageInitialized = QtCore.Signal()
along with Qudi. If not, see .
"""
from qtpy import QtCore, QtWidgets
import numpy as np
__all__ = ['DoubleSlider']
class DoubleSlider(QtWidgets.QSlider):
"""
"""
doubleValueChanged = QtCore.Signal(float)
doubleSliderMoved = QtCore.Signal(float)
doubleRangeChanged = QtCore.Signal(float, float)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._step_number = 1000
self._minimum_value = 0
self._maximum_value = 1
super().setRange(0, self._step_number)
self.valueChanged.connect(self.__translate_value_changed)
self.sliderMoved.connect(self.__translate_slider_moved)
self.rangeChanged.connect(self.__translate_range_changed)
return
def setMinimum(self, min_val):
self._minimum_value = float(min_val)
return