Beispiel #1
0
    def __init__(self, manager, name, log_sub):
        QDockWidgetCloseDetect.__init__(self, "Log")
        self.setObjectName(name)

        grid = LayoutWidget()
        self.setWidget(grid)

        grid.addWidget(QtWidgets.QLabel("Minimum level: "), 0, 0)
        self.filter_level = QtWidgets.QComboBox()
        self.filter_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
        self.filter_level.setToolTip("Display entries at or above this level")
        grid.addWidget(self.filter_level, 0, 1)
        self.filter_level.currentIndexChanged.connect(
            self.filter_level_changed)
        self.filter_freetext = QtWidgets.QLineEdit()
        self.filter_freetext.setPlaceholderText("freetext filter...")
        self.filter_freetext.editingFinished.connect(
            self.filter_freetext_changed)
        grid.addWidget(self.filter_freetext, 0, 2)

        scrollbottom = QtWidgets.QToolButton()
        scrollbottom.setToolTip("Scroll to bottom")
        scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_ArrowDown))
        grid.addWidget(scrollbottom, 0, 3)
        scrollbottom.clicked.connect(self.scroll_to_bottom)
        newdock = QtWidgets.QToolButton()
        newdock.setToolTip("Create new log dock")
        newdock.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_FileDialogNewFolder))
        # note the lambda, the default parameter is overriden otherwise
        newdock.clicked.connect(lambda: manager.create_new_dock())
        grid.addWidget(newdock, 0, 4)
        grid.layout.setColumnStretch(2, 1)

        self.log = QtWidgets.QTreeView()
        self.log.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.log.setHorizontalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setVerticalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        grid.addWidget(self.log, 1, 0, colspan=5)
        self.scroll_at_bottom = False
        self.scroll_value = 0

        # If Qt worked correctly, this would be nice to have. Alas, resizeSections
        # is broken when the horizontal scrollbar is enabled.
        # self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        # sizeheader_action = QtWidgets.QAction("Resize header", self.log)
        # sizeheader_action.triggered.connect(
        #     lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeToContents))
        # self.log.addAction(sizeheader_action)

        log_sub.add_setmodel_callback(self.set_model)

        cw = QtGui.QFontMetrics(self.font()).averageCharWidth()
        self.log.header().resizeSection(0, 26*cw)
Beispiel #2
0
    def __init__(self, datasets_sub, uid, name, spec):
        QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
        self.setObjectName("applet" + str(uid))

        qfm = QtGui.QFontMetrics(self.font())
        self.setMinimumSize(20 * qfm.averageCharWidth(), 5 * qfm.lineSpacing())
        self.resize(40 * qfm.averageCharWidth(), 10 * qfm.lineSpacing())

        self.datasets_sub = datasets_sub
        self.applet_name = name
        self.spec = spec

        self.starting_stopping = False
Beispiel #3
0
    def __init__(self, datasets_sub, uid, name, command):
        QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
        self.setObjectName("applet" + str(uid))

        qfm = QtGui.QFontMetrics(self.font())
        self.setMinimumSize(20*qfm.averageCharWidth(), 5*qfm.lineSpacing())
        self.resize(40*qfm.averageCharWidth(), 10*qfm.lineSpacing())

        self.datasets_sub = datasets_sub
        self.applet_name = name
        self.command = command

        self.starting_stopping = False
Beispiel #4
0
 def __init__(self, main_window):
     QDockWidgetCloseDetect.__init__(self, "Real Complicated Grapher")
     self.setObjectName("RCG")
     self.main_window = main_window
     self.is_closed = False
     self.main_window.addDockWidget(QtCore.Qt.TopDockWidgetArea, self)
     self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable)
     self.setFloating(True)
     self.rcg = RCG()
     self.setWidget(self.rcg)
     self.setTitleBarWidget(QtWidgets.QMainWindow())
     self.top_level_changed()
     self.connect_server()
