def _getLabeledList(w, label="", commandSlot=None): """Utility function to create an expanding listbox in labeled frame""" # use the other utility function to create the labeled frame frame = _getLabeledFrame(w, label) listbox = qt.QListBox(frame, label) # allow the listbox to expand in both directions listbox.setSizePolicy(_ANCHOR) # connect the "double-click" signal (event) to commandSlot if commandSlot: w.connect(listbox, SIGNAL("selected(int)"), commandSlot) return frame, listbox
def __init__(self, *args): apply(qt.QWidget.__init__, (self, ) + args) self.topLayout = qt.QVBoxLayout(self, 10) self.grid = qt.QGridLayout(0, 0) self.topLayout.addLayout(self.grid, 10) # Create a list box self.lb = qt.QListBox(self, "listBox") file = open(sys.argv[1], 'r') self.dasitems = map(lambda x: string.rstrip(x), file.readlines()) file.close() self.setCaption(self.dasitems.pop(0)) for item in self.dasitems: self.lb.insertItem(item) self.grid.addMultiCellWidget(self.lb, 0, 0, 0, 0) self.connect(self.lb, qt.SIGNAL("selected(int)"), self.listBoxItemSelected) self.topLayout.activate()
def buildInterface(self): self.layout = qt.QHBoxLayout(self) self.titleLabel = QubLabel("<B>Title<B>", self) self.titleLabel.setAlignment(qt.Qt.AlignCenter) self.titleLabel.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)) self.layout.addWidget(self.titleLabel) """ move and configure appearence """ self.radioGroup = QubRadioGroup(QubRadioGroup.Horizontal, self) self.radioGroup.hide() self.connect(self.radioGroup, qt.PYSIGNAL("PositionClicked"), self.positionClicked) self.layout.addWidget(self.radioGroup) self.setButton = qt.QPushButton("Set", self) self.setButton.hide() self.connect(self.setButton, qt.SIGNAL("clicked()"), self.setPosition) self.setButton.setEnabled(False) self.layout.addWidget(self.setButton) """ display appearence """ self.valueLabel = qt.QLabel("no value", self) self.valueLabel.hide() self.valueLabel.setAlignment(qt.Qt.AlignCenter) self.layout.addWidget(self.valueLabel) """ incremental appearence """ self.frame = qt.QFrame(self) self.frame.hide() self.frame.setFrameShape(qt.QFrame.NoFrame) self.frame.setFrameShadow(qt.QFrame.Plain) self.layout.addWidget(self.frame) vlayout = qt.QVBoxLayout(self.frame) vlayout.setMargin(10) self.valueWidget = QubValue(self.frame, titleType=QubValue.Label, valueType=QubValue.Label, orientation=QubValue.Horizontal) self.valueWidget.setTitle("Current Position") vlayout.addWidget(self.valueWidget) vlayout.addSpacing(5) hlayout = qt.QHBoxLayout(vlayout) self.positionList = qt.QListBox(self.frame) hlayout.addWidget(self.positionList) hlayout.addSpacing(5) vlayout1 = qt.QVBoxLayout(hlayout) self.gotoButton = qt.QPushButton("Go", self.frame) self.connect(self.gotoButton, qt.SIGNAL("clicked()"), self.gotoPosition) vlayout1.addWidget(self.gotoButton) vlayout1.addStretch(1) self.addButton = qt.QPushButton("Add", self.frame) self.connect(self.addButton, qt.SIGNAL("clicked()"), self.addPosition) vlayout1.addWidget(self.addButton) vlayout1.addSpacing(5) self.remButton = qt.QPushButton("Delete", self.frame) self.connect(self.remButton, qt.SIGNAL("clicked()"), self.remPosition) vlayout1.addWidget(self.remButton) """ popup config """ self.configWindow = MultiplePositionConfigurator(self) self.popupMenu = qt.QPopupMenu(self.titleLabel) self.popupMenu.insertItem("Configure", self.configWindow.show)
def __init__(self, parent=None, name=None, fl=0): CreateTaskBase.__init__(self, parent, name, fl, 'Helical') if not name: self.setName("create_helical_widget") # # Data attributes # self.init_models() self._prev_pos = None self._current_pos = None self._list_item_map = {} self.init_models() # # Layout # v_layout = qt.QVBoxLayout(self, 2, 5, "v_layout") self._lines_gbox = qt.QGroupBox('Lines', self, "lines_gbox") self._lines_gbox.setColumnLayout(0, qt.Qt.Vertical) self._lines_gbox.layout().setSpacing(6) self._lines_gbox.layout().setMargin(11) lines_gbox_layout = qt.QHBoxLayout(self._lines_gbox.layout()) lines_gbox_layout.setAlignment(qt.Qt.AlignTop) self._list_box = qt.QListBox(self._lines_gbox, "helical_page") self._list_box.setSelectionMode(qt.QListBox.Extended) self._list_box.setFixedWidth(200) self._list_box.setFixedHeight(75) list_box_tool_tip = "Select the line(s) to perfrom helical scan on" qt.QToolTip.add(self._list_box, list_box_tool_tip) lines_gbox_layout.addWidget(self._list_box) button_layout = qt.QVBoxLayout(None, 0, 6, "button_layout") button_layout.setSpacing(5) add_button = qt.QPushButton("+", self._lines_gbox, "add_button") add_button.setFixedWidth(20) add_button.setFixedHeight(20) remove_button = qt.QPushButton("-", self._lines_gbox, "add_button") remove_button.setFixedWidth(20) remove_button.setFixedHeight(20) button_layout.addWidget(add_button) button_layout.addWidget(remove_button) lines_gbox_layout.addLayout(button_layout) add_button_tool_tip = "Add a line between two saved positions, " \ "CTRL click to select more than one position" qt.QToolTip.add(add_button, add_button_tool_tip) remove_button_tool_tip = "Remove selected line(s)" qt.QToolTip.add(remove_button, remove_button_tool_tip) self._acq_gbox = qt.QVGroupBox('Acquisition', self, 'acq_gbox') self._acq_widget = \ AcquisitionWidget(self._acq_gbox, "acquisition_widget", layout='vertical', acq_params=self._acquisition_parameters, path_template=self._path_template) self._acq_widget.disable_inverse_beam(True) self._data_path_gbox = qt.QVGroupBox('Data location', self, 'data_path_gbox') self._data_path_widget = \ DataPathWidget(self._data_path_gbox, data_model = self._path_template, layout = 'vertical') self._processing_gbox = qt.QVGroupBox('Processing', self, 'processing_gbox') self._processing_widget = \ ProcessingWidget(self._processing_gbox, data_model = self._processing_parameters) v_layout.addWidget(self._lines_gbox) v_layout.addWidget(self._acq_gbox) v_layout.addWidget(self._data_path_gbox) v_layout.addWidget(self._processing_gbox) qt.QObject.connect(add_button, qt.SIGNAL("clicked()"), self.add_clicked) qt.QObject.connect(remove_button, qt.SIGNAL("clicked()"), self.remove_clicked) qt.QObject.connect(self._list_box, qt.SIGNAL("selectionChanged()"), self.list_box_selection_changed) prefix_ledit = self._data_path_widget.\ data_path_widget_layout.child('prefix_ledit') run_number_ledit = self._data_path_widget.\ data_path_widget_layout.child('run_number_ledit') self.connect(prefix_ledit, qt.SIGNAL("textChanged(const QString &)"), self._prefix_ledit_change) self.connect(run_number_ledit, qt.SIGNAL("textChanged(const QString &)"), self._run_number_ledit_change) self.connect(self._data_path_widget, qt.PYSIGNAL("path_template_changed"), self.handle_path_conflict)