def __init__(self, parent=None, session=None): super(SearchWidget, self).__init__(parent) self._editor = parent self.hiden = True self.setMinimumSize(100, 100) self.setWindowTitle("Search") self.actionSearch = QtGui.QAction("Search Next", self) self.actionBackSearch = QtGui.QAction("Search Previous", self) self.actionReplace = QtGui.QAction("Replace All", self) self.lineEdit = QtGui.QLineEdit() self.lineEditReplace = QtGui.QLineEdit() self.textSearch = QtGui.QLabel("Search :") self.textReplaceBy = QtGui.QLabel("Replace by :") self.btnNext = QtGui.QToolButton() self.btnPrev = QtGui.QToolButton() self.btnReplace = QtGui.QToolButton() self.btnReplace.setMinimumSize(100, 40) self.btnNext.setMinimumSize(100, 40) self.btnPrev.setMinimumSize(100, 40) self.btnReplace.setDefaultAction(self.actionReplace) self.btnPrev.setDefaultAction(self.actionBackSearch) self.btnNext.setDefaultAction(self.actionSearch) self.caseBtn = QtGui.QCheckBox("Match Case") self.wholeBtn = QtGui.QCheckBox( "Whole Word (Disabled if case sensitive)") QtCore.QObject.connect(self.actionBackSearch, QtCore.SIGNAL('triggered(bool)'), self.searchBack) QtCore.QObject.connect(self.actionSearch, QtCore.SIGNAL('triggered(bool)'), self.search) QtCore.QObject.connect(self.actionReplace, QtCore.SIGNAL('triggered(bool)'), self.replaceall) QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL('returnPressed()'), self.search) layout = QtGui.QGridLayout() layout.setAlignment(QtCore.Qt.AlignLeft) layout.addWidget(self.textSearch, 0, 0) layout.addWidget(self.lineEdit, 0, 1, 1, 2) layout.addWidget(self.textReplaceBy, 1, 0) layout.addWidget(self.lineEditReplace, 1, 1, 1, 2) layout.addWidget(self.caseBtn, 2, 0) layout.addWidget(self.wholeBtn, 2, 1) layout.addWidget(self.btnReplace, 3, 0) layout.addWidget(self.btnPrev, 3, 1) layout.addWidget(self.btnNext, 3, 2) self.setLayout(layout)
def setShowDockInMenu(self): """ Use it to add show/hide dockwidget in menu """ children = self.findChildren(QtGui.QDockWidget) for child in children: name = child.windowTitle() if name.lower() == "menu": continue btn = QtGui.QCheckBox(name, self) btn.setChecked(child.isVisibleTo(self)) btn.toggled.connect(child.setVisible) # child.visibilityChanged.connect(btn.setChecked) child._actions = [ ["View", "Show", btn, "smallwidget"], ] def actions(self): return self._actions child.actions = types.MethodType(actions, child) self.controller.connect_actions(child)
def create_buttons(self): """ Remove old buttons and add new ones. """ # Manage in the new func layout = self.layout() for w in self.widgets: layout.removeWidget(w) self.widgets = [] for i, elt in enumerate(self.in_list): elt_name = str(elt) button = QtGui.QCheckBox(elt_name) button.setChecked(True) self.connect(button, QtCore.SIGNAL("clicked()"), lambda index=i: self.reactToClick(index)) layout.addWidget(button) self.widgets.append(button)
def make_widget(self, typ, value, parent): """ Take this value and type and make me a nice widget please. The widget is wrapped in a SenderWidget and can be accessed through the widget.inner attribute.""" w = None if typ == bool: w = QtGui.QCheckBox(parent) w.setCheckState( QtCore.Qt.Checked if value else QtCore.Qt.Unchecked) elif typ == tuple: w = QtGui.QLineEdit(str(value), parent) elif typ == int: w = QtGui.QSpinBox(parent) w.setRange(-10000, 10000) w.setSingleStep(1) elif typ == float: w = QtGui.QDoubleSpinBox(parent) w.setRange(-10000.0, 10000.0) w.setSingleStep(0.01) if w is not None: wrapper = SenderWidget(w, typ, self) wrapper.valueChanged.connect(self.__on_widget_changed) return wrapper