def __init__(self, pv, moving_pv=None, moving_val=0, precision=5, convert=None, *args, **kwargs): super(EpicsValueLabel, self).__init__(*args, **kwargs) # Value conversion function self.convert = convert self.precision = precision self.setMinimumSize(qt.QSize(130, 30)) self.setMaximumSize(qt.QSize(130, 30)) self.setFrameShape(qt.QFrame.Panel) self.setFrameShadow(qt.QFrame.Sunken) self.setAlignment(qt.Qt.AlignCenter) self.setText("not connected") self.formatStr = "{:." + str(self.precision) + "f}" self.moving_val = moving_val self.pv = epics.PV(pv, auto_monitor=True) self.pv.add_callback(self.update_value) if moving_pv is not None: self.moving_pv = epics.PV(moving_pv, auto_monitor=True) self.moving_pv.add_callback(self.update_color) # Set initial value from pv if self.pv.connected: _submit(self.setText, str(round(self.pv.get(), self.precision)))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setMinimumSize(qt.QSize(80, 30)) self.setMaximumSize(qt.QSize(80, 30)) self.setFrameShape(qt.QFrame.Panel) self.setFrameShadow(qt.QFrame.Sunken) self.setAlignment(qt.Qt.AlignCenter) self.setText("not conn.")
def __init__(self, pv, read_pv=None, suppression=False, *args, **kwargs): super(GainComboBox, self).__init__(*args, **kwargs) self.lastUpdate = 0 self.setEditable(True) self.lineEdit = self.lineEdit() self.lineEdit.setAlignment(qt.Qt.AlignCenter) self.lineEdit.setReadOnly(True) self.setMinimumSize(qt.QSize(100, 30)) self.setMaximumSize(qt.QSize(100, 30)) self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.setItemText(0, "1E3 V/A") self.setItemText(1, "1E4 V/A") self.setItemText(2, "1E5 V/A") self.setItemText(3, "1E6 V/A") self.setItemText(4, "1E7 V/A") self.setItemText(5, "1E8 V/A") self.setItemText(6, "1E9 V/A") self.setItemText(7, "1E10 V/A") self.suppression = suppression if suppression: self.prefix = pv[:-4] self.suppressionValuePV = epics.PV(self.prefix + 'SuppressionValue', auto_monitor=True) self.suppressionExponentPV = epics.PV(self.prefix + 'SuppressionExponent', auto_monitor=True) self.pv = epics.PV(pv, auto_monitor=True) if read_pv: self.read_pv = epics.PV(read_pv, auto_monitor=True) else: self.read_pv = self.pv self.read_pv.add_callback(self.update_value) # Set initial value from pv if self.read_pv.connected: _submit(self.update_value) self.currentIndexChanged.connect(self.update_pv)
def __init__(self, sbarWidth, parent=None, *args, **kwargs): super(ScrollBarTwoValue, self).__init__(parent=parent, *args, **kwargs) self.setMinimumSize(qt.QSize(sbarWidth, 30)) self.setMaximumSize(qt.QSize(sbarWidth, 30)) self.setMinimum(0) self.setMaximum(1000) self.setSingleStep(1000) self.setOrientation(qt.Qt.Horizontal) self.setInvertedAppearance(False) self.valueChanged.connect(self.checkValue)
def __init__(self, pv, read_pv=None, *args, **kwargs): super().__init__(*args, **kwargs) self.lastUpdate = 0 self.setEditable(True) self.lineEdit = self.lineEdit() self.lineEdit.setAlignment(qt.Qt.AlignCenter) self.lineEdit.setReadOnly(True) self.setMinimumSize(qt.QSize(100, 30)) self.setMaximumSize(qt.QSize(100, 30)) self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.addItem("") self.setItemText(0, "10 usec") self.setItemText(1, "30 usec") self.setItemText(2, "100 usec") self.setItemText(3, "300 usec") self.setItemText(4, "1 msec") self.setItemText(5, "3 msec") self.setItemText(6, "10 msec") self.setItemText(7, "30 msec") self.setItemText(8, "100 msec") self.setItemText(9, "300 msec") if type(pv) in (list, tuple): self.pvs = {} for idx, _pv in enumerate(pv): self.pvs[idx] = epics.PV(_pv, auto_monitor=True) else: self.pvs[0] = epics.PV(pv, auto_monitor=True) if read_pv: self.read_pv = epics.PV(read_pv, auto_monitor=True) else: self.read_pv = self.pvs[0] self.read_pv.add_callback(self.update_value) # Set initial value from pv if self.read_pv.connected: _submit(self.update_value) self.currentIndexChanged.connect(self.update_pv)
def restoreWindowLocationSettings(self, groupName, window): """Restore the window settings using this settings object :param qt.QSettings settings: Initialized settings """ settings = self.__settings if settings is None: _logger.debug("Settings not set") return settings.beginGroup(groupName) size = settings.value("size", qt.QSize()) pos = settings.value("pos", qt.QPoint()) isFullScreen = settings.value("full-screen", False) try: if not isinstance(isFullScreen, bool): isFullScreen = utils.stringToBool(isFullScreen) except ValueError: isFullScreen = False settings.endGroup() if not pos.isNull(): window.move(pos) if not size.isNull(): window.resize(size) if isFullScreen: window.showFullScreen()
def __init__(self, *args, **kwargs): self.__pixmap = None self.__moving = None self.__hover = None self.__focus = None self.__range = None self.__nSteps = self._defaultNSteps self.__snap = False self.__sliderIcons = { 'left': getKmapIcon('right_arrow'), 'right': getKmapIcon('left_arrow') } self.__sliders = OrderedDict([('left', Qt.QRect()), ('right', Qt.QRect())]) self.__values = {'left': None, 'right': None} self.__showRangeBackground = None # call the super constructor AFTER defining all members that # are used in the "paint" method super(RangeSlider, self).__init__(*args, **kwargs) self.setFocusPolicy(Qt.Qt.ClickFocus) self.__setupSliders() self.setMouseTracking(True) self.setMinimumSize(Qt.QSize(*self._defaultMinimumSize)) self.setMaximumHeight(self._defaultMaximumHeight) self.setSliderValues(None, None)
def restoreSettings(self, settings): """Restore the window settings using this settings object :param qt.QSettings settings: Initialized settings """ settings.beginGroup("mainwindow") size = settings.value("size", qt.QSize(640, 480)) pos = settings.value("pos", qt.QPoint()) isFullScreen = settings.value("full-screen", False) if not isinstance(isFullScreen, bool): isFullScreen = False settings.endGroup() settings.beginGroup("mainlayout") try: data = settings.value("spliter") data = [int(d) for d in data] self.__spliter.setSizes(data) except Exception: _logger.debug("Backtrace", exc_info=True) settings.endGroup() if not pos.isNull(): self.move(pos) if not size.isNull(): self.resize(size) if isFullScreen: self.showFullScreen()
def createIconPanel(self, parent): panel = qt.QWidget(parent) layout = qt.QGridLayout() # layout.setSizeConstraint(qt.QLayout.SetMinAndMaxSize) panel.setLayout(layout) self.tools = [] # Sort together animated and non animated icons fix_icons = self.getAllAvailableIcons() animated_icons = self.getAllAvailableAnimatedIcons() icons = [] icons.extend([(i, "_") for i in fix_icons]) icons.extend([(i, "anim") for i in animated_icons]) icons = sorted(icons) for i, icon_info in enumerate(icons): icon_name, icon_kind = icon_info col, line = i / 10, i % 10 if icon_kind == "anim": tool = AnimatedToolButton(panel) icon = silx.gui.icons.getAnimatedIcon(icon_name) tool.setToolTip("Animated icon '%s'" % icon_name) else: tool = qt.QToolButton(panel) icon = silx.gui.icons.getQIcon(icon_name) tool.setToolTip("Icon '%s'" % icon_name) tool.setIcon(icon) tool.setIconSize(qt.QSize(32, 32)) layout.addWidget(tool, col, line) self.tools.append(tool) return panel
def __init__(self, plot, parent=None): assert isinstance( plot, RixsPlot2D), "'plot' should be an instance of RixsPlot2D" _title = f"Plot {plot._index} : cursors infos" super(RixsROIDockWidget, self).__init__(_title, parent=parent) self._roiManager = RixsROIManager(plot) #: Create the table widget displaying infos self._roiTable = RegionOfInterestTableWidget() self._roiTable.setRegionOfInterestManager(self._roiManager) #: Create a toolbar containing buttons for all ROI 'drawing' modes self._roiToolbar = qt.QToolBar() self._roiToolbar.setIconSize(qt.QSize(16, 16)) for roiClass in self._roiManager.getSupportedRoiClasses(): # Create a tool button and associate it with the QAction of each # mode action = self._roiManager.getInteractionModeAction(roiClass) self._roiToolbar.addAction(action) # Add the region of interest table and the buttons to a dock widget self._widget = qt.QWidget() self._layout = qt.QVBoxLayout() self._widget.setLayout(self._layout) self._layout.addWidget(self._roiToolbar) self._layout.addWidget(self._roiTable) self.setWidget(self._widget) self.visibilityChanged.connect(self.roiDockVisibilityChanged)
def __init__(self, parent): super(AboutDialog, self).__init__(parent) self.setWindowTitle("About") self.setWindowIcon(qt.QIcon(ICONPATHR)) self.parseq_pypi_version = self.check_pypi_version( ) # pypi_ver, cur_ver # noqa self.tabBar = qt.QTabBar(parent=self) self.tabBar.setIconSize(qt.QSize(32, 32)) self.tabBar.setStyleSheet("QTabBar {font: bold 10pt;}") # "QTabBar::tab { height: 100px; width: 400px; }") self.tabNames = ['ParSeq', csi.pipelineName] self.iconPaths = [ICONPATHP, csi.appIconPath] for tabName, iconPath in zip(self.tabNames, self.iconPaths): icon = qt.QIcon(iconPath) if iconPath else qt.QIcon() self.tabBar.addTab(icon, tabName) self.tabBar.currentChanged.connect(self.changePage) self.makeWebView() # self.webView.page().mainFrame().setScrollBarPolicy( # qt.Qt.Vertical, qt.Qt.ScrollBarAlwaysOff) # self.webView.page().mainFrame().setScrollBarPolicy( # qt.Qt.Horizontal, qt.Qt.ScrollBarAlwaysOff) layout = qt.QVBoxLayout() layout.addWidget(self.tabBar) layout.setSpacing(0) layout.addWidget(self.webView) self.setLayout(layout) self.resize(0, 0)
def createIconPanel(self, parent): panel = qt.QWidget(parent) layout = qt.QGridLayout() # layout.setSizeConstraint(qt.QLayout.SetMinAndMaxSize) panel.setLayout(layout) self.tools = [] import silx.resources icons = silx.resources.list_dir("gui/icons") # filter out sub-directories icons = filter(lambda x: not silx.resources.is_dir("gui/icons/" + x), icons) # remove extension icons = [i.split(".")[0] for i in icons] # remove duplicated names icons = set(icons) # sort by names icons = sorted(icons) for i, icon_name in enumerate(icons): col, line = i / 10, i % 10 icon = silx.gui.icons.getQIcon(icon_name) tool = qt.QToolButton(panel) tool.setIcon(icon) tool.setIconSize(qt.QSize(32, 32)) tool.setToolTip(icon_name) layout.addWidget(tool, col, line) self.tools.append(tool) return panel
def __init__(self): super(AbstractCalibrationTask, self).__init__() self._initGui() self.__model = None self.installEventFilter(self) if hasattr(self, "_nextStep"): self._nextStep.setIconSize(qt.QSize(32, 32))
def __init__(self, parent=None): self.__pixmap = None self.__positionCount = None self.__firstValue = 0. self.__secondValue = 1. self.__minValue = 0. self.__maxValue = 1. self.__hoverRect = qt.QRect() self.__hoverControl = None self.__focus = None self.__moving = None self.__icons = { 'first': icons.getQIcon('previous'), 'second': icons.getQIcon('next') } # call the super constructor AFTER defining all members that # are used in the "paint" method super(RangeSlider, self).__init__(parent) self.setFocusPolicy(qt.Qt.ClickFocus) self.setAttribute(qt.Qt.WA_Hover) self.setMinimumSize(qt.QSize(50, 20)) self.setMaximumHeight(20) # Broadcast value changed signal self.sigValueChanged.connect(self.__emitPositionChanged)
def __createCompoundIcon(self, backgroundIcon, foregroundIcon): icon = qt.QIcon() sizes = backgroundIcon.availableSizes() sizes = sorted(sizes, key=lambda s: s.height()) sizes = filter(lambda s: s.height() < 100, sizes) sizes = list(sizes) if len(sizes) > 0: baseSize = sizes[-1] else: baseSize = qt.QSize(32, 32) modes = [qt.QIcon.Normal, qt.QIcon.Disabled] for mode in modes: pixmap = qt.QPixmap(baseSize) pixmap.fill(qt.Qt.transparent) painter = qt.QPainter(pixmap) painter.drawPixmap(0, 0, backgroundIcon.pixmap(baseSize, mode=mode)) painter.drawPixmap(0, 0, foregroundIcon.pixmap(baseSize, mode=mode)) painter.end() icon.addPixmap(pixmap, mode=mode) return icon
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.resize(535, 47) layout = qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(6) self.StatusLabel = qt.QLabel(self) self.StatusLabel.setText("Status:") layout.addWidget(self.StatusLabel) self.StatusLine = qt.QLineEdit(self) self.StatusLine.setText("Ready") self.StatusLine.setReadOnly(1) layout.addWidget(self.StatusLine) self.ChisqLabel = qt.QLabel(self) self.ChisqLabel.setText("Reduced chisq:") layout.addWidget(self.ChisqLabel) self.ChisqLine = qt.QLineEdit(self) self.ChisqLine.setMaximumSize(qt.QSize(16000, 32767)) self.ChisqLine.setText("") self.ChisqLine.setReadOnly(1) layout.addWidget(self.ChisqLine)
def __readSettings(self): settings = Qt.QSettings(_COMPANY_NAME, _APP_NAME) settings.beginGroup("gui") self.resize(settings.value("MainWindow/size", Qt.QSize(400, 400))) self.move(settings.value("MainWindow/pos", Qt.QPoint(200, 200))) self.restoreState(settings.value("MainWindow/state", Qt.QByteArray())) settings.endGroup()
def __init__(self, pv, *args, **kwargs): super().__init__(*args, **kwargs) self.setMinimumSize(qt.QSize(100, 30)) self.setMaximumSize(qt.QSize(100, 30)) self.setFrameShape(qt.QFrame.Panel) self.setFrameShadow(qt.QFrame.Sunken) self.setAlignment(qt.Qt.AlignCenter) self.setText("not connected") self.pv = epics.PV(pv, auto_monitor=True) self.pv.add_callback(self.update_value) # Set initial value from pv if self.pv.connected: _submit(self.update_value)
def __init__(self, parent=None): super(CalibrantPreview, self).__init__(parent) self.__calibrant = None self.__waveLength = None self.__pixmap = None self.__cachedSize = None self.setMinimumSize(qt.QSize(50, 20))
def __createTreeWindow(self, treeView): toolbar = qt.QToolBar(self) toolbar.setIconSize(qt.QSize(16, 16)) toolbar.setStyleSheet("QToolBar { border: 0px }") action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("view-refresh")) action.setText("Refresh") action.setToolTip("Refresh all selected items") action.triggered.connect(self.__refreshSelected) action.setShortcut(qt.QKeySequence(qt.Qt.Key_F5)) toolbar.addAction(action) treeView.addAction(action) self.__refreshAction = action # Another shortcut for refresh action = qt.QAction(toolbar) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_R)) treeView.addAction(action) action.triggered.connect(self.__refreshSelected) action = qt.QAction(toolbar) # action.setIcon(icons.getQIcon("view-refresh")) action.setText("Close") action.setToolTip("Close selected item") action.triggered.connect(self.__removeSelected) action.setShortcut(qt.QKeySequence(qt.Qt.Key_Delete)) treeView.addAction(action) self.__closeAction = action toolbar.addSeparator() action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-expand-all")) action.setText("Expand all") action.setToolTip("Expand all selected items") action.triggered.connect(self.__expandAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Plus)) toolbar.addAction(action) treeView.addAction(action) self.__expandAllAction = action action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-collapse-all")) action.setText("Collapse all") action.setToolTip("Collapse all selected items") action.triggered.connect(self.__collapseAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Minus)) toolbar.addAction(action) treeView.addAction(action) self.__collapseAllAction = action widget = qt.QWidget(self) layout = qt.QVBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(toolbar) layout.addWidget(treeView) return widget
def setProfile(self, x, y, colormap): """ :param profile: a 1D numpy array :param colormap: an XsocsPlot2DColormap instance :param nColors: number of colors :return: """ assert x.ndim == 1 assert y.ndim == 1 self.__colormap = colormap self.__pixmap = pixmap = Qt.QPixmap(Qt.QSize(x.size, self._pimapHeight)) pixmap.fill() xMin = x.min() xMax = x.max() colors = _applyColormap(colormap, x) profileValues = (y * (1.0 * self._pimapHeight / y.max())) points = [Qt.QPointF(0, 0)] points.extend( [Qt.QPointF(idx, val) for idx, val in enumerate(profileValues)]) points.extend([Qt.QPointF(colormap.nColors - 1, 0)]) poly = Qt.QPolygonF(points) if colormap.minVal is not None: lineMin = ((colormap.minVal - xMin) * (pixmap.width() - 1) / (xMax - xMin)) else: lineMin = None if colormap.maxVal is not None: lineMax = ((colormap.maxVal - xMin) * (pixmap.width() - 1) / (xMax - xMin)) else: lineMax = None self.__lineMin = lineMin self.__lineMax = lineMax gradient = Qt.QLinearGradient(Qt.QPoint(0, 0), Qt.QPoint(colormap.nColors - 1, 0)) for idx, color in enumerate(colors): qColor = Qt.QColor.fromRgbF(*color) gradient.setColorAt(idx / (1.0 * (colormap.nColors - 1)), qColor) painter = Qt.QPainter(pixmap) painter.save() painter.scale(1, -1.) painter.translate(Qt.QPointF(0., -1.0 * self._pimapHeight)) brush = Qt.QBrush(gradient) painter.setBrush(brush) painter.setPen(Qt.QPen(Qt.Qt.NoPen)) painter.drawPolygon(poly) painter.restore() painter.end() self.update()
def changeWindowFlags(self, node, evt): if self.isFloating(): # The dockWidget will automatically regain it's Qt::widget flag # when it becomes docked again self.setWindowFlags(qt.Qt.Window | qt.Qt.CustomizeWindowHint | qt.Qt.WindowMaximizeButtonHint) # setWindowFlags calls setParent() when changing the flags for a # window, causing the widget to be hidden, so: self.show() # Custom title bar: self.titleBar = qt.QWidget() self.titleBar.setAutoFillBackground(True) self.titleBar.setStyleSheet("QWidget {font: bold; font-size: " + fontSize + "pt;}") pal = self.titleBar.palette() pal.setColor(qt.QPalette.Window, qt.QColor("lightgray")) self.titleBar.setPalette(pal) height = qt.QApplication.style().pixelMetric( qt.QStyle.PM_TitleBarHeight) self.titleBar.setMaximumHeight(height) layout = qt.QHBoxLayout() self.titleBar.setLayout(layout) buttonSize = qt.QSize(height - 16, height - 16) self.titleIcon = qt.QLabel() # self.titleIcon.setPixmap(self.parent().runIcon.pixmap(buttonSize)) self.titleIcon.setPixmap(node.widget.dimIcon.pixmap(buttonSize)) self.titleIcon.setVisible(True) layout.addWidget(self.titleIcon, 0) self.title = qt.QLabel(self.windowTitle()) layout.addWidget(self.title, 0) layout.setContentsMargins(4, 4, 4, 4) layout.addStretch() self.dockButton = qt.QToolButton(self) self.dockButton.setIcon(qt.QApplication.style().standardIcon( qt.QStyle.SP_ToolBarVerticalExtensionButton)) self.dockButton.setMaximumSize(buttonSize) self.dockButton.setAutoRaise(True) self.dockButton.clicked.connect(self.toggleFloating) self.dockButton.setToolTip('dock into the main window') layout.addWidget(self.dockButton, 0) self.maxButton = qt.QToolButton(self) self.maxButton.setIcon(qt.QApplication.style().standardIcon( qt.QStyle.SP_TitleBarMaxButton)) self.maxButton.setMaximumSize(buttonSize) self.maxButton.setAutoRaise(True) self.maxButton.clicked.connect(self.toggleMax) layout.addWidget(self.maxButton, 0) self.setTitleBarWidget(self.titleBar) else: self.setTitleBarWidget(None) self.parent().setTabIcons()
def restoreSettings(self, settings): """Restore the window settings using this settings object :param qt.QSettings settings: Initialized settings """ settings.beginGroup("mainwindow") size = settings.value("size", qt.QSize(640, 480)) pos = settings.value("pos", qt.QPoint()) isFullScreen = settings.value("full-screen", False) try: if not isinstance(isFullScreen, bool): isFullScreen = utils.stringToBool(isFullScreen) except ValueError: isFullScreen = False settings.endGroup() settings.beginGroup("mainlayout") try: data = settings.value("spliter") data = [int(d) for d in data] self.__splitter.setSizes(data) except Exception: _logger.debug("Backtrace", exc_info=True) try: data = settings.value("spliter2") data = [int(d) for d in data] self.__splitter2.setSizes(data) except Exception: _logger.debug("Backtrace", exc_info=True) isVisible = settings.value("custom-nxdata-window-visible", False) try: if not isinstance(isVisible, bool): isVisible = utils.stringToBool(isVisible) except ValueError: isVisible = False self.__customNxdataWindow.setVisible(isVisible) self._displayCustomNxdataWindow.setChecked(isVisible) settings.endGroup() settings.beginGroup("content") isSorted = settings.value("is-sorted", True) try: if not isinstance(isSorted, bool): isSorted = utils.stringToBool(isSorted) except ValueError: isSorted = True self.setContentSorted(isSorted) settings.endGroup() if not pos.isNull(): self.move(pos) if not size.isNull(): self.resize(size) if isFullScreen: self.showFullScreen()
def __init__(self, pv, scaler_pv=None, moving_pv=None, moving_val=0, precision=3, limit_hi=9, *args, **kwargs): super().__init__(*args, **kwargs) if scaler_pv: self.count_mode = epics.PV(scaler_pv + '.CONT') self.count_time = epics.PV(scaler_pv + '.TP') self.auto_count_time = epics.PV(scaler_pv + '.TP1') self.setMinimumSize(qt.QSize(120, 30)) self.setMaximumSize(qt.QSize(120, 30)) self.precision = precision self.setFrameShape(qt.QFrame.Panel) self.setFrameShadow(qt.QFrame.Sunken) self.setAlignment(qt.Qt.AlignCenter) self.setText("not connected") self.formatStr = "{:." + str(self.precision) + "f}" self.moving_val = moving_val self.pv = epics.PV(pv, auto_monitor=True) self.pv.add_callback(self.update_value) if moving_pv is not None: self.moving_pv = epics.PV(moving_pv, auto_monitor=True) self.moving_pv.add_callback(self.update_color) self.limit_hi = limit_hi self._dummyIndex = 0 self.notifyTimer = qt.QTimer() self.notifyTimer.timeout.connect(self._notifyColor) self.notifyTimer.start(1000)
def __init__(self, parent=None): qt.QToolBar.__init__(self, parent) self.setIconSize(qt.QSize(16, 16)) action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-active-items")) action.setText("Active items only") action.setToolTip("Display stats for active items only.") action.setCheckable(True) action.setChecked(True) self.__displayActiveItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-items")) action.setText("All items") action.setToolTip("Display stats for all available items.") action.setCheckable(True) self.__displayWholeItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-visible-data")) action.setText("Use the visible data range") action.setToolTip("Use the visible data range.<br/>" "If activated the data is filtered to only use" "visible data of the plot." "The filtering is a data sub-sampling." "No interpolation is made to fit data to" "boundaries.") action.setCheckable(True) self.__useVisibleData = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-data")) action.setText("Use the full data range") action.setToolTip("Use the full data range.") action.setCheckable(True) action.setChecked(True) self.__useWholeData = action self.addAction(self.__displayWholeItems) self.addAction(self.__displayActiveItems) self.addSeparator() self.addAction(self.__useVisibleData) self.addAction(self.__useWholeData) self.itemSelection = qt.QActionGroup(self) self.itemSelection.setExclusive(True) self.itemSelection.addAction(self.__displayActiveItems) self.itemSelection.addAction(self.__displayWholeItems) self.dataRangeSelection = qt.QActionGroup(self) self.dataRangeSelection.setExclusive(True) self.dataRangeSelection.addAction(self.__useWholeData) self.dataRangeSelection.addAction(self.__useVisibleData)
def _listSizeHint(self): if self.__listMode == "icon": return self._listMinimumSizeHint() else: maxWidth = 0 for row in range(self._list.count()): item = self._list.item(row) width = item.sizeHint().width() if maxWidth < width: maxWidth = width return qt.QSize(maxWidth, 10)
def __init__(self, parent=None, n=None): qt.QWidget.__init__(self, parent) # Use the font size as the icon size to avoid to create bigger buttons fontMetric = self.fontMetrics() iconSize = qt.QSize(fontMetric.height(), fontMetric.height()) self.mainLayout = qt.QHBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(0) self.firstButton = qt.QPushButton(self) self.firstButton.setIcon(icons.getQIcon("first")) self.firstButton.setIconSize(iconSize) self.previousButton = qt.QPushButton(self) self.previousButton.setIcon(icons.getQIcon("previous")) self.previousButton.setIconSize(iconSize) self._lineEdit = qt.QLineEdit(self) self._label = qt.QLabel(self) self.nextButton = qt.QPushButton(self) self.nextButton.setIcon(icons.getQIcon("next")) self.nextButton.setIconSize(iconSize) self.lastButton = qt.QPushButton(self) self.lastButton.setIcon(icons.getQIcon("last")) self.lastButton.setIconSize(iconSize) self.mainLayout.addWidget(self.firstButton) self.mainLayout.addWidget(self.previousButton) self.mainLayout.addWidget(self._lineEdit) self.mainLayout.addWidget(self._label) self.mainLayout.addWidget(self.nextButton) self.mainLayout.addWidget(self.lastButton) if n is None: first = qt.QSlider().minimum() last = qt.QSlider().maximum() else: first, last = 0, n self._lineEdit.setFixedWidth(self._lineEdit.fontMetrics().width( '%05d' % last)) validator = qt.QIntValidator(first, last, self._lineEdit) self._lineEdit.setValidator(validator) self._lineEdit.setText("%d" % first) self._label.setText("of %d" % last) self._index = first """0-based index""" self.firstButton.clicked.connect(self._firstClicked) self.previousButton.clicked.connect(self._previousClicked) self.nextButton.clicked.connect(self._nextClicked) self.lastButton.clicked.connect(self._lastClicked) self._lineEdit.editingFinished.connect(self._textChangedSlot)
def sizeHint(self): """Size hint while grow according to the content of the view""" rowCount = self.model().rowCount() size = qt.QTableView.sizeHint(self) if rowCount <= 0: return size height = self.horizontalHeader().size().height() height = height + self.rowHeight(0) * rowCount if height < size.height(): return size size = qt.QSize(size.width(), height) return size
def _createPreviewToolbar(self, parent, dataPreviewWidget, dataSelectorWidget): plot = dataPreviewWidget.plot() toolbar = qt.QToolBar(parent) toolbar.setIconSize(qt.QSize(16, 16)) toolbar.setStyleSheet("QToolBar { border: 0px }") toolbar.addAction(actions.mode.ZoomModeAction(plot, parent)) toolbar.addAction(actions.mode.PanModeAction(plot, parent)) toolbar.addSeparator() toolbar.addAction(actions.control.ResetZoomAction(plot, parent)) toolbar.addSeparator() toolbar.addAction(actions.control.ColormapAction(plot, parent)) return toolbar
def __init__(self, transformNode=None, parent=None, roothPath=None): super(FileTreeView, self).__init__(parent) model = FileSystemWithHdf5Model(transformNode, self) # model = qt.QFileSystemModel(self) # for test purpose if hasattr(transformNode, 'fileNameFilters'): # model.setFilter(qt.QDir.NoDotAndDotDot | qt.QDir.Files) model.fsModel.setNameFilters(transformNode.fileNameFilters) model.fsModel.setNameFilterDisables(False) self.setModel(model) if isinstance(model, FileSystemWithHdf5Model): model.resetRootPath.connect(self._resetRootPath) model.requestSaveExpand.connect(self.saveExpand) model.requestRestoreExpand.connect(self.restoreExpand) else: model.indexFileName = model.index self.transformNode = transformNode if transformNode is not None: self.setItemDelegateForColumn(0, SelectionDelegate(self)) if parent is not None: self.parent().setMouseTracking(True) if roothPath is None: roothPath = '' rootIndex = model.setRootPath(roothPath) self.setRootIndex(rootIndex) self.setMinimumSize(qt.QSize(COLUMN_NAME_WIDTH, 250)) self.setColumnWidth(0, COLUMN_NAME_WIDTH) self.setIndentation(NODE_INDENTATION) self.setSortingEnabled(True) self.sortByColumn(0, qt.Qt.AscendingOrder) self.setSelectionMode(qt.QAbstractItemView.ExtendedSelection) self.setDragEnabled(True) self.setDragDropMode(qt.QAbstractItemView.DragOnly) self.setAcceptDrops(False) self.setDropIndicatorShown(True) self.setContextMenuPolicy(qt.Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.onCustomContextMenu) self.selectionModel().selectionChanged.connect(self.selChanged) self.prevSelectedIndexes = [] if transformNode is not None: strLoad = "Load data (you can also drag it to the data tree)" self.actionLoad = self._addAction( strLoad, self.transformNode.widget.loadFiles, "Ctrl+O") self.actionSynchronize = self._addAction( "Synchronize container", self.synchronizeHDF5, "Ctrl+R") self.actionViewTextFile = self._addAction( "View text file (will be diplayed in 'meta' panel)", self.viewTextFile, "F3")