def _build(self): #self.layout= qt.QVBoxLayout(self) if QTVERSION < '4.0.0': self.list= qt.QListView(self, "ScanList") self.list.setSelectionMode(qt.QListView.Extended) self.mainTab = qt.QTabWidget(self) else: self.splitter = qt.QSplitter(self) self.splitter.setOrientation(qt.Qt.Vertical) self.list = qt.QTreeWidget(self.splitter) self.list.setSelectionMode(qt.QAbstractItemView.ExtendedSelection) self.mainTab = qt.QTabWidget(self.splitter) self.cntTable = SpecFileCntTable.SpecFileCntTable() self.mcaTable = SpecFileMcaTable.SpecFileMcaTable() self.mainTab.addTab(self.cntTable, str("Counters")) self.mainTab.addTab(self.mcaTable, str("MCA")) if QTVERSION < '4.0.0': self.mainTab.setCurrentPage(self.mainTab.indexOf(self.mcaTable)) else: self.mainTab.setCurrentWidget(self.mcaTable) autoBox = qt.QWidget(self) autoBoxLayout = qt.QHBoxLayout(autoBox) autoBoxLayout.setMargin(0) autoBoxLayout.setSpacing(0) self.autoOffBox = qt.QCheckBox(autoBox) self.autoOffBox.setText("Auto OFF") self.autoAddBox = qt.QCheckBox(autoBox) self.autoAddBox.setText("Auto ADD") self.autoReplaceBox = qt.QCheckBox(autoBox) self.autoReplaceBox.setText("Auto REPLACE") if self.autoReplace: self.autoAddBox.setChecked(False) self.autoReplaceBox.setChecked(True) else: self.autoAddBox.setChecked(True) self.autoReplaceBox.setChecked(False) if OBJECT3D: self.object3DBox = qt.QCheckBox(autoBox) self.object3DBox.setText("3D On") autoBoxLayout.addWidget(self.object3DBox) self.connect(self.mcaTable, qt.SIGNAL("McaDeviceSelected"), self.mcaDeviceSelected) if QTVERSION > '4.0.0': self.meshBox = qt.QCheckBox(autoBox) self.meshBox.setText("Mesh") self.meshBox.setToolTip("Consider selection as a regular mesh") autoBoxLayout.addWidget(self.meshBox) autoBoxLayout.addWidget(self.autoOffBox) autoBoxLayout.addWidget(self.autoAddBox) autoBoxLayout.addWidget(self.autoReplaceBox) self.forceMcaBox = qt.QCheckBox(autoBox) self.forceMcaBox.setText("Force MCA") autoBoxLayout.addWidget(self.forceMcaBox) if QTVERSION < '4.0.0': self.mainLayout.addWidget(self.list) self.mainLayout.addWidget(self.mainTab) else: self.mainLayout.addWidget(self.splitter) self.mainLayout.addWidget(autoBox) # --- list headers if QTVERSION < '4.0.0': self.list.addColumn("X") self.list.addColumn("S#") self.list.addColumn("Command") self.list.addColumn("Pts") self.list.addColumn("Mca") self.list.header().setResizeEnabled(0, 0) self.list.header().setResizeEnabled(0, 1) self.list.header().setResizeEnabled(1, 2) self.list.header().setResizeEnabled(0, 3) self.list.header().setResizeEnabled(0, 4) self.list.header().setClickEnabled(0,-1) self.list.setSorting(-1) # --- list selection options self.list.setAllColumnsShowFocus(1) # --- signal handling self.connect(self.list, qt.SIGNAL("selectionChanged()"), self.__selectionChanged) self.connect(self.list, qt.SIGNAL("contextMenuRequested(QListViewItem *, const QPoint &, int)"), self.__contextMenu) self.connect(self.list, qt.SIGNAL("doubleClicked(QListViewItem *)"), self.__doubleClicked) """ self.connect(self.cntTable, qt.PYSIGNAL('SpecCntTableSignal'), self._cntSignal) """ # --- context menu self.menu= qt.QPopupMenu(self.list) idd= self.menu.insertItem("Show scan header") self.menu.connectItem(idd, self.__showScanInfo) else: labels = ["X", "S#", "Command", "Points", "Nb. Mca"] ncols = len(labels) self.list.setColumnCount(ncols) self.list.setHeaderLabels(labels) #size=50 #self.list.header().resizeSection(0, size) #self.list.header().resizeSection(1, size) #self.list.header().resizeSection(2, 4 * size) #self.list.header().resizeSection(3, size) #self.list.header().resizeSection(4, size) self.list.header().setStretchLastSection(False) if QTVERSION < '4.2.0': self.list.header().setResizeMode(0, qt.QHeaderView.Stretch) self.list.header().setResizeMode(1, qt.QHeaderView.Stretch) self.list.header().setResizeMode(2, qt.QHeaderView.Interactive) self.list.header().setResizeMode(3, qt.QHeaderView.Stretch) self.list.header().setResizeMode(4, qt.QHeaderView.Stretch) else: self.list.header().setResizeMode(0, qt.QHeaderView.ResizeToContents) self.list.header().setResizeMode(1, qt.QHeaderView.ResizeToContents) self.list.header().setResizeMode(2, qt.QHeaderView.Interactive) self.list.header().setResizeMode(3, qt.QHeaderView.ResizeToContents) self.list.header().setResizeMode(4, qt.QHeaderView.ResizeToContents) # --- signal handling self.connect(self.list, qt.SIGNAL("itemSelectionChanged()"), self.__selectionChanged) self.list.setContextMenuPolicy(qt.Qt.CustomContextMenu) self.connect(self.list, qt.SIGNAL("customContextMenuRequested(const QPoint &)"), self.__contextMenu) self.connect(self.list, qt.SIGNAL("itemDoubleClicked(QTreeWidgetItem *, int)"), self.__doubleClicked) self.connect(self.cntTable, qt.SIGNAL('SpecCntTableSignal'), self._cntSignal) if QTVERSION > '4.2.0': self.list.setSortingEnabled(False) self.connect(self.list.header(), qt.SIGNAL("sectionDoubleClicked(int)"), self.__headerSectionDoubleClicked) if OBJECT3D: self.connect(self.object3DBox, qt.SIGNAL("clicked()"), self._setObject3DBox) if hasattr(self, 'meshBox'): self.connect(self.meshBox, qt.SIGNAL("clicked()"), self._setMeshBox) self.connect(self.autoOffBox, qt.SIGNAL("clicked()"), self._setAutoOff) self.connect(self.autoAddBox, qt.SIGNAL("clicked()"), self._setAutoAdd) self.connect(self.autoReplaceBox, qt.SIGNAL("clicked()"), self._setAutoReplace) self.connect(self.forceMcaBox, qt.SIGNAL('clicked()'), self._setForcedMca) if QTVERSION < '4.0.0': self.connect(self.mainTab, qt.SIGNAL('currentChanged(QWidget*)'), self._tabChanged) else: self.connect(self.mainTab, qt.SIGNAL('currentChanged(int)'), self._tabChanged) self.disableMca = 0 #(type=="scan") self.disableScan = 0 #(type=="mca") # --- context menu self.data= None self.scans= []
def __init__(self, parent=None, name="SPSSelector", fl=0): qt.QWidget.__init__(self, parent, name, fl) self.dataSource = None self.data = None self.currentSpec = None self.currentArray = None self.selection = None self.openFile = self.refreshSpecList self.selectPixmap = qt.QPixmap(icons.selected) self.unselectPixamp = qt.QPixmap(icons.unselected) mainLayout = qt.QVBoxLayout(self) # --- spec name selection specWidget = qt.QWidget(self) self.specCombo = qt.QComboBox(specWidget) self.specCombo.setEditable(0) self.reload = qt.QIconSet(qt.QPixmap(icons.reload)) refreshButton = qt.QToolButton(specWidget) refreshButton.setIconSet(self.reload) refreshButton.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum)) self.closeIcon = qt.QIconSet(qt.QPixmap(icons.fileclose)) closeButton = qt.QToolButton(specWidget) closeButton.setIconSet(self.closeIcon) closeButton.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum)) specLayout = qt.QHBoxLayout(specWidget) specLayout.addWidget(self.specCombo) specLayout.addWidget(refreshButton) specLayout.addWidget(closeButton) self.connect(refreshButton, qt.SIGNAL("clicked()"), self.refreshSpecList) self.connect(closeButton, qt.SIGNAL("clicked()"), self.closeCurrentSpec) self.connect(self.specCombo, qt.SIGNAL("activated(const QString &)"), self.refreshArrayList) # --- splitter self.splitter = qt.QSplitter(self) self.splitter.setOrientation(qt.QSplitter.Vertical) # --- shm array list self.arrayList = qt.QListView(self.splitter, "ShmArrayList") self.arrayList.addColumn("") self.arrayList.addColumn("Array Name") self.arrayList.addColumn("Rows") self.arrayList.addColumn("Cols") self.arrayList.setSorting(-1) self.arrayList.header().setClickEnabled(0, -1) self.arrayList.setAllColumnsShowFocus(1) self.arrayList.setSelectionMode(qt.QListView.Single) self.connect(self.arrayList, qt.SIGNAL("selectionChanged()"), self.__arraySelection) # --- array parameter self.paramIndex = {} self.paramWidget = qt.QWidgetStack(self.splitter) for type in self.WidgetArrays.keys(): widclass = self.WidgetArrays[type] wid = widclass(self.paramWidget) self.paramWidget.addWidget(wid) self.paramIndex[type] = self.paramWidget.id(wid) # --- command buttons butWidget = qt.QWidget(self) butWidget.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) addButton = qt.QPushButton("Add", butWidget) removeButton = qt.QPushButton("Remove", butWidget) replaceButton = qt.QPushButton("Replace", butWidget) butLayout = qt.QHBoxLayout(butWidget) butLayout.addWidget(removeButton) butLayout.addWidget(replaceButton) butLayout.addWidget(addButton) butLayout.setMargin(5) self.connect(addButton, qt.SIGNAL("clicked()"), self.__addClicked) self.connect(replaceButton, qt.SIGNAL("clicked()"), self.__replaceClicked) self.connect(removeButton, qt.SIGNAL("clicked()"), self.__removeClicked) # --- main layout mainLayout.setMargin(5) mainLayout.setSpacing(5) mainLayout.addWidget(specWidget) mainLayout.addWidget(self.splitter) mainLayout.addWidget(butWidget)