示例#1
0
class ShortcutsConfigWidget(QWidget):
    def __init__(self, shortcuts_manager):
        '''
        :param IShortcutsManager shortcuts_manager:
        '''
        QWidget.__init__(self)
        from pyvmmonitor_qt.qt.QtWidgets import QTreeView
        self._shortcuts = QTreeView(self)

        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        self._vlayout = QVBoxLayout(self)
        self._vlayout.addWidget(self._shortcuts)
        self.setLayout(self._vlayout)

        from pyvmmonitor_qt.tree.pythonic_tree_view import PythonicQTreeView
        self._pythonic_tree = PythonicQTreeView(self._shortcuts)
        self._pythonic_tree.columns = ['Action', 'Shortcut']
class ShortcutsConfigWidget(QWidget):

    def __init__(self, shortcuts_manager):
        '''
        :param IShortcutsManager shortcuts_manager:
        '''
        QWidget.__init__(self)
        from pyvmmonitor_qt.qt.QtWidgets import QTreeView
        self._shortcuts = QTreeView(self)

        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        self._vlayout = QVBoxLayout(self)
        self._vlayout.addWidget(self._shortcuts)
        self.setLayout(self._vlayout)

        from pyvmmonitor_qt.tree.pythonic_tree_view import PythonicQTreeView
        self._pythonic_tree = PythonicQTreeView(self._shortcuts)
        self._pythonic_tree.columns = ['Action', 'Shortcut']
class FilteredTreeViewWidget(QWidget):
    def __init__(self, pythonic_tree_view=None):
        QWidget.__init__(self)
        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        self._vbox = QVBoxLayout(self)

        from pyvmmonitor_qt.qt.QtWidgets import QLineEdit
        self._edit_text_filter = QLineEdit(self)
        self._vbox.addWidget(self._edit_text_filter)

        if pythonic_tree_view is None:
            from pyvmmonitor_qt.tree.pythonic_tree_view import PythonicQTreeView
            from pyvmmonitor_qt.qt.QtWidgets import QTreeView
            tree = QTreeView(self)
            pythonic_tree_view = PythonicQTreeView(tree)
        else:
            pythonic_tree_view.tree.setParent(self)

        self._vbox.addWidget(pythonic_tree_view.tree)
        self.setLayout(self._vbox)
        self._pythonic_tree_view = pythonic_tree_view

        self._edit_text_filter.textChanged.connect(
            self._on_filter_text_changed)

    def _on_filter_text_changed(self, *args, **kwargs):
        self._pythonic_tree_view.filter_text = self.filter_text

    @property
    def filter_text(self):
        return self._edit_text_filter.text()

    @filter_text.setter
    def filter_text(self, text):
        self._edit_text_filter.setText(text)
        self._pythonic_tree_view.filter_text = text

    @property
    def tree(self):
        return self._pythonic_tree_view.tree

    @property
    def pythonic_tree_view(self):
        return self._pythonic_tree_view
class FilteredTreeViewWidget(QWidget):

    def __init__(self, pythonic_tree_view=None):
        QWidget.__init__(self)
        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        self._vbox = QVBoxLayout(self)

        from pyvmmonitor_qt.qt.QtWidgets import QLineEdit
        self._edit_text_filter = QLineEdit(self)
        self._vbox.addWidget(self._edit_text_filter)

        if pythonic_tree_view is None:
            from pyvmmonitor_qt.tree.pythonic_tree_view import PythonicQTreeView
            from pyvmmonitor_qt.qt.QtWidgets import QTreeView
            tree = QTreeView(self)
            pythonic_tree_view = PythonicQTreeView(tree)
        else:
            pythonic_tree_view.tree.setParent(self)

        self._vbox.addWidget(pythonic_tree_view.tree)
        self.setLayout(self._vbox)
        self._pythonic_tree_view = pythonic_tree_view

        self._edit_text_filter.textChanged.connect(self._on_filter_text_changed)

    def _on_filter_text_changed(self, *args, **kwargs):
        self._pythonic_tree_view.filter_text = self.filter_text

    @property
    def filter_text(self):
        return self._edit_text_filter.text()

    @filter_text.setter
    def filter_text(self, text):
        self._edit_text_filter.setText(text)
        self._pythonic_tree_view.filter_text = text

    @property
    def tree(self):
        return self._pythonic_tree_view.tree

    @property
    def pythonic_tree_view(self):
        return self._pythonic_tree_view
