def __init__(self, bench, parent_container): """ Container which layouts its child items on stacked layout and provides a tab bar. :param bench: :param parent_container: """ super(TabContainer, self).__init__(bench, parent_container) self.setAcceptDrops(True) self.refDropRegions = None self.absDropRegions = None self.overlay = DropOverlay(self) self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) if CONFIG.debug_layout: self.layout.setContentsMargins(2, 16, 2, 2) self.setLayout(self.layout) self._tabbar = TabHeader() self.layout.addWidget(self._tabbar) self._dockstack = QStackedLayout() self._dockstack.setContentsMargins(0, 0, 0, 0) self._dockstack.setSpacing(0) self.layout.addLayout(self._dockstack)
def setupui(self): vbl = QGridLayout(self) lab = QLabel('<h2>' + self.bpm + ' Triggered Acquisitions</h2>') lab.setAlignment(Qt.AlignCenter) vbl.addWidget(lab, 0, 0, 1, 2) self.stack = QStackedLayout() multi_pass = MultiTurnData(parent=self, acq_type='ACQ', prefix=self.prefix, bpm=self.bpm) multi_pass.setObjectName('multi_pass') single_pass = SinglePassData(parent=self, prefix=self.prefix, bpm=self.bpm) single_pass.setObjectName('single_pass') self.stack.addWidget(multi_pass) self.stack.addWidget(single_pass) vbl.addLayout(self.stack, 1, 0) config = ACQTrigConfigs(parent=self, prefix=self.prefix, bpm=self.bpm, data_prefix='ACQ') config.setObjectName('config') vbl.addWidget(config, 1, 1) self.setStyleSheet(""" #multi_pass{ min-width:50em; min-height:48em;} #single_pass{ min-width:50em; min-height:48em;} #config{ min-height:21em;}""")
def __init__(self, name=None, plugin=None, parent=None, options=DEFAULT_OPTIONS): super().__init__(name, plugin, parent, options) # Attributes self._starting_up = True self._current_color_scheme = None self._last_texts = [None, None] self._last_editor_doc = None self._last_console_cb = None self._last_editor_cb = None self.css_path = self.get_option('css_path') self.no_docs = _("No documentation available") self.docstring = True # TODO: What is this used for? # Widgets self._sphinx_thread = SphinxThread( html_text_no_doc=warning(self.no_docs, css_path=self.css_path), css_path=self.css_path, ) self.shell = None self.internal_console = None self.internal_shell = None self.plain_text = PlainText(self) self.rich_text = RichText(self) self.source_label = QLabel(_("Source")) self.source_combo = QComboBox(self) self.object_label = QLabel(_("Object")) self.object_combo = ObjectComboBox(self) self.object_edit = QLineEdit(self) # Setup self.object_edit.setReadOnly(True) self.object_combo.setMaxCount(self.get_option('max_history_entries')) self.object_combo.setItemText(0, '') self.plain_text.set_wrap_mode(self.get_option('wrap')) self.source_combo.addItems([_("Console"), _("Editor")]) if (not programs.is_module_installed('rope') and not programs.is_module_installed('jedi', '>=0.11.0')): self.source_combo.hide() self.source_label.hide() # Layout self.stack_layout = layout = QStackedLayout() layout.addWidget(self.rich_text) layout.addWidget(self.plain_text) self.setLayout(layout) # Signals self._sphinx_thread.html_ready.connect( self._on_sphinx_thread_html_ready) self._sphinx_thread.error_msg.connect( self._on_sphinx_thread_error_msg) self.object_combo.valid.connect(self.force_refresh) self.rich_text.sig_link_clicked.connect(self.handle_link_clicks) self.source_combo.currentIndexChanged.connect( lambda x: self.source_changed()) self.sig_render_started.connect(self.start_spinner) self.sig_render_finished.connect(self.stop_spinner)
def __init__(self, parent=None): super(RedisEditor, self).__init__(parent) self.empty = QWidget(self) self.item = RedisItemEditor(self) self.db = RedisDbEditor(self) self.db.setWindowFlags(Qt.Widget) layout = QStackedLayout(self) layout.addWidget(self.empty) layout.addWidget(self.item) layout.addWidget(self.db)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) panel_layout = QStackedLayout() panel_layout.setSizeConstraint(QLayout.SetMaximumSize) panel_layout.setContentsMargins (0,0,0,0) self.setLayout(panel_layout) # cache the line lists for speedier access linelist.populate_linelists_cache() self.hub.workspace.mdi_area.subWindowActivated.connect(self._plot_selected)
def __init__(self, parent=None): super(RedisItemEditor, self).__init__(parent) self.load_ui() self.__original_item = None self.__item = None ui = self.ui layout = QStackedLayout(ui.type_editor) layout.setContentsMargins(3, 3, 3, 3) self.none_editor = QWidget() self.simple_editor = SimpleEditor() self.hash_editor = MultiEditor() self.seq_editor = MultiEditor() self.seq_editor.ui.table.horizontalHeader().setVisible(False) self.set_editor = MultiEditor() self.set_editor.ui.table.horizontalHeader().setVisible(False) layout.addWidget(self.none_editor) layout.addWidget(self.simple_editor) layout.addWidget(self.hash_editor) layout.addWidget(self.seq_editor) layout.addWidget(self.set_editor) self.type_editor_map = { "none": self.none_editor, "string": self.simple_editor, "hash": self.hash_editor, "list": self.seq_editor, "set": self.set_editor, } ttl_validator = QIntValidator() ttl_validator.setBottom(-1) ui.ttl_value.setValidator(ttl_validator) ui.key_name.textChanged.connect(self.__on_key_name_changed) ui.key_name.returnPressed.connect(self.__on_key_name_applied) ui.ttl_value.textChanged.connect(self.__on_ttl_changed) ui.ttl_value.returnPressed.connect(self.__on_ttl_applied) ui.apply_button.clicked.connect(self.__on_apply) ui.refresh_button.clicked.connect(self.__on_refresh) ui.undo_button.clicked.connect(self.__on_undo) ui.persist_button.clicked.connect(self.__on_persist) ui.delete_button.clicked.connect(self.__on_delete)
def __init__( self, settings: BaseSettings, algorithms: typing.Dict[str, typing.Type[SegmentationAlgorithm]], parent=None ): super().__init__(parent) self.settings = settings self.algorithms = algorithms settings.algorithm_changed.connect(self.updated_algorithm) self.stack_layout = QStackedLayout() self.algorithm_choose = QComboBox() self.algorithm_dict: typing.Dict[str, BaseAlgorithmSettingsWidget] = {} self.algorithm_choose.currentTextChanged.connect(self.change_algorithm) self.add_widgets_to_algorithm() self.settings.image_changed.connect(self.image_changed) # self.setMinimumWidth(370) self.setContentsMargins(0, 0, 0, 0) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.algorithm_choose) layout.addLayout(self.stack_layout) self.setLayout(layout)
def setup_ui(self): """Initialize widgets.""" def switch_style(i): view = self.landscape_view if self.view_mode == MainApp.LANDSCAPE else self.portrait_view self.style_changed.emit(self.styles[i]) view.selected_style = self.styles[i] for i in range(min(len(self.styles), len(settings.STYLE_SHORTCUTS))): QShortcut(QKeySequence(settings.STYLE_SHORTCUTS[i]), self, lambda x=i: switch_style(x)) self.landscape_view = LandscapeView(self.styles) self.landscape_view.style_changed.connect(self.style_button_clicked) self.landscape_view.toggle_fullscreen_signal.connect( self.toggle_fullscreen) self.landscape_view.quality_changed.connect(self.quality_choice) self.portrait_view = PortraitView(self.styles) self.portrait_view.style_changed.connect(self.style_button_clicked) self.portrait_view.toggle_fullscreen_signal.connect( self.toggle_fullscreen) self.portrait_view.quality_changed.connect(self.quality_choice) self.main_layout = QStackedLayout() self.main_layout.addWidget(self.landscape_view) self.main_layout.addWidget(self.portrait_view) self.setLayout(self.main_layout) self.view_mode = MainApp.LANDSCAPE self.setStyleSheet('background-color:black;' 'font-family: Arial;' 'font-style: normal;' 'font-size: 12pt;' 'font-weight: bold;' 'color:white;') self.setWindowTitle('Stylize')
def setup_ui(self): self.main_layout = QGridLayout() self.setLayout(self.main_layout) # add toolbar self.toolbar = QToolBar() self.main_layout.setMenuBar(self.toolbar) # create the tree view layout and add/remove buttons self.tree_view_layout = QVBoxLayout() self.tree_view = PyDMAlarmTree(self, config_name="UNITITLED", edit_mode=True) self.tree_view.setEditTriggers(QAbstractItemView.DoubleClicked) self.tree_view.setSelectionMode(QAbstractItemView.SingleSelection) self.tree_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.tree_view.setHeaderHidden(True) # Drag/drop self.tree_view.setDragDropMode(QAbstractItemView.InternalMove) self.tree_view.setDragEnabled(True) self.tree_view.setAcceptDrops(True) # view sizing self.tree_view.setColumnWidth(0, 160) self.tree_view.setColumnWidth(1, 160) self.tree_view.setColumnWidth(2, 160) # lable for tree view configuration_indicator = QLabel("Configuration:") self.tree_label = QLineEdit("Untitled") self.tree_label_layout = QHBoxLayout() self.tree_label_layout.addWidget(configuration_indicator) self.tree_label_layout.addWidget(self.tree_label) self.tree_view_layout.addLayout(self.tree_label_layout) self.tree_view_layout.addWidget(self.tree_view) # add/ remove buttons self.add_remove_layout = QHBoxLayout() spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.add_remove_layout.addItem(spacer) self.add_button = QPushButton("New", self) self.add_remove_layout.addWidget(self.add_button) self.remove_button = QPushButton("Remove", self) self.add_remove_layout.addWidget(self.remove_button) self.tree_view_layout.addLayout(self.add_remove_layout) # add the tree view to the window self.main_layout.addLayout(self.tree_view_layout, 0, 0) self.property_layout = QVBoxLayout() self.property_layout.addWidget(QLabel("Alarm Properties")) # crate property view self.property_data_layout = QStackedLayout() self.property_layout.addLayout(self.property_data_layout) self.property_widget_config = QWidget() self.property_widget_config.setWindowTitle("config") # create group widget self.property_widget_group = QWidget() self.property_widget_group.setWindowTitle("group") self.property_view_layout_group = QGridLayout() # add label self.label_edit_group = QLineEdit() self.label_label_group = QLabel("NAME") # add guidance self.guidance_edit_group = QLineEdit() self.guidance_label_group = QLabel("GUIDANCE") self.property_view_layout_group.addWidget(self.label_label_group, 1, 0) self.property_view_layout_group.addWidget(self.label_edit_group, 1, 1) self.property_view_layout_group.addWidget(self.guidance_label_group, 2, 0) self.property_view_layout_group.addWidget(self.guidance_edit_group, 2, 1) spacer = QSpacerItem(40, 200, QSizePolicy.Expanding, QSizePolicy.Minimum) self.property_view_layout_group.addItem(spacer, 3, 0) self.property_view_layout_group.addItem(spacer, 4, 0) self.property_view_layout_group.addItem(spacer, 5, 0) self.property_view_layout_group.addItem(spacer, 6, 0) self.property_view_layout_group.addItem(spacer, 7, 0) self.property_view_layout_group.addItem(spacer, 8, 0) # create pv widget self.property_widget_pv = QWidget() self.property_widget_pv.setWindowTitle("pv") self.property_view_layout_pv = QGridLayout() # add label self.label_edit_pv = QLineEdit() self.label_label_pv = QLabel("NAME") # add guidance self.guidance_edit_pv = QLineEdit() self.guidance_label_pv = QLabel("GUIDANCE") self.property_view_layout_pv.addWidget(self.label_label_pv, 1, 0) self.property_view_layout_pv.addWidget(self.label_edit_pv, 1, 1, 1, 3) self.property_view_layout_pv.addWidget(self.guidance_label_pv, 2, 0) self.property_view_layout_pv.addWidget(self.guidance_edit_pv, 2, 1, 1, 3) # add description self.description_edit = QLineEdit() self.description_label = QLabel("DESCRIPTION") self.property_view_layout_pv.addWidget(self.description_label, 3, 0) self.property_view_layout_pv.addWidget(self.description_edit, 3, 1, 1, 3) # add delay self.delay_edit = QLineEdit() self.delay_label = QLabel("DELAY") self.property_view_layout_pv.addWidget(self.delay_label, 4, 0) self.property_view_layout_pv.addWidget(self.delay_edit, 4, 1, 1, 3) self.delay_edit.setValidator(QIntValidator()) # add count self.count_edit = QLineEdit() self.count_label = QLabel("COUNT") self.property_view_layout_pv.addWidget(self.count_label, 5, 0) self.property_view_layout_pv.addWidget(self.count_edit, 5, 1, 1, 3) self.count_edit.setValidator(QIntValidator()) # add filter/force pv self.filter_edit = QLineEdit() self.filter_label = QLabel("ENABLING FILTER") self.property_view_layout_pv.addWidget(self.filter_label, 6, 0) self.property_view_layout_pv.addWidget(self.filter_edit, 6, 1, 1, 3) # enabled, latching, annunciating self.enabled_check = QCheckBox("ENABLED") self.annunciating_check = QCheckBox("ANNUNCIATING") self.latching_check = QCheckBox("LATCHING") self.property_view_layout_pv.addWidget(self.enabled_check, 7, 0) self.property_view_layout_pv.addWidget(self.annunciating_check, 7, 1) self.property_view_layout_pv.addWidget(self.latching_check, 7, 2) self.property_view_layout_pv.addItem(spacer, 8, 0) # create save button self.button_box = QDialogButtonBox(self) self.button_box.setOrientation(Qt.Horizontal) self.button_box.addButton("Save Properties", QDialogButtonBox.AcceptRole) self.property_layout.addWidget(self.button_box) # self.property_layout.addLayout(self.property_view_layout) self.property_widget_pv.setLayout(self.property_view_layout_pv) self.property_widget_group.setLayout(self.property_view_layout_group) self.property_data_layout.addWidget(self.property_widget_config) self.property_data_layout.addWidget(self.property_widget_pv) self.property_data_layout.addWidget(self.property_widget_group) self.main_layout.addLayout(self.property_layout, 0, 1) self.setWindowTitle("Alarm Tree Editor") self.tree_view.expandAll()
def _setupUi(self): # Leds Panel cw = QWidget(self) panel = QWidget(cw) panel_lay = QGridLayout() panel_lay.setVerticalSpacing(0) panel_lay.setHorizontalSpacing(5) panel.setLayout(panel_lay) # # Leds Header for i, lab in enumerate([ '', 'PS\nConn?', 'Power\nState', 'Interlock', 'OpMode\nSlowRef?', 'Current\nDiff']): label = QLabel(lab, panel, alignment=Qt.AlignCenter) label.setStyleSheet('min-width:3.4em; max-width:3.4em;') panel_lay.addWidget(label, 0, i) # # Leds panel _on = _PSConst.PwrStateSts.On _slowref = _PSConst.States.SlowRef _rmpwfm = _PSConst.States.RmpWfm i = 2 for sec in ['LI', 'TB', 'BO', 'TS', 'SI']: seclabel = QLabel('<h3>'+sec+'</h3>', panel) panel_lay.addWidget(seclabel, i, 0) i += 1 if sec == 'LI': for label, filt in lips2filters.items(): ps_label = QLabel( label, panel, alignment=Qt.AlignRight | Qt.AlignVCenter) psnames = PSSearch.get_psnames(filters=filt) ps_c2v = dict() ilk_c2v = dict() conn_chs = list() for name in psnames: pvn = _PVName(name).substitute(prefix=self._prefix) conn_chs.append(pvn.substitute(propty='PwrState-Sts')) ps_c2v[pvn.substitute(propty='PwrState-Sts')] = 1 ilk_c2v[pvn.substitute(propty='StatusIntlk-Mon')] = \ {'value': _PS_LI_INTLK, 'comp': 'lt'} f = 'LI-.*:PS-'+filt['dev'] conn_led = MyLedMultiConnection( filters=f, parent=panel, channels=conn_chs) ps_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=ps_c2v) if 'Spect' in filt['dev']: intlk_led = LISpectIntlkLed(panel, filters=f) else: intlk_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=ilk_c2v) suf = sec+filt['dev'].strip('.*')+'_led' conn_led.setObjectName('conn' + suf) ps_led.setObjectName('ps' + suf) intlk_led.setObjectName('intlk' + suf) panel_lay.addWidget(ps_label, i, 0) panel_lay.addWidget(conn_led, i, 1) panel_lay.addWidget(ps_led, i, 2) panel_lay.addWidget(intlk_led, i, 3) i += 1 else: l2f = sips2filters if sec == 'SI' else asps2filters for label, filt in l2f.items(): filt['sec'] = sec psnames = PSSearch.get_psnames(filters=filt) if not psnames: continue psconn_chs = list() ps_c2v = dict() ilk_c2v = dict() opm_c2v = dict() df_c2v = dict() for name in psnames: pvn = _PVName(name).substitute(prefix=self._prefix) ps_c2v[pvn.substitute(propty='PwrState-Sts')] = _on if name.dis == 'PS': psconn_chs.append( pvn.substitute(propty='Version-Cte')) ilk_c2v[pvn.substitute(propty='IntlkSoft-Mon')] = 0 ilk_c2v[pvn.substitute(propty='IntlkHard-Mon')] = 0 opm_pvn = pvn.substitute(propty='OpMode-Sts') if sec == 'BO': opm_c2v[opm_pvn] = { 'value': [_slowref, _rmpwfm], 'comp': 'in'} else: opm_c2v[opm_pvn] = _slowref df_c2v[pvn.substitute(propty='DiagStatus-Mon')] = \ {'value': 0, 'bit': 5} elif name.dis == 'PU': psconn_chs.append( pvn.substitute(propty='PwrState-Sts')) intlkcount = 7 if 'Sept' in name.dev else 8 for idx in range(1, intlkcount+1): ppty = 'Intlk'+str(idx)+'-Mon' pvn = pvn.substitute(propty=ppty) ilk_c2v[pvn] = 1 f = sec+'-'+filt['sub']+':'+psnames[0].dis+'-'+filt['dev'] ps_label = QLabel( label, panel, alignment=Qt.AlignRight | Qt.AlignVCenter) psconn_led = MyLedMultiConnection( filters=f, parent=panel, channels=psconn_chs) ps_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=ps_c2v) intlk_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=ilk_c2v) suf = sec+filt['dev'].strip('.*')+'_led' psconn_led.setObjectName('psconn' + suf) ps_led.setObjectName('ps' + suf) intlk_led.setObjectName('intlk' + suf) panel_lay.addWidget(ps_label, i, 0) panel_lay.addWidget(psconn_led, i, 1) panel_lay.addWidget(ps_led, i, 2) panel_lay.addWidget(intlk_led, i, 3) if psnames[0].dis == 'PS': opm_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=opm_c2v) opm_led.setOnColor(PyDMLed.LightGreen) opm_led.setOffColor(PyDMLed.Yellow) diff_led = MyLedMultiChannel( filters=f, parent=panel, channels2values=df_c2v) opm_led.setObjectName('opm' + suf) diff_led.setObjectName('diff' + suf) panel_lay.addWidget(opm_led, i, 4) panel_lay.addWidget(diff_led, i, 5) i += 1 panel_lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.MinimumExpanding), i, 0) i += 1 # Current State and Log Tables table_label2px = { 'Date': 110, 'Time': 85, 'Type': 70, 'PS Name': 145, 'Property': 85, 'Value': 120} channels = list() for ps in PSSearch.get_psnames(filters={'dis': 'PS'}): channels.append(_PVName(ps).substitute( prefix=self._prefix, propty='DiagCurrentDiff-Mon')) channels.append(_PVName(ps).substitute( prefix=self._prefix, propty='OpMode-Sts')) self._status = LogTable(cw, channels, table_label2px, is_status=True) self._status.setObjectName('status_table') self._status.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self._status.updated.connect(self._filter_table) self._log = LogTable(cw, channels, table_label2px) self._log.setObjectName('log_table') self._log.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self._tables_stack = QStackedLayout() self._tables_stack.addWidget(self._status) self._tables_stack.addWidget(self._log) self._rb_status = QRadioButton('Status', self) self._rb_status.setObjectName('rb_status') self._rb_status.setChecked(True) self._visible_table = self._status self._rb_status.toggled.connect(_partial(self._toggle_table, 0)) self._rb_log = QRadioButton('Log', self) self._rb_log.setObjectName('rb_log') self._rb_log.toggled.connect(_partial(self._toggle_table, 1)) for name, width in table_label2px.items(): attr = '_search_'+name.replace(' ', '').lower() setattr(self, attr, QLineEdit()) le = getattr(self, attr) le.setObjectName(name) le.setPlaceholderText(name + '...') le.editingFinished.connect(self._filter_table) width = str(width-1) if name == 'Value': le.setStyleSheet( '#'+name+'{min-width:'+width+'px;}') le.setSizePolicy(QSzPlcy.Expanding, QSzPlcy.Maximum) else: le.setStyleSheet( '#'+name+'{min-width:'+width+'px; max-width:'+width+'px;}') le.setSizePolicy(QSzPlcy.Maximum, QSzPlcy.Maximum) self._scrollup_pb = QPushButton('↟', cw) self._scrollup_pb.setObjectName('scrollup_pb') self._scrollup_pb.clicked.connect(self._arrange_table) self._scrolldown_pb = QPushButton('↡', cw) self._scrolldown_pb.setObjectName('scrolldown_pb') self._scrolldown_pb.clicked.connect(self._arrange_table) tables_lay = QGridLayout() tables_lay.setVerticalSpacing(2) tables_lay.setHorizontalSpacing(0) tables_lay.addWidget(self._search_date, 0, 0) tables_lay.addWidget(self._search_time, 0, 1) tables_lay.addWidget(self._search_type, 0, 2) tables_lay.addWidget(self._search_psname, 0, 3) tables_lay.addWidget(self._search_property, 0, 4) tables_lay.addWidget(self._search_value, 0, 5) tables_lay.addWidget(self._scrollup_pb, 0, 6, alignment=Qt.AlignRight) tables_lay.addLayout(self._tables_stack, 1, 0, 1, 7) tables_lay.addWidget(self._rb_status, 2, 0, alignment=Qt.AlignLeft) tables_lay.addWidget(self._rb_log, 2, 1, alignment=Qt.AlignLeft) tables_lay.addWidget(self._scrolldown_pb, 2, 6, alignment=Qt.AlignRight) tables = QWidget(cw) tables.setObjectName('tables') tables.setLayout(tables_lay) # Connect signals for led in self.findChildren(QLed): led.shape = PyDMLed.ShapeMap.Round led.filterlog.connect(self._filter_table) led.warning.connect(self._log.add_log_slot) led.warning.connect(self._status.add_log_slot) led.normal.connect(self._status.remove_log_slot) # Layout window_title = QLabel('<h2>Power Supplies Diagnostics</h2>', cw, alignment=Qt.AlignCenter) layout = QGridLayout() layout.setVerticalSpacing(20) layout.setHorizontalSpacing(5) layout.addWidget(window_title, 0, 0, 1, 2) layout.addWidget(panel, 1, 0) layout.addWidget(tables, 1, 1) cw.setStyleSheet(""" #scrollup_pb, #scrolldown_pb{ max-height: 1em; max-width: 0.7em; color: #464646; } QLineEdit{ max-height: 1em; } #status_table, #log_table{ border: 1px solid #bebebe; } #tables{ min-width: 700px; } #rb_status, #rb_log{ min-width: 5em; max-width: 5em; max-height: 1em; }""") cw.setLayout(layout) self.setCentralWidget(cw)