def setup(self, fname): """Setup Run Configuration dialog with filename *fname*""" combo_label = QLabel(_("Select a run configuration:")) self.combo = QComboBox() self.combo.setMaxVisibleItems(20) self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.stack = QStackedWidget() configurations = _get_run_configurations() for index, (filename, options) in enumerate(configurations): if fname == filename: break else: # There is no run configuration for script *fname*: # creating a temporary configuration that will be kept only if # dialog changes are accepted by the user configurations.insert(0, (fname, RunConfiguration(fname).get())) index = 0 for filename, options in configurations: widget = RunConfigOptions(self) widget.set(options) self.combo.addItem(filename) self.stack.addWidget(widget) self.combo.currentIndexChanged.connect(self.stack.setCurrentIndex) self.combo.setCurrentIndex(index) self.add_widgets(combo_label, self.combo, 10, self.stack) self.add_button_box(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.setWindowTitle(_("Run configuration per file"))
def __init__(self, parent=None): QDialog.__init__(self, parent) self.main = parent # Widgets self.pages_widget = QStackedWidget() self.pages_widget.setMinimumWidth(600) self.contents_widget = QListWidget() self.button_reset = QPushButton(_('Reset to defaults')) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.ok_btn = bbox.button(QDialogButtonBox.Ok) # Widgets setup # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Spyder), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle(_('Preferences')) self.setWindowIcon(ima.icon('configure')) self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) self.contents_widget.setCurrentRow(0) self.contents_widget.setMinimumWidth(220) self.contents_widget.setMinimumHeight(400) # Layout hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) hsplitter.setStretchFactor(0, 1) hsplitter.setStretchFactor(1, 2) btnlayout = QHBoxLayout() btnlayout.addWidget(self.button_reset) btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) # Signals and slots if self.main: self.button_reset.clicked.connect(self.main.reset_spyder) self.pages_widget.currentChanged.connect(self.current_page_changed) self.contents_widget.currentRowChanged.connect( self.pages_widget.setCurrentIndex) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) # Ensures that the config is present on spyder first run CONF.set('main', 'interface_language', load_lang_conf())
def __init__(self): super(ConfigDialog, self).__init__() self.needs_reload = True # Set size and position self.setGeometry(0, 0, 900, 550) frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) self.contentsWidget = QListView() self.contentsWidget.setViewMode(QListView.IconMode) # self.contentsWidget.setIconSize(QSize(96, 84)) self.contentsWidget.setMovement(QListView.Static) self.contentsWidget.setMaximumWidth(174) self.contentsWidget.setSpacing(12) self.contentsWidget.setSelectionMode(QAbstractItemView.SingleSelection) self.contentsModel = QStandardItemModel() self.contentsWidget.setModel(self.contentsModel) self.contentsWidget.selectionModel().currentChanged.connect( self.changePage) self.buttonboxWidget = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Apply # | QDialogButtonBox.Help ) self.buttonboxWidget.button(QDialogButtonBox.Ok).clicked.connect( self.ok) self.buttonboxWidget.button(QDialogButtonBox.Apply).clicked.connect( self.apply) self.buttonboxWidget.button(QDialogButtonBox.Cancel).clicked.connect( self.close) self.pagesWidget = QStackedWidget() horizontalLayout = QHBoxLayout() horizontalLayout.addWidget(self.contentsWidget) horizontalLayout.addWidget(self.pagesWidget, 1) mainLayout = QVBoxLayout() mainLayout.addLayout(horizontalLayout) # mainLayout.addStretch(1) mainLayout.addSpacing(12) mainLayout.addWidget(self.buttonboxWidget) self.setLayout(mainLayout) self.setWindowTitle("Config Dialog") # Set modality self.setModal(True) self.lastwidget = None # Restore Settings pluginmanager.attach(self.request_reload, Filters.COMPLETE)
def __init__(self, ert: EnKFMain, notifier: ErtNotifier, config_file: str): self.notifier = notifier QWidget.__init__(self) self.ert = ert self.facade = LibresFacade(ert) self._config_file = config_file self.setObjectName("Simulation_panel") layout = QVBoxLayout() self._simulation_mode_combo = QComboBox() self._simulation_mode_combo.setObjectName("Simulation_mode") addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode") self._simulation_mode_combo.currentIndexChanged.connect( self.toggleSimulationMode) simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter) simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setObjectName("start_simulation") self.run_button.setText("Start simulation") self.run_button.setIcon(resourceIcon("play_circle.svg")) self.run_button.setIconSize(QSize(32, 32)) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self._simulation_stack = QStackedWidget() self._simulation_stack.setLineWidth(1) self._simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self._simulation_stack) self._simulation_widgets = OrderedDict() """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]""" self.addSimulationConfigPanel(SingleTestRunPanel(ert, notifier)) self.addSimulationConfigPanel(EnsembleExperimentPanel(ert, notifier)) if self.facade.have_observations: self.addSimulationConfigPanel(EnsembleSmootherPanel(ert, notifier)) self.addSimulationConfigPanel( MultipleDataAssimilationPanel(self.facade, notifier)) self.addSimulationConfigPanel( IteratedEnsembleSmootherPanel(self.facade, notifier)) self.setLayout(layout)
def __init__(self, config_file): QWidget.__init__(self) self._config_file = config_file self._ee_config = None if FeatureToggling.is_enabled("ensemble-evaluator"): self._ee_config = EvaluatorServerConfig() self.setObjectName("Simulation_panel") layout = QVBoxLayout() self._simulation_mode_combo = QComboBox() self._simulation_mode_combo.setObjectName("Simulation_mode") addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode") self._simulation_mode_combo.currentIndexChanged.connect( self.toggleSimulationMode) simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter) simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setObjectName("start_simulation") self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self._simulation_stack = QStackedWidget() self._simulation_stack.setLineWidth(1) self._simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self._simulation_stack) self._simulation_widgets = OrderedDict() """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]""" self.addSimulationConfigPanel(SingleTestRunPanel()) self.addSimulationConfigPanel(EnsembleExperimentPanel()) if ERT.ert.have_observations(): self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def __init__(self, parent=None, objname=None): QDialog.__init__(self, parent) # If used for data object in tree, the main is the tree widget. self.parent = parent self.objname = objname # Widgets self.pages_widget = QStackedWidget() self.contents_widget = QListWidget() self.button_reset = QPushButton(_('Reset to defaults')) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) # Widgets setup # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Ezcad), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) if self.objname is None: self.setWindowTitle(_('Preferences')) else: self.setWindowTitle(_('Preferences of ') + self.objname) self.setWindowIcon(ima.icon('configure')) self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) self.contents_widget.setCurrentRow(0) # Layout hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) hsplitter.setSizes([150,500]) btnlayout = QHBoxLayout() btnlayout.addWidget(self.button_reset) btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) # Signals and slots self.pages_widget.currentChanged.connect(self.current_page_changed) self.contents_widget.currentRowChanged.connect( self.pages_widget.setCurrentIndex) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) bbox.clicked.connect(self.button_clicked) # Ensures that the config is present on ezcad first run CONF.set('main', 'interface_language', load_lang_conf())
def __init__(self, parent=None, model=None): super(StackedCanvasView, self).__init__(parent) if model is not None: self.setModel(model) self.canvas_display_widgets = [ CanvasDisplayTabWidget(), SplitHorizontal(), SplitVertical(), SplitThreeView(), SplitGridView() ] ### Create stacked widget and fill pages with different canvas display widgets self.stackedwidget = QStackedWidget(self) # Create a visual layout section for the buttons that are used to switch the widgets self.buttonpanel = QHBoxLayout() self.buttonpanel.addStretch(10) # Create a logical button grouping that will: # - show the currently selected view (button will be checked/pressed) # - allow for switching the buttons/views in a mutually exclusive manner (only one can be pressed at a time) self.buttongroup = QButtonGroup() def add_canvas_display_widgets(): for i in range(len(self.canvas_display_widgets)): # Add the view to the stacked widget self.stackedwidget.addWidget(self.canvas_display_widgets[i]) # Create a button, using the view's recommended display icon button = QPushButton(self) button.setCheckable(True) button.setIcon(self.canvas_display_widgets[i].icon) button.setToolTip( getattr(self.canvas_display_widgets[i], "tool_tip", None)) button.setWhatsThis( getattr(self.canvas_display_widgets[i], "whats_this", None)) # Add the button to the logical button group self.buttongroup.addButton(button, i) # Add the button to the visual layout section self.buttonpanel.addWidget(button) add_canvas_display_widgets() def set_default_canvas_display_widget(): # The first button added to the buttongroup will be the currently selected button (and therefore view) self.buttongroup.button(0).setChecked(True) set_default_canvas_display_widget() # Whenever a button is switched, capture its id (corresponds to integer index in our case); # this will handle switching the view and displaying canvases. self.buttongroup.idToggled.connect(self.switch_view) # define outer layout & add stacked widget and button panel self.layout = QVBoxLayout() self.layout.addWidget(self.stackedwidget) self.layout.addLayout(self.buttonpanel) self.setLayout(self.layout)
def __init__(self, *args, **kwargs): # define status images self.status_icons = { -2: QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'depth_status_delay.png')), -1: QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'depth_status_in_use.png')), 1: QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'depth_status_done.png')), 0: QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'depth_status_off.png')), } # Settings self.subject_settings = None self.procedure_settings = None self.depth_settings = None self.features_settings = None # Plot options self.plot_config = {} self.y_range = uVRANGE self.plot_stack = QStackedWidget() # generate a dict {chan_label: {Feature:[stack idx, latest_datum]}} self.stack_dict = {} # shared memory to display the currently monitored electrode self.monitored_channel_mem = QSharedMemory() self.monitored_channel_mem.setKey("MonitoredChannelMemory") self.monitored_channel_mem.attach(QSharedMemory.ReadOnly) # wrap up init super(FeaturesPlotWidget, self).__init__(*args, **kwargs) self.move(WINDOWDIMS_FEATURES[0], WINDOWDIMS_FEATURES[1]) self.resize(WINDOWDIMS_FEATURES[2], WINDOWDIMS_FEATURES[3]) self.setMaximumWidth(WINDOWDIMS_FEATURES[2]) # initialize plots self.layout().addWidget(self.plot_stack) self.refresh_axes() # Extra time on purpose. # Define and start processes # will only start processes when settings are received self.depth_wrapper = ProcessWrapper('Depth_Process') self.depth_process_running = False self.features_wrapper = ProcessWrapper('Features_Process') self.features_process_running = False
def __init__(self): super(ExtendedTabWidget, self).__init__() self._tab_bar = None self._stack = QStackedWidget() self._main_layout = QBoxLayout(QBoxLayout.LeftToRight) self._main_layout.setContentsMargins(0, 0, 0, 0) self._main_layout.addWidget(self._stack) self.setLayout(self._main_layout)
def __init__(self, parent): SpyderPluginWidget.__init__(self, parent) # Widgets self.stack = QStackedWidget(self) self.stack.setStyleSheet("QStackedWidget{padding: 0px; border: 0px}") self.shellwidgets = {} # Layout layout = QGridLayout(self) layout.addWidget(self.stack)
def __init__(self, parent): SpyderPluginWidget.__init__(self, parent) # Widgets self.stack = QStackedWidget(self) self.shellwidgets = {} # Layout layout = QGridLayout(self) layout.addWidget(self.stack) # Initialize plugin self.initialize_plugin()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Widgets self._stack = QStackedWidget(self) self._shellwidgets = {} # Layout layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._stack) self.setLayout(layout)
def setupui(self): vbl = QVBoxLayout(self) self.stack = QStackedWidget(self) vbl.addWidget(self.stack) rbA = QRadioButton('Antennas', self) rbP = QRadioButton('Positions', self) rbA.toggled.connect(_part(self.toggle_button, 0)) rbP.toggled.connect(_part(self.toggle_button, 1)) self.radio_buttons.append(rbA) self.radio_buttons.append(rbP) rbA.setChecked(True) hbl = QHBoxLayout() hbl.addStretch() hbl.addWidget(rbA) hbl.addStretch() hbl.addWidget(rbP) hbl.addStretch() vbl.addItem(hbl) # ##### Antennas Widget ###### stack1 = QWidget(self.stack) self.stack.addWidget(stack1) vbl = QVBoxLayout(stack1) graph = self.create_graph(stack1, 'ant') vbl.addWidget(graph) stats = self.create_statistics(stack1, 'ant') vbl.addWidget(stats) # ##### Position and Amplitudes Widget ###### stack2 = QWidget(self.stack) self.stack.addWidget(stack2) vbl = QVBoxLayout(stack2) graph = self.create_graph(stack2, 'pos') vbl.addWidget(graph) graph = self.create_graph(stack2, 'amp') vbl.addWidget(graph) self.setStyleSheet(""" #SinglePassDataGraph{ min-width:48em; min-height:24em; } QLabel{ min-width:6em; max-width:6em; min-height:1.5em; max-height:1.5em; }""")
def __init__(self, parent): SpyderPluginWidget.__init__(self, parent) # Widgets self.stack = QStackedWidget(self) self.stack.setStyleSheet("QStackedWidget{padding: 0px; border: 0px}") self.shellwidgets = {} # Layout layout = QVBoxLayout() layout.addWidget(self.stack) self.setLayout(layout) # Initialize plugin self.initialize_plugin()
def __init__(self, parent): QWidget.__init__(self, parent) SpyderPluginMixin.__init__(self, parent) # Widgets self.stack = QStackedWidget(self) self.shellwidgets = {} # Layout layout = QVBoxLayout() layout.addWidget(self.stack) self.setLayout(layout) # Initialize plugin self.initialize_plugin()
def __init__( self, save_register: typing.Dict[str, type(SaveBase)], system_widget=True, base_values: typing.Optional[dict] = None, parent=None, history: typing.Optional[typing.List[str]] = None, file_mode=QFileDialog.AnyFile, ): super().__init__(parent) self.setFileMode(file_mode) self.save_register = { x.get_name_with_suffix(): x for x in save_register.values() } self.setOption(QFileDialog.DontUseNativeDialog, not system_widget) self.setAcceptMode(QFileDialog.AcceptSave) self.filterSelected.connect(self.change_filter) self.setNameFilters(self.save_register.keys()) self.accepted_native = False self.values = {} self.names = [] if history is not None: history = self.history() + history self.setHistory(history) self.base_values = base_values if base_values is not None else {} if not system_widget: widget = QStackedWidget() for name, val in self.save_register.items(): wi = FormWidget(val.get_fields()) if name in self.base_values: wi.set_values(self.base_values[name]) widget.addWidget(wi) self.names.append(name) self.filterSelected.connect(self.change_parameters) layout = self.layout() if isinstance(layout, QGridLayout): # print(layout.columnCount(), layout.rowCount()) # noinspection PyArgumentList layout.addWidget(widget, 0, layout.columnCount(), layout.rowCount(), 1) self.stack_widget = widget else: layout.addWidget(widget) self.stack_widget = widget self.selectNameFilter(self.names[0])
def __init__(self): runengine.initialize() deviceviewcontainer = DeviceView() devicelist = deviceviewcontainer.view controlsstack = QStackedWidget() devicelist.sigShowControl.connect(controlsstack.addSetWidget) self.stages = { 'Controls': GUILayout( controlsstack, left=devicelist, ), 'Plans': GUILayout(scripteditor(), left=devicelist), 'Run Engine': GUILayout(RunEngineWidget(), left=devicelist) } super(AcquirePlugin, self).__init__()
def __init__(self, parent): self.main = parent # Spyder3 # Widgets self.stack = QStackedWidget(self) self.shellwidgets = {} # Fallback widget when no MxConsole available. # Spyder 4 output internal error message without this. self.blankwidget = QLabel(text="No MxConsole Available") self.blankwidget.setAlignment(Qt.AlignCenter) self.stack.addWidget(self.blankwidget) # On active tab in IPython console change self.main.ipyconsole.tabwidget.currentChanged.connect( self.on_ipyconsole_current_changed)
def __init__(self, datalist, comment="", parent=None): QWidget.__init__(self, parent) layout = QVBoxLayout() self.setLayout(layout) self.combobox = QComboBox() layout.addWidget(self.combobox) self.stackwidget = QStackedWidget(self) layout.addWidget(self.stackwidget) self.combobox.currentIndexChanged.connect( self.stackwidget.setCurrentIndex) self.widgetlist = [] for data, title, comment in datalist: self.combobox.addItem(title) widget = FormWidget(data, comment=comment, parent=self) self.stackwidget.addWidget(widget) self.widgetlist.append(widget)
def __init__(self, parent=None): super().__init__(parent) self._list = QListWidget(self) self._stack = QStackedWidget(self) self._list.setObjectName("Preferences") # Set up buttons self._button_cancel = QPushButton(trans._("Cancel")) self._button_ok = QPushButton(trans._("OK")) self._default_restore = QPushButton(trans._("Restore defaults")) # Setup self.setWindowTitle(trans._("Preferences")) self._button_ok.setDefault(True) # Layout left_layout = QVBoxLayout() left_layout.addWidget(self._list) left_layout.addStretch() left_layout.addWidget(self._default_restore) left_layout.addWidget(self._button_cancel) left_layout.addWidget(self._button_ok) main_layout = QHBoxLayout() main_layout.addLayout(left_layout, 1) main_layout.addWidget(self._stack, 3) self.setLayout(main_layout) # Signals self._list.currentRowChanged.connect( lambda index: self._stack.setCurrentIndex(index)) self._button_cancel.clicked.connect(self.on_click_cancel) self._button_ok.clicked.connect(self.on_click_ok) self._default_restore.clicked.connect(self.restore_defaults) self.rejected.connect(self.on_click_cancel) # Make widget self.make_dialog() self._list.setCurrentRow(0)
def __init__(self, parent=None): super().__init__(parent) self.contentsWidget = QListWidget() self.pagesWidget = QStackedWidget() self.plotPref = PlotPreferences(parent) self.dataPref = DataPreferences(parent) self.pagesWidget.addWidget(self.plotPref) self.pagesWidget.addWidget(self.dataPref) self.contentsWidget.addItem("Plot") self.contentsWidget.addItem("Data") self.contentsWidget.currentItemChanged.connect(self.changePage) self.contentsWidget.setCurrentRow(0) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Close) okButton = self.buttonBox.button(QDialogButtonBox.Ok) okButton.clicked.connect(self.ok) applyButton = self.buttonBox.button(QDialogButtonBox.Apply) applyButton.clicked.connect(self.apply) closeButton = self.buttonBox.button(QDialogButtonBox.Close) closeButton.clicked.connect(self.close) horizontalLayout = QHBoxLayout() horizontalLayout.addWidget(self.contentsWidget) horizontalLayout.addWidget(self.pagesWidget) self.contentsWidget.setSizeAdjustPolicy( QAbstractScrollArea.AdjustToContents) mainLayout = QVBoxLayout() mainLayout.addLayout(horizontalLayout) mainLayout.addWidget(self.buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Preferences")
def setup(self, fname): """Setup Run Configuration dialog with filename *fname*""" combo_label = QLabel(_("Select a run configuration:")) self.combo = QComboBox() self.combo.setMaxVisibleItems(20) self.stack = QStackedWidget() configurations = _get_run_configurations() for index, (filename, options) in enumerate(configurations): if fname == filename: break else: # There is no run configuration for script *fname*: # creating a temporary configuration that will be kept only if # dialog changes are accepted by the user configurations.insert(0, (fname, RunConfiguration(fname).get())) index = 0 for filename, options in configurations: widget = RunConfigOptions(self) widget.set(options) widget.layout().setContentsMargins(0, 0, 0, 0) self.combo.addItem(filename) self.stack.addWidget(widget) self.combo.currentIndexChanged.connect(self.stack.setCurrentIndex) self.combo.setCurrentIndex(index) layout = self.add_widgets(combo_label, self.combo, 10, self.stack) widget_dialog = QWidget() widget_dialog.setLayout(layout) scrollarea = QScrollArea(self) scrollarea.setWidget(widget_dialog) scrollarea.setMinimumWidth(600) scrollarea.setWidgetResizable(True) scroll_layout = QVBoxLayout(self) scroll_layout.addWidget(scrollarea) self.add_button_box(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.setWindowTitle(_("Run configuration per file"))
def _load_core_widget(self): setting = self.params["setting"] hlayout = QHBoxLayout() list_widget = QListWidget() stacked_widget = QStackedWidget() for key in setting.keys(): list_widget.addItem(key) widget = QWidget() widget_layout = QVBoxLayout() for value in setting[key]: self._create_form(widget_layout, [value]) widget_layout.addStretch() widget.setLayout(widget_layout) stacked_widget.addWidget(widget) hlayout.addWidget(list_widget) hlayout.addWidget(stacked_widget) hlayout.setStretch(0, 1) hlayout.setStretch(1, 5) list_widget.currentRowChanged.connect(stacked_widget.setCurrentIndex) list_widget.setCurrentRow(0) return hlayout
def __init__(self, parent: MainWindow, renderers: List[Renderer]) -> None: """Initialize the Editor.""" super().__init__(parent=parent) self.renderers = renderers self.tree_widget = QTreeWidget() self.tree_widget.setHeaderHidden(True) self.stacked_widget = QStackedWidget() self.layout = QHBoxLayout() self.layout.addWidget(self.tree_widget) self.layout.addWidget(self.stacked_widget) def _selection_callback() -> None: for item in self.tree_widget.selectedItems(): widget_idx = item.data(0, Qt.ItemDataRole.UserRole) self.stacked_widget.setCurrentIndex(widget_idx) self.tree_widget.itemSelectionChanged.connect(_selection_callback) self.setLayout(self.layout) self.setWindowTitle("Editor") self.setModal(True) self.update()
def setup_and_check(self, data, title='', readonly=False, xlabels=None, ylabels=None): """ Setup ArrayEditor: return False if data is not supported, True otherwise """ self.data = data self.data.flags.writeable = True is_record_array = data.dtype.names is not None is_masked_array = isinstance(data, np.ma.MaskedArray) if data.ndim > 3: self.error( _("Arrays with more than 3 dimensions are not " "supported")) return False if xlabels is not None and len(xlabels) != self.data.shape[1]: self.error( _("The 'xlabels' argument length do no match array " "column number")) return False if ylabels is not None and len(ylabels) != self.data.shape[0]: self.error( _("The 'ylabels' argument length do no match array row " "number")) return False if not is_record_array: dtn = data.dtype.name if dtn not in SUPPORTED_FORMATS and not dtn.startswith('str') \ and not dtn.startswith('unicode'): arr = _("%s arrays") % data.dtype.name self.error(_("%s are currently not supported") % arr) return False self.layout = QGridLayout() self.setLayout(self.layout) self.setWindowIcon(ima.icon('arredit')) if title: title = to_text_string(title) + " - " + _("NumPy array") else: title = _("Array editor") if readonly: title += ' (' + _('read only') + ')' self.setWindowTitle(title) self.resize(600, 500) # Stack widget self.stack = QStackedWidget(self) if is_record_array: for name in data.dtype.names: self.stack.addWidget( ArrayEditorWidget(self, data[name], readonly, xlabels, ylabels)) elif is_masked_array: self.stack.addWidget( ArrayEditorWidget(self, data, readonly, xlabels, ylabels)) self.stack.addWidget( ArrayEditorWidget(self, data.data, readonly, xlabels, ylabels)) self.stack.addWidget( ArrayEditorWidget(self, data.mask, readonly, xlabels, ylabels)) elif data.ndim == 3: pass else: self.stack.addWidget( ArrayEditorWidget(self, data, readonly, xlabels, ylabels)) self.arraywidget = self.stack.currentWidget() if self.arraywidget: self.arraywidget.model.dataChanged.connect( self.save_and_close_enable) self.stack.currentChanged.connect(self.current_widget_changed) self.layout.addWidget(self.stack, 1, 0) # Buttons configuration btn_layout = QHBoxLayout() if is_record_array or is_masked_array or data.ndim == 3: if is_record_array: btn_layout.addWidget(QLabel(_("Record array fields:"))) names = [] for name in data.dtype.names: field = data.dtype.fields[name] text = name if len(field) >= 3: title = field[2] if not is_text_string(title): title = repr(title) text += ' - ' + title names.append(text) else: names = [_('Masked data'), _('Data'), _('Mask')] if data.ndim == 3: # QSpinBox self.index_spin = QSpinBox(self, keyboardTracking=False) self.index_spin.valueChanged.connect(self.change_active_widget) # QComboBox names = [str(i) for i in range(3)] ra_combo = QComboBox(self) ra_combo.addItems(names) ra_combo.currentIndexChanged.connect(self.current_dim_changed) # Adding the widgets to layout label = QLabel(_("Axis:")) btn_layout.addWidget(label) btn_layout.addWidget(ra_combo) self.shape_label = QLabel() btn_layout.addWidget(self.shape_label) label = QLabel(_("Index:")) btn_layout.addWidget(label) btn_layout.addWidget(self.index_spin) self.slicing_label = QLabel() btn_layout.addWidget(self.slicing_label) # set the widget to display when launched self.current_dim_changed(self.last_dim) else: ra_combo = QComboBox(self) ra_combo.currentIndexChanged.connect( self.stack.setCurrentIndex) ra_combo.addItems(names) btn_layout.addWidget(ra_combo) if is_masked_array: label = QLabel( _("<u>Warning</u>: changes are applied separately")) label.setToolTip(_("For performance reasons, changes applied "\ "to masked array won't be reflected in "\ "array's data (and vice-versa).")) btn_layout.addWidget(label) btn_layout.addStretch() if not readonly: self.btn_save_and_close = QPushButton(_('Save and Close')) self.btn_save_and_close.setDisabled(True) self.btn_save_and_close.clicked.connect(self.accept) btn_layout.addWidget(self.btn_save_and_close) self.btn_close = QPushButton(_('Close')) self.btn_close.setAutoDefault(True) self.btn_close.setDefault(True) self.btn_close.clicked.connect(self.reject) btn_layout.addWidget(self.btn_close) self.layout.addLayout(btn_layout, 2, 0) self.setMinimumSize(400, 300) # Make the dialog act as a window self.setWindowFlags(Qt.Window) return True
def setup_page(self): self.ICON = ima.icon('eyedropper') names = self.get_option("names") try: names.pop(names.index(u'Custom')) except ValueError: pass custom_names = self.get_option("custom_names", []) # Interface options theme_group = QGroupBox(_("Main interface")) # Interface Widgets ui_themes = ['Automatic', 'Light', 'Dark'] ui_theme_choices = list( zip(ui_themes, [ui_theme.lower() for ui_theme in ui_themes])) ui_theme_combo = self.create_combobox(_('Interface theme'), ui_theme_choices, 'ui_theme', restart=True) styles = [str(txt) for txt in list(QStyleFactory.keys())] # Don't offer users the possibility to change to a different # style in Gtk-based desktops # See spyder-ide/spyder#2036. if is_gtk_desktop() and ('GTK+' in styles): styles = ['GTK+'] choices = list(zip(styles, [style.lower() for style in styles])) style_combo = self.create_combobox(_('Qt windows style'), choices, 'windows_style', default=self.main.default_style) self.style_combobox = style_combo.combobox themes = ['Spyder 2', 'Spyder 3'] icon_choices = list(zip(themes, [theme.lower() for theme in themes])) icons_combo = self.create_combobox(_('Icon theme'), icon_choices, 'icon_theme', restart=True) theme_comboboxes_layout = QGridLayout() theme_comboboxes_layout.addWidget(ui_theme_combo.label, 0, 0) theme_comboboxes_layout.addWidget(ui_theme_combo.combobox, 0, 1) theme_comboboxes_layout.addWidget(style_combo.label, 1, 0) theme_comboboxes_layout.addWidget(self.style_combobox, 1, 1) theme_comboboxes_layout.addWidget(icons_combo.label, 2, 0) theme_comboboxes_layout.addWidget(icons_combo.combobox, 2, 1) theme_layout = QVBoxLayout() theme_layout.addLayout(theme_comboboxes_layout) theme_group.setLayout(theme_layout) # Syntax coloring options syntax_group = QGroupBox(_("Syntax highlighting theme")) # Syntax Widgets edit_button = QPushButton(_("Edit selected scheme")) create_button = QPushButton(_("Create new scheme")) self.delete_button = QPushButton(_("Delete scheme")) self.reset_button = QPushButton(_("Reset to defaults")) self.preview_editor = CodeEditor(self) self.stacked_widget = QStackedWidget(self) self.scheme_editor_dialog = SchemeEditor(parent=self, stack=self.stacked_widget) self.scheme_choices_dict = {} schemes_combobox_widget = self.create_combobox('', [('', '')], 'selected') self.schemes_combobox = schemes_combobox_widget.combobox # Syntax layout syntax_layout = QGridLayout(syntax_group) btns = [ self.schemes_combobox, edit_button, self.reset_button, create_button, self.delete_button ] for i, btn in enumerate(btns): syntax_layout.addWidget(btn, i, 1) syntax_layout.setColumnStretch(0, 1) syntax_layout.setColumnStretch(1, 2) syntax_layout.setColumnStretch(2, 1) syntax_layout.setContentsMargins(0, 12, 0, 12) # Fonts options fonts_group = QGroupBox(_("Fonts")) # Fonts widgets plain_text_font = self.create_fontgroup( option='font', title=_("Plain text"), fontfilters=QFontComboBox.MonospacedFonts, without_group=True) rich_text_font = self.create_fontgroup(option='rich_font', title=_("Rich text"), without_group=True) # Fonts layouts fonts_layout = QGridLayout(fonts_group) fonts_layout.addWidget(plain_text_font.fontlabel, 0, 0) fonts_layout.addWidget(plain_text_font.fontbox, 0, 1) fonts_layout.addWidget(plain_text_font.sizelabel, 0, 2) fonts_layout.addWidget(plain_text_font.sizebox, 0, 3) fonts_layout.addWidget(rich_text_font.fontlabel, 1, 0) fonts_layout.addWidget(rich_text_font.fontbox, 1, 1) fonts_layout.addWidget(rich_text_font.sizelabel, 1, 2) fonts_layout.addWidget(rich_text_font.sizebox, 1, 3) fonts_layout.setRowStretch(fonts_layout.rowCount(), 1) # Left options layout options_layout = QVBoxLayout() options_layout.addWidget(theme_group) options_layout.addWidget(syntax_group) options_layout.addWidget(fonts_group) # Right preview layout preview_group = QGroupBox(_("Preview")) preview_layout = QVBoxLayout() preview_layout.addWidget(self.preview_editor) preview_group.setLayout(preview_layout) # Combined layout combined_layout = QGridLayout() combined_layout.setRowStretch(0, 1) combined_layout.setColumnStretch(1, 100) combined_layout.addLayout(options_layout, 0, 0) combined_layout.addWidget(preview_group, 0, 1) self.setLayout(combined_layout) # Signals and slots create_button.clicked.connect(self.create_new_scheme) edit_button.clicked.connect(self.edit_scheme) self.reset_button.clicked.connect(self.reset_to_default) self.delete_button.clicked.connect(self.delete_scheme) self.schemes_combobox.currentIndexChanged.connect(self.update_preview) self.schemes_combobox.currentIndexChanged.connect(self.update_buttons) # Setup for name in names: self.scheme_editor_dialog.add_color_scheme_stack(name) for name in custom_names: self.scheme_editor_dialog.add_color_scheme_stack(name, custom=True) self.update_combobox() self.update_preview() self.update_qt_style_combobox()
def __init__(self, napari_viewer: Viewer, parent: Optional[QWidget] = None): super(IMCWidget, self).__init__(parent) self._controller = IMCController(napari_viewer, self) self._imc_file_tree_model = IMCFileTreeModel(self._controller, parent=self) self._imc_file_tree_view = IMCFileTreeView(parent=self) self._imc_file_tree_view.setModel(self._imc_file_tree_model) self._channel_table_model = ChannelTableModel(self._controller, parent=self) self._channel_table_proxy_model = QSortFilterProxyModel(self) self._channel_table_proxy_model.setSourceModel( self._channel_table_model) self._channel_table_proxy_model.sort( self._channel_table_model.LABEL_COLUMN) self._channel_table_view = ChannelTableView(parent=self) self._channel_table_view.setModel(self._channel_table_proxy_model) self._channel_controls_widget = ChannelControlsWidget(self._controller, parent=self) self._channel_controls_container = QStackedWidget(self) self._channel_controls_container.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self._channel_controls_container.addWidget(QWidget(self)) self._channel_controls_container.addWidget( self._channel_controls_widget) layout = QVBoxLayout(self) splitter = QSplitter(Qt.Vertical, self) splitter.addWidget(self._imc_file_tree_view) channel_panel = QWidget(self) channel_panel_layout = QVBoxLayout() channel_panel_layout.addWidget(self._channel_table_view) channel_panel_layout.addWidget(self._channel_controls_container) channel_panel.setLayout(channel_panel_layout) splitter.addWidget(channel_panel) layout.addWidget(splitter) self.setLayout(layout) # noinspection PyUnusedLocal # noinspection PyUnresolvedReferences @self._imc_file_tree_model.dataChanged.connect def on_imc_file_tree_model_data_changed(top_left: QModelIndex, bottom_right: QModelIndex, roles: Optional[int] = None): item = top_left.internalPointer() if isinstance(item, IMCFilePanoramaModel): if item.is_shown: self._controller.hide_imc_file_panorama(item) else: self._controller.show_imc_file_panorama(item) elif isinstance(item, IMCFileAcquisitionModel): if item.is_loaded: self._controller.unload_imc_file_acquisition(item) else: self._controller.load_imc_file_acquisition(item) # noinspection PyUnresolvedReferences @self._imc_file_tree_view.events.imc_file_closed.connect def on_imc_file_tree_view_imc_file_closed(imc_file: IMCFileModel): self._controller.close_imc_file(imc_file) # noinspection PyUnusedLocal # noinspection PyUnresolvedReferences @self._channel_table_model.dataChanged.connect def on_channel_table_model_data_changed(top_left: QModelIndex, bottom_right: QModelIndex, roles: Optional[int] = None): channel = self._controller.channels[top_left.row()] if channel.is_shown: self._controller.hide_channel(channel) else: self._controller.show_channel(channel) channel_table_selection_model: QItemSelectionModel = self._channel_table_view.selectionModel( ) # noinspection PyUnusedLocal # noinspection PyUnresolvedReferences @channel_table_selection_model.selectionChanged.connect def on_channel_table_view_selection_changed( selected: QItemSelection, deselected: QItemSelection): selected_channels = [] for index in self._channel_table_view.selectedIndexes(): index = self._channel_table_proxy_model.mapToSource(index) channel = self._controller.channels[index.row()] selected_channels.append(channel) self._controller.selected_channels = selected_channels
def __init__(self, parent, max_entries=100): "Initialize Various list objects before assignment" displaylist = [] displaynamelist = [] infixmod = [] infixlist = [] desclist = [] parameternamelist = [] parameterdesclist = [] buttonlist = [] xmldoc = minidom.parse( os.path.dirname(os.path.abspath(__file__)) + '\\ratelaw2_0_3.xml') lawlistxml = xmldoc.getElementsByTagName('law') o = 0 for s in lawlistxml: o = o + 1 parameternamelistlist = [0 for x in range(o)] parameterdesclistlist = [0 for x in range(o)] """i is the number of laws currently in the xml file""" i = 0 """ Parsing xml: Acquiring rate law name, description, and list of parameter information """ for s in lawlistxml: """Gets Latec Expression""" displaylist.append(s.getAttribute('display')) """Gets Rate-Law Name""" displaynamelist.append(s.getAttribute('displayName')) """"Gets Raw Rate-Law expression""" infixlist.append(s.getAttribute('infixExpression')) """Gets description statement""" desclist.append(s.getAttribute('description')) """Gets listOfParameters Object""" parameterlist = s.getElementsByTagName('listOfParameters')[0] """Gets a list of parameters within ListOfParameters object""" parameters = parameterlist.getElementsByTagName('parameter') for param in parameters: parameternamelist.append(param.attributes['name'].value) parameterdesclist.append(param.attributes['description'].value) parameternamelistlist[i] = parameternamelist parameterdesclistlist[i] = parameterdesclist parameternamelist = [] parameterdesclist = [] i = i + 1 SLElistlist = [0 for x in range(i)] PLElistlist = [0 for x in range(i)] ILElistlist = [0 for x in range(i)] paramLElistlist = [0 for x in range(i)] numlistlist = [0 for x in range(i)] QWidget.__init__(self, parent) self.setWindowTitle("Rate Law Library") self.output = None self.error_output = None self._last_wdir = None self._last_args = None self._last_pythonpath = None self.lawlist = QListWidget() self.lawpage = QStackedWidget() for j in range(i): item = QListWidgetItem(displaynamelist[j]) self.lawlist.addItem(item) self.lawdetailpage = QWidget() setup_group = QGroupBox(displaynamelist[j]) infixmod.append(infixlist[j].replace("___", " ")) setup_label = QLabel(infixmod[j]) setup_label.setWordWrap(True) desc_group = QGroupBox("Description") desc_label = QLabel(desclist[j]) desc_label.setWordWrap(True) param_label = QGridLayout() nm = QLabel("Name:") des = QLabel("Description:") repl = QLabel("Replace with:") param_label.addWidget(nm, 0, 0) param_label.addWidget(des, 0, 1) param_label.addWidget(repl, 0, 2) """g is the total number of alterable values""" """t is the total number of alterable non-parameters""" t = 1 snum = 0 pnum = 0 inum = 0 """range of N is the max number of possible substrates OR products""" N = 5 for n in range(N): nl = n + 1 if (infixmod[j].find('S%s' % nl) > -1): z = QLabel('S%s is present' % nl) param_label.addWidget(z, t, 0) snum = snum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('P%s' % nl) > -1): z = QLabel('P%s is present' % nl) param_label.addWidget(z, t, 0) pnum = pnum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('I%s' % nl) > -1): z = QLabel('I%s is present' % nl) param_label.addWidget(z, t, 0) inum = inum + 1 t = t + 1 """Initialize lists of list of parameter lineedit""" length = len(parameternamelistlist[j]) for b in range(length): p = QLabel("%s :" % parameternamelistlist[j][b]) param_label.addWidget(p, b + t, 0) d = QLabel("'%s'" % parameterdesclistlist[j][b]) param_label.addWidget(d, b + t, 1) Slineeditlist = [0 for x in range(snum)] Plineeditlist = [0 for x in range(pnum)] Ilineeditlist = [0 for x in range(inum)] paramlineeditlist = [0 for x in range(length)] editcount = 1 """Place lineedit widgets for parameters""" for s in range(snum): Slineeditlist[s] = QLineEdit() param_label.addWidget(Slineeditlist[s], editcount, 2) editcount = editcount + 1 SLElistlist[j] = Slineeditlist for s in range(pnum): Plineeditlist[s] = QLineEdit() param_label.addWidget(Plineeditlist[s], editcount, 2) editcount = editcount + 1 PLElistlist[j] = Plineeditlist for s in range(inum): Ilineeditlist[s] = QLineEdit() param_label.addWidget(Ilineeditlist[s], editcount, 2) editcount = editcount + 1 ILElistlist[j] = Ilineeditlist for s in range(length): paramlineeditlist[s] = QLineEdit() param_label.addWidget(paramlineeditlist[s], editcount, 2) editcount = editcount + 1 paramLElistlist[j] = paramlineeditlist """Necessary lists for editable parameters. Housekeeping essentially.""" numlistlist[j] = [snum, pnum, inum, length] charlist = ["S", "P", "I"] buttonlist.append(QPushButton(self)) buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j]) # Warning: do not try to regroup the following QLabel contents with # widgets above -- this string was isolated here in a single QLabel # on purpose: to fix Issue 863 """Page formatting""" setup_layout = QVBoxLayout() setup_layout.addWidget(setup_label) setup_group.setLayout(setup_layout) desc_group.setLayout(param_label) vlayout2 = QVBoxLayout() vlayout2.addWidget(setup_group) vlayout2.addWidget(desc_group) vlayout2.addWidget(buttonlist[j]) vlayout2.addStretch(1) self.lawdetailpage.setLayout(vlayout2) self.lawpage.addWidget(self.lawdetailpage) """Set up button functionality""" for k in range(47): buttonlist[k].clicked.connect( self.pressbutton(infixmod[k], SLElistlist[k], PLElistlist[k], ILElistlist[k], paramLElistlist[k], parameternamelistlist[k], numlistlist[k], charlist, k)) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) self.lawlist.setCurrentRow(0) self.lawlist.setMinimumWidth(self.lawlist.sizeHintForColumn(0)) """Set up high-level widget formatting.""" hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
def __init__(self): super(XicamMainWindow, self).__init__() # Set icon self.setWindowIcon(QIcon(QPixmap(str(path("icons/xicam.gif"))))) # Set size and position self.setGeometry(0, 0, 1000, 600) frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) # Init child widgets to None self.topwidget = (self.leftwidget) = (self.rightwidget) = ( self.bottomwidget ) = self.lefttopwidget = self.righttopwidget = self.leftbottomwidget = self.rightbottomwidget = None # Setup appearance self.setWindowTitle("Xi-cam") self.load_style() # Attach an object to restore config when loaded self._config_restorer = ConfigRestorer() # Load plugins pluginmanager.qt_is_safe = True pluginmanager.initialize_types() pluginmanager.collect_plugins() pluginmanager.collect_user_plugins() # Setup center/toolbar/statusbar/progressbar self.pluginmodewidget = pluginModeWidget() self.pluginmodewidget.sigSetStage.connect(self.setStage) self.pluginmodewidget.sigSetGUIPlugin.connect(self.setGUIPlugin) self.addToolBar(self.pluginmodewidget) self.setStatusBar(QStatusBar(self)) msg.progressbar = QProgressBar(self) msg.progressbar.hide() msg.statusbar = self.statusBar() self.statusBar().addPermanentWidget(msg.progressbar) self.setCentralWidget(QStackedWidget()) # NOTE: CentralWidgets are force-deleted when replaced, even if the object is still referenced; # To avoid this, a QStackedWidget is used for the central widget. # Setup menubar menubar = DebuggableMenuBar() self.setMenuBar(menubar) file = QMenu("&File", parent=menubar) plugins = QMenu("&Plugins", parent=menubar) menubar.addMenu(file) file.addAction("Se&ttings", self.showSettings, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_S)) file.addAction("E&xit", self.close) menubar.addMenu(plugins) plugins.addAction("Open User &Plugin Directory", self.openUserPluginDir, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_P)) # Set up help help = QMenu("&Help", parent=menubar) documentation_link = QUrl("https://xi-cam.readthedocs.io/en/latest/") help.addAction("Xi-CAM &Help", lambda: QDesktopServices.openUrl(documentation_link)) slack_link = QUrl("https://nikea.slack.com") help.addAction("Chat on &Slack", lambda: QDesktopServices.openUrl(slack_link)) help.addSeparator() about_title = "About Xi-CAM" version_text = f"""Version: <strong>{version.get_versions()['version']}</strong>""" copyright_text = f"""<small>Copyright (c) 2016, The Regents of the University of California, \ through Lawrence Berkeley National Laboratory \ (subject to receipt of any required approvals from the U.S. Dept. of Energy). \ All rights reserved.</small>""" funding_text = f"""Funding for this research was provided by: \ Lawrence Berkeley National Laboratory (grant No. TReXS LDRD to AH); \ US Department of Energy (award No. Early Career Award to AH; \ contract No. DE-SC0012704; contract No. DE-AC02-06CH11357; \ contract No. DE-AC02-76SF00515; contract No. DE-AC02-05CH11231); \ Center for Advanced Mathematics in Energy Research Applications; \ Light Source Directors Data Solution Task Force Pilot Project.""" about_text = version_text + "<br><br>" + funding_text + "<br><hr>" + copyright_text about_box = QMessageBox(QMessageBox.NoIcon, about_title, about_text) about_box.setTextFormat(Qt.RichText) about_box.setWindowModality(Qt.NonModal) help.addAction("&About Xi-CAM", lambda: about_box.show()) help.addSeparator() help.addAction(QWhatsThis.createAction(help)) menubar.addMenu(help) # Initialize layout with first plugin self._currentGUIPlugin = None self.build_layout() # self._currentGUIPlugin = pluginmanager.getPluginsOfCategory("GUIPlugin")[0] self.populate_layout() # Make F key bindings fkeys = [ Qt.Key_F1, Qt.Key_F2, Qt.Key_F3, Qt.Key_F4, Qt.Key_F5, Qt.Key_F6, Qt.Key_F7, Qt.Key_F8, Qt.Key_F9, Qt.Key_F10, Qt.Key_F11, Qt.Key_F12, ] self.Fshortcuts = [QShortcut(QKeySequence(key), self) for key in fkeys] for i in range(12): self.Fshortcuts[i].activated.connect(partial(self.setStage, i)) self.readSettings() # Wireup default widgets get_default_stage()["left"].sigOpen.connect(self.open) get_default_stage()["left"].sigOpen.connect(print) get_default_stage()["left"].sigPreview.connect( get_default_stage()["lefttop"].preview)
def __init__(self): super(XicamMainWindow, self).__init__() # Set icon self.setWindowIcon(QIcon(QPixmap(str(path("icons/xicam.gif"))))) # Set size and position self.setGeometry(0, 0, 1000, 600) frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) # Init child widgets to None self.topwidget = (self.leftwidget) = (self.rightwidget) = ( self.bottomwidget ) = self.lefttopwidget = self.righttopwidget = self.leftbottomwidget = self.rightbottomwidget = None # Setup appearance self.setWindowTitle("Xi-cam") self._configdialog = ConfigDialog() # Load plugins pluginmanager.collect_plugins() # Setup center/toolbar/statusbar/progressbar self.pluginmodewidget = pluginModeWidget() self.pluginmodewidget.sigSetStage.connect(self.setStage) self.pluginmodewidget.sigSetGUIPlugin.connect(self.setGUIPlugin) self.addToolBar(self.pluginmodewidget) self.setStatusBar(QStatusBar(self)) msg.progressbar = QProgressBar(self) msg.progressbar.hide() msg.statusbar = self.statusBar() self.statusBar().addPermanentWidget(msg.progressbar) self.setCentralWidget(QStackedWidget()) # NOTE: CentralWidgets are force-deleted when replaced, even if the object is still referenced; # To avoid this, a QStackedWidget is used for the central widget. # Setup menubar menubar = DebuggableMenuBar() self.setMenuBar(menubar) file = QMenu("&File", parent=menubar) menubar.addMenu(file) file.addAction("Se&ttings", self.showSettings, shortcut=QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_S)) file.addAction("E&xit", self.close) help = QMenu("&Help", parent=menubar) menubar.addMenu(help) # Initialize layout with first plugin self._currentGUIPlugin = None self.build_layout() # self._currentGUIPlugin = pluginmanager.getPluginsOfCategory("GUIPlugin")[0] self.populate_layout() # Make F key bindings fkeys = [ Qt.Key_F1, Qt.Key_F2, Qt.Key_F3, Qt.Key_F4, Qt.Key_F5, Qt.Key_F6, Qt.Key_F7, Qt.Key_F8, Qt.Key_F9, Qt.Key_F10, Qt.Key_F11, Qt.Key_F12, ] self.Fshortcuts = [QShortcut(QKeySequence(key), self) for key in fkeys] for i in range(12): self.Fshortcuts[i].activated.connect(partial(self.setStage, i)) self.readSettings() # Wireup default widgets defaultstage["left"].sigOpen.connect(self.open) defaultstage["left"].sigOpen.connect(print) defaultstage["left"].sigPreview.connect( defaultstage["lefttop"].preview)