示例#5
0
    def __init__(self, parent=None):
        super(QtTermWidget, self).__init__(parent)

        layout = QVBoxLayout(self)
        self._splitter = QSplitter(QtCore.Qt.Vertical, self)
        layout.addWidget(self._splitter)

        self._results = QtTermResultsWidget(self)
        self._splitter.addWidget(self._results)

        self._entry = QtTermEntryWidget(self)
        self._splitter.addWidget(self._entry)

        self.setLayout(layout)

        self._tracebacks = []

        self._entry.traceback.connect(self._results.handleTraceback)

        self._entry.stdoutRedirect.output.connect(self._results.handleOutput)
示例#6
0
    def __init__(self, parent, font=None, lexer=None):
        super(AdvancedCodeWidget, self).__init__(parent)

        self.code = CodeWidget(self, font=font, lexer=lexer)
        self.find = FindWidget(self)
        self.find.hide()
        self.replace = ReplaceWidget(self)
        self.replace.hide()
        self.replace.replace_button.setEnabled(False)
        self.replace.replace_all_button.setEnabled(False)

        self.active_find_widget = None
        self.previous_find_widget = None

        self.code.selectionChanged.connect(self._update_replace_enabled)

        self.find.line_edit.returnPressed.connect(self.find_next)
        self.find.next_button.clicked.connect(self.find_next)
        self.find.prev_button.clicked.connect(self.find_prev)

        self.replace.line_edit.returnPressed.connect(self.find_next)
        self.replace.line_edit.textChanged.connect(
            self._update_replace_all_enabled)
        self.replace.next_button.clicked.connect(self.find_next)
        self.replace.prev_button.clicked.connect(self.find_prev)
        self.replace.replace_button.clicked.connect(self.replace_next)
        self.replace.replace_all_button.clicked.connect(self.replace_all)

        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.code)
        layout.addWidget(self.find)
        layout.addWidget(self.replace)

        self.setLayout(layout)
示例#7
0
    def __init__(self, parent, font=None, lexer=None):
        super(AdvancedCodeWidget, self).__init__(parent)

        self.code = CodeWidget(self, font=font, lexer=lexer)
        self.find = FindWidget(self)
        self.find.hide()
        self.replace = ReplaceWidget(self)
        self.replace.hide()
        self.replace.replace_button.setEnabled(False)
        self.replace.replace_all_button.setEnabled(False)

        self.active_find_widget = None
        self.previous_find_widget = None

        self.code.selectionChanged.connect(self._update_replace_enabled)

        self.find.line_edit.returnPressed.connect(self.find_next)
        self.find.next_button.clicked.connect(self.find_next)
        self.find.prev_button.clicked.connect(self.find_prev)

        self.replace.line_edit.returnPressed.connect(self.find_next)
        self.replace.line_edit.textChanged.connect(
            self._update_replace_all_enabled)
        self.replace.next_button.clicked.connect(self.find_next)
        self.replace.prev_button.clicked.connect(self.find_prev)
        self.replace.replace_button.clicked.connect(self.replace_next)
        self.replace.replace_all_button.clicked.connect(self.replace_all)

        from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.code)
        layout.addWidget(self.find)
        layout.addWidget(self.replace)

        self.setLayout(layout)
