Skip to content

Commit

Permalink
Merge 2fbe2bd into 2c7b591
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgill86 committed Mar 4, 2020
2 parents 2c7b591 + 2fbe2bd commit f1526cd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/releases/1.4.0.rst
Expand Up @@ -72,7 +72,7 @@ here <https://github.com/jpgill86/neurotic/blob/master/neurotic/example/example-
* Add API tutorial to example Jupyter notebook
(:pr:`234`, :pr:`236`)

* Add shell commands to example Jupyter notebook for installing neurotic
* Add shell commands to example Jupyter notebook for installing **neurotic**
(:pr:`185`)

Other changes
Expand Down
8 changes: 6 additions & 2 deletions neurotic/gui/config.py
Expand Up @@ -30,6 +30,10 @@
pq.mN = pq.UnitQuantity('millinewton', pq.N/1e3, symbol = 'mN'); # define millinewton


available_themes = ['light', 'dark', 'original', 'printer-friendly']
available_ui_scales = ['tiny', 'small', 'medium', 'large', 'huge']


class EphyviewerConfigurator():
"""
A class for launching ephyviewer for a dataset with configurable viewers.
Expand Down Expand Up @@ -104,8 +108,8 @@ def __init__(self, metadata, blk, lazy = False):
'tiny': {'app_font_size': self.default_font_size-4, 'channel_label_size': self.default_font_size-4, 'scatter_size': 4},
'small': {'app_font_size': self.default_font_size-2, 'channel_label_size': self.default_font_size-2, 'scatter_size': 6},
'medium': {'app_font_size': self.default_font_size, 'channel_label_size': self.default_font_size, 'scatter_size': 8},
'large': {'app_font_size': self.default_font_size+2, 'channel_label_size': self.default_font_size+2, 'scatter_size': 10},
'huge': {'app_font_size': self.default_font_size+4, 'channel_label_size': self.default_font_size+4, 'scatter_size': 12},
'large': {'app_font_size': self.default_font_size+4, 'channel_label_size': self.default_font_size+4, 'scatter_size': 10},
'huge': {'app_font_size': self.default_font_size+8, 'channel_label_size': self.default_font_size+8, 'scatter_size': 12},
}

# hide and disable viewers for which inputs are missing
Expand Down
30 changes: 14 additions & 16 deletions neurotic/gui/standalone.py
Expand Up @@ -21,7 +21,7 @@
from .. import __version__, _elephant_tools, default_log_level, log_file
from ..datasets import MetadataSelector, load_dataset
from ..datasets.metadata import _selector_labels
from ..gui.config import EphyviewerConfigurator
from ..gui.config import EphyviewerConfigurator, available_themes, available_ui_scales

import logging
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -82,10 +82,14 @@ def __init__(self, file=None, initial_selection=None, lazy=True, theme='light',
# lazy loading using Neo RawIO
self.lazy = lazy

# available themes are 'light', 'dark', 'original', and 'printer-friendly'
if theme not in available_themes:
logger.error(f'theme "{theme}" is unrecognized')
raise ValueError(f'theme "{theme}" is unrecognized')
self.theme = theme

# available sizes are 'tiny', 'small', 'medium', 'large', and 'huge'
if ui_scale not in available_ui_scales:
logger.error(f'ui scale "{ui_scale}" is unrecognized')
raise ValueError(f'ui scale "{ui_scale}" is unrecognized')
self.ui_scale = ui_scale
self.default_font_size = QT.QFont().pointSize()

Expand Down Expand Up @@ -224,30 +228,24 @@ def create_menus(self):

ui_scale_group = QT.QActionGroup(appearance_menu)
ui_scale_actions = {}
for size in ['tiny', 'small', 'medium', 'large', 'huge']:
for size in available_ui_scales:
ui_scale_actions[size] = appearance_menu.addAction(f'&{size.capitalize()} scale')
ui_scale_actions[size].setCheckable(True)
ui_scale_actions[size].triggered.connect(lambda checked, size=size: self.set_ui_scale(size))
ui_scale_group.addAction(ui_scale_actions[size])
if self.ui_scale in ui_scale_actions:
ui_scale_actions[self.ui_scale].setChecked(True)
self.set_ui_scale(self.ui_scale)
else:
raise ValueError('ui scale "{}" is unrecognized'.format(self.ui_scale))
ui_scale_actions[self.ui_scale].setChecked(True)
self.set_ui_scale(self.ui_scale) # adjust the UI scale now

appearance_menu.addSeparator()

theme_group = QT.QActionGroup(appearance_menu)
theme_actions = {}
for theme in ['light', 'dark', 'original', 'printer-friendly']:
for theme in available_themes:
theme_actions[theme] = appearance_menu.addAction(f'&{theme.capitalize()} theme')
theme_actions[theme].setCheckable(True)
theme_actions[theme].triggered.connect(lambda checked, theme=theme: self.set_theme(theme))
theme_group.addAction(theme_actions[theme])
if self.theme in theme_actions:
theme_actions[self.theme].setChecked(True)
else:
raise ValueError('theme "{}" is unrecognized'.format(self.theme))
theme_actions[self.theme].setChecked(True)

appearance_menu.addSeparator()

Expand Down Expand Up @@ -576,8 +574,8 @@ def set_ui_scale(self, size):
'tiny': self.default_font_size-4,
'small': self.default_font_size-2,
'medium': self.default_font_size,
'large': self.default_font_size+2,
'huge': self.default_font_size+4,
'large': self.default_font_size+4,
'huge': self.default_font_size+8,
}
font = self.font()
font.setPointSize(font_size[size])
Expand Down
15 changes: 6 additions & 9 deletions neurotic/scripts.py
Expand Up @@ -19,7 +19,7 @@

from . import __version__
from .datasets.data import load_dataset
from .gui.config import EphyviewerConfigurator
from .gui.config import EphyviewerConfigurator, available_themes, available_ui_scales
from .gui.standalone import MainWindow

import logging
Expand Down Expand Up @@ -61,14 +61,11 @@ def parse_args(argv):
'may be inaccurate depending on file type and ' \
'acquisition software (default: do not display)')
parser.add_argument('--ui-scale', dest='ui_scale',
choices=['tiny', 'small', 'medium', 'large', 'huge'],
default='medium', help='the scale of user interface ' \
'elements, such as text ' \
'(default: medium)')
parser.add_argument('--theme', choices=['light', 'dark', 'original',
'printer-friendly'],
default='light', help='a color theme for the GUI ' \
'(default: light)')
choices=available_ui_scales, default='medium',
help='the scale of user interface elements, such as ' \
'text (default: medium)')
parser.add_argument('--theme', choices=available_themes, default='light',
help='a color theme for the GUI (default: light)')

parser.add_argument('--launch-example-notebook', action='store_true',
help='launch Jupyter with an example notebook ' \
Expand Down
4 changes: 2 additions & 2 deletions neurotic/tests/test_cli.py
Expand Up @@ -123,7 +123,7 @@ def test_ui_scale(self):
"""Test that --ui-scale changes the ui_scale"""
app = mkQApp()

for size in ['tiny', 'small', 'medium', 'large', 'huge']:
for size in neurotic.available_ui_scales:
argv = ['neurotic', '--ui-scale', size]
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
Expand All @@ -133,7 +133,7 @@ def test_theme(self):
"""Test that --theme changes the theme"""
app = mkQApp()

for theme in ['light', 'dark', 'original', 'printer-friendly']:
for theme in neurotic.available_themes:
argv = ['neurotic', '--theme', theme]
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
Expand Down

0 comments on commit f1526cd

Please sign in to comment.