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 _create_actions(self): # Create actions self.actionRun = QtGui.QAction(qicon("run.png"), "Run", self) self.actionRunInShell = QtGui.QAction(qicon("run.png"), "Run in shell", self) menu_run = QtGui.QMenu("Run", self) menu_run.addActions([self.actionRun, self.actionRunInShell]) self.toolbutton_run = QtGui.QToolButton(self) self.toolbutton_run.setMenu(menu_run) self.toolbutton_run.setDefaultAction(self.actionRun) self.actionAnimate = QtGui.QAction(qicon("play.png"), "Animate", self) self.actionStep = QtGui.QAction(qicon("step.png"), "Step", self) self.actionStop = QtGui.QAction(qicon("pause.png"), "Stop", self) self.actionInit = QtGui.QAction(qicon("rewind.png"), "Init", self) self.actionRunSelection = QtGui.QAction(qicon("run.png"), "Run subpart", self) # File I/O self.actionCloseCurrent = QtGui.QAction(qicon("close_file.png"), "Close current tab", self) self.actionOpenFile = QtGui.QAction(qicon("open_file.png"), "Open file", self) self.actionSave = QtGui.QAction(qicon("save_file.png"), "Save File", self) self.actionSaveAs = QtGui.QAction(qicon("save_file.png"), "Save As", self) # Add shortcuts #self.actionInit.setShortcut("F1") self.actionAnimate.setShortcut("F2") self.actionRun.setShortcuts(["F1", "Ctrl+R"]) self.actionRunSelection.setShortcut(self.tr("Ctrl+E")) self.actionStep.setShortcut("F3") self.actionStop.setShortcut("F4") self.actionCloseCurrent.setShortcut(self.tr("Ctrl+W")) self.actionOpenFile.setShortcut(self.tr("Ctrl+O")) self.actionSave.setShortcut(self.tr("Ctrl+S")) #self.actionSaveAs.setShortcut(self.tr("Ctrl+Shift+S")) # Store actions self._run_actions = [ self.actionAnimate, self.actionInit, self.toolbutton_run, self.actionRunSelection, self.actionStep, self.actionStop, ] self._actions = [ ["Project", "Play", self.actionRun, 0], ["Project", "Play", self.actionAnimate, 0], ["Project", "Play", self.actionStep, 0], ["Project", "Play", self.actionStop, 0], ["Project", "Play", self.actionInit, 0], ]
def set_actions(self, actions): self._buttons = [] for i, action in enumerate(actions): button = QtGui.QToolButton() button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) button.setDefaultAction(action) self._buttons.append(button) self._fill_layout(self._buttons)
def set_actions(self, actions): for i in reversed(range(self._layout.count())): widget = self._layout.itemAt(i).widget() widget.setParent(None) self._layout.removeWidget(widget) w = self.size().width() nx = w / self.button_size.width() if nx == 0: nx = 1 for i, action in enumerate(actions): button = QtGui.QToolButton() button.setFixedSize(self.button_size) # button.setStyleSheet(self.stylesheet) button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) qsize = QtCore.QSize(self.icon_size) button.setDefaultAction(action) button.setIconSize(qsize) self._layout.addWidget(button, i / nx, i % nx)
def __init__(self, parent=None): super(GoToWidget, self).__init__() self.editor = parent self.setMinimumSize(100, 100) self.setWindowTitle("Go To Line") self.actionGo = QtGui.QAction("Go to line", self) self.lineEdit = QtGui.QLineEdit() self.btnGo = QtGui.QToolButton() self.btnGo.setDefaultAction(self.actionGo) QtCore.QObject.connect(self.actionGo, QtCore.SIGNAL('triggered(bool)'), self.go) QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL('returnPressed()'), self.go) layout = QtGui.QGridLayout() layout.setAlignment(QtCore.Qt.AlignLeft) layout.addWidget(self.lineEdit, 0, 0) layout.addWidget(self.btnGo, 0, 1) self.setLayout(layout) self.hide()