def init_toolbar(self): # x-scale slider self._xscale_slider = PopupSlider( orientation = QtCore.Qt.Horizontal ) xslider = self._xscale_slider.slider() xslider.setRange(2, 42) xslider.setSingleStep(1) xslider.valueChanged.connect( self.set_xscale ) xslider.setValue(10) # y-scale slider self._yscale_slider = PopupSlider( orientation = QtCore.Qt.Vertical ) yslider = self._yscale_slider.slider() yslider.setRange(1, 21) yslider.setSingleStep(1) yslider.valueChanged.connect( self.set_yscale ) yslider.setValue(10) self._searchbox = QtWidgets.QLineEdit('Search') self._searchbox.setMaxLength(32) self._searchbox.returnPressed.connect( self.do_search ) self._panesplit = QtWidgets.QSpinBox() self._panesplit.setRange(1, 8) self._panesplit.setSingleStep(1) self._panesplit.valueChanged.connect( self.set_split ) self._panesplit.setValue( 4 )
def init_statusbar(self): # divide by 3 parts self._caretpos = QtWidgets.QLabel('') self._msg = QtWidgets.QLabel("Sequence Pane") self._status = QtWidgets.QLabel("Status indicator") self._statusbar.addPermanentWidget(self._msg, 1) self._statusbar.addPermanentWidget(self._status, 1) self._statusbar.addPermanentWidget(self._caretpos, 2)
def init_hscrollbar(self): """ this function initialize horizontal scrollbar, further setting up of the scrollbar will be performed during resizeEvent by width_hint() """ if self.have_hscrollbar: self._hscrollbar = QtWidgets.QScrollBar(QtCore.Qt.Horizontal) self._layout.addWidget(self._hscrollbar) else: self._layout.addSpacing( QtWidgets.QScrollBar(QtCore.Qt.Horizontal).sizeHint().height())
def __init__(self, parent=None, orientation=QtCore.Qt.Vertical, length=100): super(PopupSlider, self).__init__( parent, QtCore.Qt.Popup ) self._slider = QtWidgets.QSlider(orientation) self._toolbutton = None if orientation == QtCore.Qt.Vertical: self.resize( self._slider.sizeHint().width(), 100 ) else: self.resize( 100, self._slider.sizeHint().height() ) layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(0,0,0,0) layout.setSpacing(0) layout.addWidget( self._slider, 0 ) self.setLayout( layout )
def init_layout(self): self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._layout.addWidget(self._splitter, 1) if self._vscrollbarpane: self._layout.addWidget(self._vscrollbarpane, 0) self.setLayout(self._layout)
def __init__(self, parent=None): super(ConsoleLog, self).__init__(parent) self.start_time = time.time() self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("Console Log ~ SeqPy/InSAnE") self.plaintextedit = QtWidgets.QPlainTextEdit() self.plaintextedit.setReadOnly(True) self.plaintextedit.setMaximumBlockCount(250) self.setCentralWidget(self.plaintextedit) self.write('console log created')
def progress(msg, maxvalue=10): msgbox = QtWidgets.QProgressDialog(msg, 'Cancel', 0, maxvalue) #msgbox.setWindowTitle('') #msgbox.setText(msg) #msgbox.setStandardButtons(QtGui.QMessageBox.NoButton) msgbox.setModal(True) msgbox.show() msgbox.setValue(0) QtWidgets.qApp.processEvents() return msgbox
def create_action(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False): action = QtWidgets.QAction(text, self.pane()) if icon is not None: action.setIcon( QtGui.QIcon(":/images%s.png" % icon) ) if shortcut is not None: action.setShortcut( shortcut ) if tip is not None: action.setToolTip( tip ) action.setStatusTip( tip ) if slot is not None: action.triggered.connect( slot ) if checkable: action.setCheckable( True ) return action
def init_layout(self, header=None, footer=None): """ initialize the layout; this function needs to be called before everything else """ self._layout = QtWidgets.QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._layout.addWidget(self._splitter, 1) self.setLayout(self._layout) self.init_hscrollbar() if header: self.set_header(header) if footer: self.set_footer(footer) self.init_signals() self.set_painter() # split is set to 1, but will be adjusted when this pane is inserted to frame self.set_split(1)
def populate_toolbar(self, toolbar): super(TracePaneActions, self).populate_toolbar( toolbar ) self._xscale_slider.add_as_popup( toolbar, '\u2194' ) self._yscale_slider.add_as_popup( toolbar, '\u2195' ) toolbar.addWidget( self._searchbox ) self._prevsearch = toolbar.addAction( '\u226a', self.do_prevsearch) self._prevsearch.setEnabled(False) self._nextsearch = toolbar.addAction( '\u226b', self.do_nextsearch) self._nextsearch.setEnabled(False) toolbar.addWidget( self._panesplit ) self._peaks = {} for i in range(len(trace_set)): tb = QtWidgets.QToolButton() tb.setText(trace_set[i]) tb.setDown(True) toolbar.addWidget( tb ) self._peaks[i] = tb tb.clicked.connect( lambda x, button_no = i: self.tracebutton_changed( x, button_no ) )
def main(): app = QtWidgets.QApplication(sys.argv) # patching seqpy.cout set_cout(writelog) cout('console log ready..') try: infile = sys.argv[1] except IndexError: infile = None w = IMainWindow() w.show() if infile: # allow all windows to be drawn QtCore.QTimer.singleShot(100, lambda: w.load(infile)) else: w.setFocus() app.exec_()
def alert(msg): msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle('Error') msgbox.setText(msg) msgbox.exec_()