Skip to content

Commit

Permalink
style: improved styling launcher buttons in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ElpadoCan committed Jun 19, 2023
1 parent 72d2027 commit 7024d56
Showing 1 changed file with 17 additions and 60 deletions.
77 changes: 17 additions & 60 deletions cellacdc/__main__.py
Expand Up @@ -112,8 +112,8 @@ def eventFilter(self, object, event):
QSettings, QUrl, QCoreApplication
)
from qtpy.QtGui import (
QFontDatabase, QIcon, QDesktopServices, QFont, QMouseEvent,
QPixmap
QFontDatabase, QIcon, QDesktopServices, QFont, QColor,
QPalette
)

# acdc modules
Expand Down Expand Up @@ -472,12 +472,21 @@ def launchWelcomeGuide(self, checked=False):

def setColorsAndText(self):
self.moduleLaunchedColor = '#ead935'
self.moduleLaunchedQColor = QColor(self.moduleLaunchedColor)
defaultColor = self.guiButton.palette().button().color().name()
self.defaultButtonPalette = self.guiButton.palette()
self.defaultPushButtonColor = defaultColor
self.defaultTextDataStructButton = self.dataStructButton.text()
self.defaultTextGuiButton = self.guiButton.text()
self.defaultTextDataPrepButton = self.dataPrepButton.text()
self.defaultTextSegmButton = self.segmButton.text()
self.moduleLaunchedPalette = self.guiButton.palette()
self.moduleLaunchedPalette.setColor(
QPalette.Button, self.moduleLaunchedQColor
)
self.moduleLaunchedPalette.setColor(
QPalette.ButtonText, QColor(0,0,0)
)

def createMenuBar(self):
menuBar = self.menuBar()
Expand Down Expand Up @@ -1136,62 +1145,13 @@ def launchRepeatDataPrep(self):
self.batchConverterWin.show()

def launchDataStruct(self, checked=False):
self.dataStructButton.setStyleSheet(
f'QPushButton {{background-color: {self.moduleLaunchedColor};}}'
)
self.dataStructButton.setPalette(self.moduleLaunchedPalette)
self.dataStructButton.setText(
'0. Creating data structure running...'
)

QTimer.singleShot(100, self._showDataStructWin)

# def attemptDataStructSeparateProcess(self):
# self.dataStructButton.setStyleSheet(
# f'QPushButton {{background-color: {self.moduleLaunchedColor};}}'
# )
# self.dataStructButton.setText(
# '0. Creating data structure running...'
# )
#
# cellacdc_path = os.path.dirname(os.path.realpath(__file__))
# dataStruct_path = os.path.join(cellacdc_path, 'dataStruct.py')
#
# # Due to javabridge limitation only one 'start_vm' can be called in
# # each process. To get around with this every data structure conversion
# # is launched in a separate process
# try:
# subprocess.run(
# [sys.executable, dataStruct_path], check=True, text=True,
# shell=False
# )
# except Exception as e:
# print('=========================================')
# traceback.print_exc()
# print('=========================================')
# err = ("""
# <p style="font-size:12px">
# Launching data structure module in a separate process failed.<br><br>
# Please restart Cell-ACDC if you need to use this module again.
# <p>
# """)
# self.dataStructButton.setStyleSheet(
# f'QPushButton {{background-color: {self.defaultPushButtonColor};}}')
# self.dataStructButton.setText(
# '0. Restart Cell-ACDC to enable module 0 again.')
# self.dataStructButton.setToolTip(
# 'Due to an interal limitation of the Java Virtual Machine\n'
# 'moduel 0 can be launched only once.\n'
# 'To use it again close and reopen Cell-ACDC'
# )
# self.dataStructButton.setDisabled(True)
# return
#
# self.dataStructButton.setStyleSheet(
# f'QPushButton {{background-color: {self.defaultPushButtonColor};}}')
# self.dataStructButton.setText(
# '0. Create data structure from microscopy file(s)...')
# self.dataStructButton.setDisabled(False)

def _showDataStructWin(self):
msg = widgets.myMessageBox(wrapText=False, showCentered=False)
bioformats_url = 'https://www.openmicroscopy.org/bio-formats/'
Expand Down Expand Up @@ -1309,22 +1269,18 @@ def workerProgress(self, text, loggerLevel='INFO'):
self.logger.log(getattr(logging, loggerLevel), text)

def restoreDefaultButtons(self):
self.dataStructButton.setStyleSheet(
f'QPushButton {{background-color: {self.defaultPushButtonColor};}}'
)
self.dataStructButton.setText(
'0. Create data structure from microscopy/image file(s)...'
)

self.dataStructButton.setPalette(self.defaultButtonPalette)

def launchDataPrep(self, checked=False):
c = self.dataPrepButton.palette().button().color().name()
launchedColor = self.moduleLaunchedColor
defaultColor = self.defaultPushButtonColor
defaultText = self.defaultTextDataPrepButton
if c != self.moduleLaunchedColor:
self.dataPrepButton.setStyleSheet(
f'QPushButton {{background-color: {launchedColor};}}')
self.dataPrepButton.setPalette(self.moduleLaunchedPalette)
self.dataPrepButton.setText(
'DataPrep is running. Click to restore window.'
)
Expand All @@ -1341,6 +1297,8 @@ def launchDataPrep(self, checked=False):

def dataPrepClosed(self):
self.logger.info('Data prep window closed.')
self.dataPrepButton.setText(' 1. Launch data prep module...')
self.dataPrepButton.setPalette(self.defaultButtonPalette)
del self.dataPrepWin

def launchSegm(self, checked=False):
Expand All @@ -1349,8 +1307,7 @@ def launchSegm(self, checked=False):
defaultColor = self.defaultPushButtonColor
defaultText = self.defaultTextSegmButton
if c != self.moduleLaunchedColor:
self.segmButton.setStyleSheet(
f'QPushButton {{background-color: {launchedColor};}}')
self.segmButton.setPalette(self.moduleLaunchedPalette)
self.segmButton.setText('Segmentation is running. '
'Check progress in the terminal/console')
self.segmWin = segm.segmWin(
Expand Down

0 comments on commit 7024d56

Please sign in to comment.