class CustomCloseTabWidget(QWidget):

    def __init__(self):
        QWidget.__init__(self)

        self._layout = QVBoxLayout(self)
        self._layout.setSpacing(0)

        self._tabbar = QTabBar(self)
        self._tabbar.currentChanged.connect(self._tab_changed)
        self._layout.addWidget(self._tabbar)

        self._stack = QStackedWidget(self)
        self._layout.addWidget(self._stack)

        self._widgets = []
        self._buttons = []
        self.setLayout(self._layout)
        # Called with: on_remove_requested(index)
        self.on_remove_requested = Callback()

    def _tab_changed(self, i):
        try:
            widget = self._widgets[i]
        except Exception:
            return  # Not there

        self._stack.setCurrentWidget(widget)

    def tab_text(self, i):
        return self._tabbar.tabText(i)
    tabText = tab_text

    def set_tab_text(self, i, text):
        return self._tabbar.setTabText(i, text)
    setTabText = set_tab_text

    def current_index(self):
        return self._tabbar.currentIndex()

    currentIndex = current_index

    def current_widget(self):
        return self._stack.currentWidget()

    currentWidget = current_widget

    def count(self):
        return len(self._widgets)

    __len__ = count

    def __iter__(self):
        i = 0
        while i < len(self):
            yield self.widget(i)
            i += 1

    def remove_tab(self, index):
        del self._widgets[index]
        del self._buttons[index]
        self._tabbar.removeTab(index)
    removeTab = remove_tab

    def index(self, widget):
        try:
            return self._widgets.index(widget)
        except ValueError:
            return -1

    def widget(self, i):
        return self._widgets[i]

    def add_tab(self, widget, label, closeable):
        widget.setParent(self._stack)

        self._widgets.append(widget)
        self._stack.addWidget(widget)
        self._tabbar.addTab(label)

        if closeable:

            bt = QPushButton(self._tabbar)
            bt.setFixedSize(20, 20)
            bt.setIcon(bt.style().standardIcon(QStyle.SP_DockWidgetCloseButton))
            self._tabbar.setTabButton(len(self._widgets) - 1, QTabBar.RightSide, bt)
            self._buttons.append(bt)

            weak_bt = weakref.ref(bt)
            weak_tab_widget = weakref.ref(self)

            def on_close():
                self = weak_tab_widget()
                bt = weak_bt()
                if self is None or bt is None:
                    return
                if not qt_utils.is_qobject_alive(self) or not qt_utils.is_qobject_alive(bt):
                    return
                i = self._buttons.index(bt)
                if i != -1:
                    self.on_remove_requested(i)
            bt.clicked.connect(on_close)
        else:
            self._buttons.append(None)

    addTab = add_tab
示例#9
0
class CustomCloseTabWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self._layout = QVBoxLayout(self)
        self._layout.setSpacing(0)

        self._tabbar = QTabBar(self)
        self._tabbar.currentChanged.connect(self._tab_changed)
        self._layout.addWidget(self._tabbar)

        self._stack = QStackedWidget(self)
        self._layout.addWidget(self._stack)

        self._widgets = []
        self._buttons = []
        self.setLayout(self._layout)
        # Called with: on_remove_requested(index)
        self.on_remove_requested = Callback()

    def _tab_changed(self, i):
        try:
            widget = self._widgets[i]
        except Exception:
            return  # Not there

        self._stack.setCurrentWidget(widget)

    def tab_text(self, i):
        return self._tabbar.tabText(i)

    tabText = tab_text

    def set_tab_text(self, i, text):
        return self._tabbar.setTabText(i, text)

    setTabText = set_tab_text

    def current_index(self):
        return self._tabbar.currentIndex()

    currentIndex = current_index

    def current_widget(self):
        return self._stack.currentWidget()

    currentWidget = current_widget

    def count(self):
        return len(self._widgets)

    __len__ = count

    def __iter__(self):
        i = 0
        while i < len(self):
            yield self.widget(i)
            i += 1

    def remove_tab(self, index):
        del self._widgets[index]
        del self._buttons[index]
        self._tabbar.removeTab(index)

    removeTab = remove_tab

    def index(self, widget):
        try:
            return self._widgets.index(widget)
        except ValueError:
            return -1

    def widget(self, i):
        return self._widgets[i]

    def add_tab(self, widget, label, closeable):
        widget.setParent(self._stack)

        self._widgets.append(widget)
        self._stack.addWidget(widget)
        self._tabbar.addTab(label)

        if closeable:

            bt = QPushButton(self._tabbar)
            bt.setFixedSize(20, 20)
            bt.setIcon(bt.style().standardIcon(
                QStyle.SP_DockWidgetCloseButton))
            self._tabbar.setTabButton(
                len(self._widgets) - 1, QTabBar.RightSide, bt)
            self._buttons.append(bt)

            weak_bt = weakref.ref(bt)
            weak_tab_widget = weakref.ref(self)

            def on_close():
                self = weak_tab_widget()
                bt = weak_bt()
                if self is None or bt is None:
                    return
                if not qt_utils.is_qobject_alive(
                        self) or not qt_utils.is_qobject_alive(bt):
                    return
                i = self._buttons.index(bt)
                if i != -1:
                    self.on_remove_requested(i)

            bt.clicked.connect(on_close)
        else:
            self._buttons.append(None)

    addTab = add_tab