Beispiel #5
0
    def __init__(self, manager, name):
        QDockWidgetCloseDetect.__init__(self, "Log")
        self.setObjectName(name)

        grid = LayoutWidget()
        self.setWidget(grid)

        grid.addWidget(QtWidgets.QLabel("Minimum level: "), 0, 0)
        self.filter_level = QtWidgets.QComboBox()
        self.filter_level.addItems(
            ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
        self.filter_level.setToolTip("Receive entries at or above this level")
        grid.addWidget(self.filter_level, 0, 1)
        self.filter_freetext = QtWidgets.QLineEdit()
        self.filter_freetext.setPlaceholderText("freetext filter...")
        self.filter_freetext.setToolTip("Receive entries containing this text")
        grid.addWidget(self.filter_freetext, 0, 2)

        scrollbottom = QtWidgets.QToolButton()
        scrollbottom.setToolTip("Scroll to bottom")
        scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_ArrowDown))
        grid.addWidget(scrollbottom, 0, 3)
        scrollbottom.clicked.connect(self.scroll_to_bottom)

        clear = QtWidgets.QToolButton()
        clear.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_DialogResetButton))
        grid.addWidget(clear, 0, 4)
        clear.clicked.connect(lambda: self.model.clear())

        if manager:
            newdock = QtWidgets.QToolButton()
            newdock.setToolTip("Create new log dock")
            newdock.setIcon(QtWidgets.QApplication.style().standardIcon(
                QtWidgets.QStyle.SP_FileDialogNewFolder))
            # note the lambda, the default parameter is overriden otherwise
            newdock.clicked.connect(lambda: manager.create_new_dock())
            grid.addWidget(newdock, 0, 5)
        grid.layout.setColumnStretch(2, 1)

        self.log = QtWidgets.QTreeView()
        self.log.setHorizontalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setVerticalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        grid.addWidget(self.log, 1, 0, colspan=6 if manager else 5)
        self.scroll_at_bottom = False
        self.scroll_value = 0

        self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        copy_action = QtWidgets.QAction("Copy entry to clipboard", self.log)
        copy_action.triggered.connect(self.copy_to_clipboard)
        self.log.addAction(copy_action)
        clear_action = QtWidgets.QAction("Clear", self.log)
        clear_action.triggered.connect(lambda: self.model.clear())
        self.log.addAction(clear_action)

        # If Qt worked correctly, this would be nice to have. Alas, resizeSections
        # is broken when the horizontal scrollbar is enabled.
        # sizeheader_action = QtWidgets.QAction("Resize header", self.log)
        # sizeheader_action.triggered.connect(
        #     lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeToContents))
        # self.log.addAction(sizeheader_action)

        cw = QtGui.QFontMetrics(self.font()).averageCharWidth()
        self.log.header().resizeSection(0, 26 * cw)

        self.model = _Model()
        self.log.setModel(self.model)
        self.model.rowsAboutToBeInserted.connect(self.rows_inserted_before)
        self.model.rowsInserted.connect(self.rows_inserted_after)
        self.model.rowsRemoved.connect(self.rows_removed)
Beispiel #6
0
    def __init__(self, manager, name):
        QDockWidgetCloseDetect.__init__(self, "Log")
        self.setObjectName(name)

        grid = LayoutWidget()
        self.setWidget(grid)

        grid.addWidget(QtWidgets.QLabel("Minimum level: "), 0, 0)
        self.filter_level = QtWidgets.QComboBox()
        self.filter_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
        self.filter_level.setToolTip("Receive entries at or above this level")
        grid.addWidget(self.filter_level, 0, 1)
        self.filter_freetext = QtWidgets.QLineEdit()
        self.filter_freetext.setPlaceholderText("freetext filter...")
        self.filter_freetext.setToolTip("Receive entries containing this text")
        grid.addWidget(self.filter_freetext, 0, 2)

        scrollbottom = QtWidgets.QToolButton()
        scrollbottom.setToolTip("Scroll to bottom")
        scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_ArrowDown))
        grid.addWidget(scrollbottom, 0, 3)
        scrollbottom.clicked.connect(self.scroll_to_bottom)

        clear = QtWidgets.QToolButton()
        clear.setIcon(QtWidgets.QApplication.style().standardIcon(
            QtWidgets.QStyle.SP_DialogResetButton))
        grid.addWidget(clear, 0, 4)
        clear.clicked.connect(lambda: self.model.clear())

        if manager:
            newdock = QtWidgets.QToolButton()
            newdock.setToolTip("Create new log dock")
            newdock.setIcon(QtWidgets.QApplication.style().standardIcon(
                QtWidgets.QStyle.SP_FileDialogNewFolder))
            # note the lambda, the default parameter is overriden otherwise
            newdock.clicked.connect(lambda: manager.create_new_dock())
            grid.addWidget(newdock, 0, 5)
        grid.layout.setColumnStretch(2, 1)

        self.log = QtWidgets.QTreeView()
        self.log.setHorizontalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setVerticalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)
        self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        grid.addWidget(self.log, 1, 0, colspan=6 if manager else 5)
        self.scroll_at_bottom = False
        self.scroll_value = 0

        self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        copy_action = QtWidgets.QAction("Copy entry to clipboard", self.log)
        copy_action.triggered.connect(self.copy_to_clipboard)
        self.log.addAction(copy_action)
        clear_action = QtWidgets.QAction("Clear", self.log)
        clear_action.triggered.connect(lambda: self.model.clear())
        self.log.addAction(clear_action)

        # If Qt worked correctly, this would be nice to have. Alas, resizeSections
        # is broken when the horizontal scrollbar is enabled.
        # sizeheader_action = QtWidgets.QAction("Resize header", self.log)
        # sizeheader_action.triggered.connect(
        #     lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeToContents))
        # self.log.addAction(sizeheader_action)

        cw = QtGui.QFontMetrics(self.font()).averageCharWidth()
        self.log.header().resizeSection(0, 26*cw)

        self.model = _Model()
        self.log.setModel(self.model)
        self.model.rowsAboutToBeInserted.connect(self.rows_inserted_before)
        self.model.rowsInserted.connect(self.rows_inserted_after)
        self.model.rowsRemoved.connect(self.rows_removed)