def create_layout(cls, layout='vertical', margin=0): if layout == 'vertical': from pyvmmonitor_qt.qt.QtWidgets import QVBoxLayout layout = QVBoxLayout() else: from pyvmmonitor_qt.qt.QtWidgets import QHBoxLayout layout = QHBoxLayout() layout.setContentsMargins(margin, margin, margin, margin) return layout
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)