2014-03-18 19:37:32 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-03-18 18:48:39 +00:00
|
|
|
__author__ = 'markusro'
|
|
|
|
|
2014-03-18 19:37:32 +00:00
|
|
|
from PyQt4 import QtGui
|
|
|
|
|
2014-03-18 18:48:39 +00:00
|
|
|
from PyQt4.QtGui import *
|
|
|
|
from PyQt4.QtCore import QRegExp
|
|
|
|
import PeakWidget
|
|
|
|
|
|
|
|
|
|
|
|
class LogFSpinBox(QDoubleSpinBox):
|
|
|
|
scientificNotationValidator = QRegExpValidator(QRegExp("[+-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?"))
|
|
|
|
|
|
|
|
def __init__(self, parent = None):
|
|
|
|
super(LogFSpinBox, self).__init__(parent)
|
|
|
|
self.setRange(1e-16,1e16)
|
|
|
|
self.setMinimum(1e-16)
|
|
|
|
self.setDecimals(17)
|
|
|
|
self.setValue(1.0)
|
|
|
|
def stepBy(self, up_down):
|
|
|
|
print self.minimum(),self.maximum()
|
|
|
|
if self.value() != 0.0:
|
|
|
|
self.setValue(self.value()*10**(up_down/9.0)) # 19 steps per decade
|
|
|
|
|
|
|
|
def textFromValue(self, value):
|
|
|
|
return "%.3e"%value
|
|
|
|
|
|
|
|
def valueFromText(self, str_value):
|
|
|
|
return str_value.toDouble()[0]
|
|
|
|
|
|
|
|
def validate(self, str_value, p_int):
|
|
|
|
return self.scientificNotationValidator.validate(str_value, p_int)
|
|
|
|
|
|
|
|
class ParameterWidget(QWidget):
|
|
|
|
def __init__(self, parent = None):
|
|
|
|
super(ParameterWidget, self).__init__(parent)
|
|
|
|
layout = QGridLayout(self)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app = QApplication([])
|