Skip to content

Commit

Permalink
Add --ui-scale argument to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgill86 committed Mar 1, 2020
1 parent e6b56e8 commit 804ad6a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ The command line interface accepts other arguments too:
.. code-block::
usage: neurotic [-h] [-V] [--debug] [--no-lazy] [--thick-traces]
[--show-datetime]
[--show-datetime] [--ui-scale {tiny,small,large,huge}]
[--theme {light,dark,original,printer-friendly}]
[--launch-example-notebook]
[file] [dataset]
Expand All @@ -234,6 +234,9 @@ The command line interface accepts other arguments too:
--show-datetime display the real-world date and time, which may be
inaccurate depending on file type and acquisition
software (default: do not display)
--ui-scale {tiny,small,large,huge}
the scale of user interface elements, such as text
(default: small)
--theme {light,dark,original,printer-friendly}
a color theme for the GUI (default: light)
--launch-example-notebook
Expand Down
7 changes: 6 additions & 1 deletion neurotic/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def parse_args(argv):
help='display the real-world date and time, which ' \
'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', 'large', 'huge'],
default='small', help='the scale of user interface ' \
'elements, such as text ' \
'(default: small)')
parser.add_argument('--theme', choices=['light', 'dark', 'original',
'printer-friendly'],
default='light', help='a color theme for the GUI ' \
Expand Down Expand Up @@ -92,7 +97,7 @@ def win_from_args(args):
"""

win = MainWindow(file=args.file, initial_selection=args.dataset,
lazy=args.lazy, theme=args.theme,
lazy=args.lazy, theme=args.theme, ui_scale=args.ui_scale,
support_increased_line_width=args.thick,
show_datetime=args.datetime)
return win
Expand Down
26 changes: 26 additions & 0 deletions neurotic/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def test_cli_defaults(self):
'thick traces enabled without --thick-traces')
self.assertFalse(win.show_datetime,
'datetime enabled without --show-datetime')
self.assertEqual(win.ui_scale, 'small',
'ui_scale changed without --ui-scale')
self.assertEqual(win.theme, 'light', 'theme changed without --theme')
self.assertEqual(win.metadata_selector.file, self.default_file,
'file was not set to default')
Expand Down Expand Up @@ -117,6 +119,30 @@ def test_show_datetime(self):
self.assertTrue(win.show_datetime,
'datetime not displayed with --show-datetime')

def test_ui_scale(self):
"""Test that --ui-scale changes the ui_scale"""
app = mkQApp()

argv = ['neurotic', '--ui-scale', 'tiny']
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
self.assertEqual(win.ui_scale, 'tiny', 'unexpected scale')

argv = ['neurotic', '--ui-scale', 'small']
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
self.assertEqual(win.ui_scale, 'small', 'unexpected scale')

argv = ['neurotic', '--ui-scale', 'large']
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
self.assertEqual(win.ui_scale, 'large', 'unexpected scale')

argv = ['neurotic', '--ui-scale', 'huge']
args = neurotic.parse_args(argv)
win = neurotic.win_from_args(args)
self.assertEqual(win.ui_scale, 'huge', 'unexpected scale')

def test_theme(self):
"""Test that --theme changes the theme"""
app = mkQApp()
Expand Down

0 comments on commit 804ad6a

Please sign in to comment.