def about(self): my_dialog = QDialog(self) my_dialog.setWindowTitle("About") my_dialog.setGeometry(0, 0, 250, 100) label = create_qt_label("aboutLabel", 50, 0, 200, 100, my_dialog) label.setText("DnD 5e Character sheet editor" + "\n" "folderisland.(com/net)" + "\n" "Version: {0}.{1}.{2}".format( VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)) my_dialog.exec_( ) # blocks all other windows until this window is closed.
class DatePicker(QWidget): selectionChanged = Signal() def __init__(self, parent=None): super(DatePicker, self).__init__(parent) self.button = QPushButton(self) icon = QIcon("logo.svg") self.button.setIcon(icon) self.setFixedSize(32, 32) self.button.setFixedSize(32, 32) self.button.setIconSize(QSize(22, 22)) self.__margin__ = 5 self.dialog = QDialog() self.dialog.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.Popup) self.dialog.setFixedSize(480, 240) self.dialog.setLayout(QHBoxLayout()) self.calender = QCalendarWidget(self) self.dialog.layout().addWidget(self.calender) self.dialog.layout().setContentsMargins(0, 0, 0, 0) self.dialog.layout().setSpacing(0) self.button.clicked.connect(self, SLOT("showCalender()")) self.calender.selectionChanged.connect(self.__emitSelectionChanged__) @Slot() def showCalender(self): print('in show') p = self.mapToGlobal(QPoint(0, self.height() + self.__margin__)) self.dialog.setGeometry(p.x(), p.y(), 0, 0) self.dialog.show() def setIcon(self, icon): if type(icon) is QIcon: self.button.setIcon(icon) elif type(icon) is str: self.button.setIcon(QIcon(icon)) else: raise Exception( 'Wrong argument type, icon should be either PySide2.QtGui.QIcon or str "string"' ) def icon(self): return self.button.icon() def setIconSize(self, iconsize): if type(iconsize) is QSize: self.button.setIconSize(iconsize) elif type(iconsize) is int: self.button.setIcon(QSize(iconsize, iconsize)) elif type(type) is iter: import collections if isinstance(iconsize, collections.Iterable): if len(iconsize) == 1: self.setIconSize(iconsize[0]) elif len(iconsize) == 2: self.setIconSize(QSize(iconsize[0], iconsize[1])) else: raise Exception() else: raise Exception( "Wrong argument type, iconSize should be either PySide2.QtCore.QSize or int value or width and height " "or iterable contains one QSize, one int or two int values for width and height respectively" ) def iconSize(self): return self.button.iconSize() def setFirstDayOfWeek(self, dayOfWeek): if type(dayOfWeek) is Qt.DayOfWeek: self.calender.setFirstDayOfWeek(dayOfWeek) elif type(dayOfWeek) is int: if dayOfWeek < 1 or dayOfWeek > 7: raise Exception( "Wrong argument, dayOfWeek should be from 1 to 7 (Monday --> Sunday)" ) self.calender.setFirstDayOfWeek(Qt.DayOfWeek(dayOfWeek)) else: raise Exception( "Wrong type, dayOfWeek should be either PySide2.QtCore.Qt.DayOf or int (1 --> 7) (Monday --> Sunday)" ) def firstDayOfWeek(self): self.calender.firstDayOfWeek() def selectedDate(self): self.calender.selectedDate() def setSelectedDate(self, args, kwargs): self.calender.setSelectedDate(args, kwargs) def minimumDate(self): self.calender.minimumDate() def setMinimumDate(self): self.calender.setMinimumDate() def selectedDate(self): return self.calender.selectedDate() def __emitSelectionChanged__(self): self.selectionChanged.emit()
def getRundown(self, silent=False): rtext = "" self.rundownCount = 0 for _condi, _pkdf in self.pk_extracted_by_condi.items(): _Np = len(_pkdf.index) _NROI = len(_pkdf.columns) ten_percent = int(_Np / 10) rtext += "{} condition, 10% of peaks count is {} peaks\n".format( _condi, ten_percent) # look at first 5 peaks _firsttenpc = _pkdf.iloc[0:ten_percent].describe().loc["mean"] # look at last 5 peaks _lasttenpc = _pkdf.iloc[-1 - ten_percent:-1].describe().loc["mean"] _tdf = self.tracedata[_condi] _max = _tdf.max() _SD = _tdf.std() _bestSNR = _max / _SD _startSNR = _firsttenpc / _SD _endSNR = _lasttenpc / _SD #print ("ff, lf : {} {}".format(_firstfive, _lastfive)) _rundownRatio = _lasttenpc.div(_firsttenpc).sort_values() self.rundownCount += _rundownRatio[ _rundownRatio < self.rundownThreshold].count() _rd_SNR = pd.concat([_rundownRatio, _bestSNR, _startSNR, _endSNR], axis=1) _rd_SNR.columns = [ 'Rundown', 'Best SNR', 'Initial SNR', 'Final SNR' ] rtext += "Rundown (amplitude ratio: last 10% / first 10%) and signal to noise ratio (start, end)\nfor {} ROIs (ROIs with worst rundown first):\n{}\n\n".format( _NROI, _rd_SNR.round(2).to_string()) rtext += "Total number of traces with rundown worse than threshold ({}): {}\n".format( self.rundownThreshold, self.rundownCount) print(rtext) if not silent: ###Make a pop up window of these results qmb = QDialog() qmb.setWindowTitle('Rundown {}'.format(self.name)) qmb.setGeometry(800, 600, 600, 600) self.rundownText = QtGui.QTextEdit() font = QtGui.QFont() font.setFamily('Courier') font.setFixedPitch(True) font.setPointSize(12) self.rundownText.setCurrentFont(font) self.rundownText.setText(rtext) self.rundownText.setReadOnly(True) #add buttons, make it the right size qmb.layout = QVBoxLayout() qmb.layout.addWidget(self.rundownText) qmb.setLayout(qmb.layout) qmb.exec_()