def __init__(self, editor): # New style doesn't work: QtWidgets.QDialog.__init__(self, editor, Qt.Window) self.setWindowTitle('Find and replace') self._editor = editor # Fix background color of line edits self.setStyleSheet('QLineEdit{background: white;}') # Create widgets self._close_button = QtWidgets.QPushButton('Close') self._close_button.clicked.connect(self.action_close) self._replace_all_button = QtWidgets.QPushButton('Replace all') self._replace_all_button.clicked.connect(self.action_replace_all) self._replace_button = QtWidgets.QPushButton('Replace') self._replace_button.clicked.connect(self.action_replace) self._find_button = QtWidgets.QPushButton('Find') self._find_button.clicked.connect(self.action_find) self._search_label = QtWidgets.QLabel('Search for') self._search_field = QtWidgets.QLineEdit() self._replace_label = QtWidgets.QLabel('Replace with') self._replace_field = QtWidgets.QLineEdit() self._case_check = QtWidgets.QCheckBox('Case sensitive') self._whole_check = QtWidgets.QCheckBox('Match whole word only') # Create layout text_layout = QtWidgets.QGridLayout() text_layout.addWidget(self._search_label, 0, 0) text_layout.addWidget(self._search_field, 0, 1) text_layout.addWidget(self._replace_label, 1, 0) text_layout.addWidget(self._replace_field, 1, 1) check_layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom) check_layout.addWidget(self._case_check) check_layout.addWidget(self._whole_check) button_layout = QtWidgets.QGridLayout() button_layout.addWidget(self._close_button, 0, 0) button_layout.addWidget(self._replace_all_button, 0, 1) button_layout.addWidget(self._replace_button, 0, 2) button_layout.addWidget(self._find_button, 0, 3) layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom) layout.addLayout(text_layout) layout.addLayout(check_layout) layout.addLayout(button_layout) self.setLayout(layout) self._search_field.setEnabled(True) self._replace_field.setEnabled(True)
def __init__(self, parent, editor): super(FindReplaceWidget, self).__init__(parent) self._editor = editor # Create widgets self._replace_all_button = QtWidgets.QPushButton('Replace all') self._replace_all_button.clicked.connect(self.action_replace_all) self._replace_button = QtWidgets.QPushButton('Replace') self._replace_button.clicked.connect(self.action_replace) self._find_button = QtWidgets.QPushButton('Find') self._find_button.clicked.connect(self.action_find) self._search_label = QtWidgets.QLabel('Search for') self._search_field = QtWidgets.QLineEdit() self._replace_label = QtWidgets.QLabel('Replace with') self._replace_field = QtWidgets.QLineEdit() self._case_check = QtWidgets.QCheckBox('Case sensitive') self._whole_check = QtWidgets.QCheckBox('Match whole word only') # Create layout text_layout = QtWidgets.QGridLayout() text_layout.addWidget(self._search_label, 0, 0) text_layout.addWidget(self._search_field, 0, 1) text_layout.addWidget(self._replace_label, 1, 0) text_layout.addWidget(self._replace_field, 1, 1) check_layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom) check_layout.addWidget(self._case_check) check_layout.addWidget(self._whole_check) button_layout = QtWidgets.QGridLayout() button_layout.addWidget(self._replace_all_button, 0, 1) button_layout.addWidget(self._replace_button, 0, 2) button_layout.addWidget(self._find_button, 0, 3) layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom) layout.addLayout(text_layout) layout.addLayout(check_layout) layout.addLayout(button_layout) layout.addStretch(1) self.setLayout(layout) # Accept keyboard focus on search and replace fields self._search_field.setEnabled(True) self._replace_field.setEnabled(True)
def __init__(self, parent, sim_method, output_stream, duration=1000): super(Explorer, self).__init__(parent) self.setWindowTitle('Myokit Explorer') self._sim_method = sim_method self._stream = output_stream # Set guess for run times guess_pre = 0 guess_run = duration # Explorer data self._data = None self._keys = None # Fix background color of line edits self.setStyleSheet('QLineEdit{background: white;}') # Create top widgets label1 = QtWidgets.QLabel('Run unlogged for ') label2 = QtWidgets.QLabel(' and then log for ') self._pre_field = QtWidgets.QLineEdit(str(guess_pre)) self._pre_valid = QtGui.QDoubleValidator() self._pre_valid.setBottom(0) self._pre_field.setValidator(self._pre_valid) self._run_field = QtWidgets.QLineEdit(str(guess_run)) self._run_valid = QtGui.QDoubleValidator() self._run_valid.setBottom(0) self._run_field.setValidator(self._run_valid) self._clear_button = QtWidgets.QPushButton('Clear graphs') self._clear_button.clicked.connect(self.action_clear) self._run_button = QtWidgets.QPushButton('Run') self._run_button.clicked.connect(self.action_run) # Create graph widgets self._axes = None self._figure = matplotlib.figure.Figure() self._canvas = backend.FigureCanvasQTAgg(self._figure) self._toolbar = backend.NavigationToolbar2QT(self._canvas, self) self._select_x = QtWidgets.QComboBox() self._select_x.currentIndexChanged.connect(self.combo_changed) self._select_y = QtWidgets.QComboBox() self._select_y.currentIndexChanged.connect(self.combo_changed) # Create bottom widgets self._close_button = QtWidgets.QPushButton('Close') self._close_button.clicked.connect(self.action_close) # Create button layout button_layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.LeftToRight) button_layout.addWidget(label1) button_layout.addWidget(self._pre_field) button_layout.addWidget(label2) button_layout.addWidget(self._run_field) button_layout.addWidget(self._clear_button) button_layout.addWidget(self._run_button) # Create graph options layout graph_option_layout = QtWidgets.QBoxLayout( QtWidgets.QBoxLayout.LeftToRight) graph_option_layout.addWidget(self._select_x) graph_option_layout.addWidget(self._select_y) # Create bottom layout bottom_layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.LeftToRight) bottom_layout.addWidget(self._close_button) # Create central layout layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom) layout.addLayout(button_layout) layout.addLayout(graph_option_layout) layout.addWidget(self._canvas) layout.addWidget(self._toolbar) layout.addLayout(bottom_layout) self.setLayout(layout)