-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from k-dominik/dark
Fixes for dark mode display
- Loading branch information
Showing
3 changed files
with
81 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
from __future__ import print_function | ||
|
||
############################################################################### | ||
# volumina: volume slicing and editing library | ||
# | ||
# Copyright (C) 2011-2014, the ilastik developers | ||
# Copyright (C) 2011-2024, the ilastik developers | ||
# <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
|
@@ -34,20 +32,18 @@ | |
QSpacerItem, | ||
QSizePolicy, | ||
) | ||
from PyQt5.QtCore import QRegExp, Qt, QTimer, pyqtSignal | ||
from PyQt5.QtCore import Qt, pyqtSignal | ||
from PyQt5 import uic | ||
import numpy | ||
|
||
|
||
class ValueRangeWidget(QWidget): | ||
|
||
changedSignal = pyqtSignal() | ||
|
||
def __init__(self, parent=None, dtype=numpy.float32): | ||
super(ValueRangeWidget, self).__init__(parent) | ||
self._blank = False | ||
self._initUic() | ||
self.allValid = True | ||
self.minBox.setButtonSymbols(QDoubleSpinBox.NoButtons) | ||
self.maxBox.setButtonSymbols(QDoubleSpinBox.NoButtons) | ||
self.minBox.setKeyboardTracking(False) | ||
|
@@ -76,8 +72,6 @@ def setDType(self, dtype): | |
box.setSingleStep(1) | ||
box.setRange(dtypeInfo.min, dtypeInfo.max) | ||
|
||
# box.setRange(typeLimits[0],typeLimits[1]) | ||
|
||
self.setLimits(dtypeInfo.min, dtypeInfo.max) | ||
|
||
def setBlank(self): | ||
|
@@ -92,57 +86,21 @@ def onChangedMinBox(self, val): | |
self.maxBox.setValue(val + self.maxBox.singleStep()) | ||
if val < self.softLimits[0]: | ||
self.minBox.setValue(self.softLimits[0]) | ||
self.validateRange() | ||
self.changedSignal.emit() | ||
|
||
def onChangedMaxBox(self, val): | ||
if val >= self.softLimits[1]: | ||
self.maxBox.setValue(self.softLimits[1]) | ||
if self.maxBox.value() <= self.minBox.value(): | ||
self.minBox.setValue(self.maxBox.value() - self.minBox.singleStep()) | ||
self.validateRange() | ||
# self.printLimits() | ||
self.changedSignal.emit() | ||
|
||
def printLimits(self): | ||
print(self.softLimits) | ||
|
||
def validateRange(self): | ||
validCheck = [True, True] | ||
if self.minBox.value() < self.softLimits[0]: | ||
validCheck[0] = False | ||
if self.maxBox.value() <= self.softLimits[0]: | ||
validCheck[1] = False | ||
if self.minBox.value() >= self.softLimits[1]: | ||
validCheck[0] = False | ||
if self.maxBox.value() > self.softLimits[1]: | ||
validCheck[1] = False | ||
# if not self.maxBox.value() > self.minBox.value(): | ||
# validCheck[1] = False | ||
|
||
for i, box in enumerate(self.boxes): | ||
if self._blank or validCheck[i]: | ||
box.setStyleSheet("QDoubleSpinBox {background-color: white;}") | ||
# self.setBackgroundColor("white", [i]) | ||
# box.setButtonSymbols(QDoubleSpinBox.NoButtons) | ||
else: | ||
self.setBackgroundColor("red", [i]) | ||
# box.setStyleSheet("QDoubleSpinBox {background-color: red;}") | ||
# box.setButtonSymbols(QDoubleSpinBox.UpDownArrows) | ||
|
||
self.allValid = all(validCheck) | ||
|
||
def setBackgroundColor(self, color, boxnumber=[0, 1]): | ||
for i in boxnumber: | ||
self.boxes[i].setStyleSheet("QDoubleSpinBox {background-color: %s}" % color) | ||
|
||
def setLimits(self, _min, _max): | ||
if _min + self.minBox.singleStep() > _max: | ||
raise RuntimeError("limits have to differ") | ||
self.softLimits = [_min, _max] | ||
if not self._blank: | ||
self.setValues(_min, _max) | ||
self.validateRange() | ||
|
||
def setValues(self, val1, val2): | ||
self._blank = False | ||
|
@@ -163,10 +121,6 @@ def getValues(self): | |
def getLimits(self): | ||
return self.softLimits | ||
|
||
def makeValid(self): | ||
if not self.maxBox.value() > self.minBox.value(): | ||
self.maxBox.setValue(self.minBox.value() + self.maxBox.singleStep()) | ||
|
||
def _initUic(self): | ||
p = os.path.split(__file__)[0] + "/" | ||
if p == "/": | ||
|
@@ -244,13 +198,12 @@ def focusInEvent(self, QFocusEvent): | |
|
||
if __name__ == "__main__": | ||
from PyQt5.QtWidgets import QApplication | ||
import vigra, numpy | ||
import numpy | ||
|
||
app = QApplication(list()) | ||
|
||
d = ValueRangeWidget() | ||
d.setDType(numpy.uint8) | ||
d.makeValid() | ||
d.setLimits(20, 40) | ||
d.show() | ||
app.exec_() |