diff --git a/README.md b/README.md index 5e8b4a78..4e245888 100644 --- a/README.md +++ b/README.md @@ -18,33 +18,35 @@ Table of Contents ----------------- - [Gooey](#gooey) -- [Table of contents](#table-of-contents) -- [Latest Update](#latest-update) -- [Quick Start](#quick-start) - - [Installation Instructions](#installation-instructions) + - [Support this project](#support-this-project) + - [Table of Contents](#table-of-contents) + - [Quick Start](#quick-start) + - [Installation instructions](#installation-instructions) - [Usage](#usage) - [Examples](#examples) -- [What It Is](#what-is-it) -- [Why Is It](#why) -- [Who is this for](#who-is-this-for) -- [How does it work](#how-does-it-work) -- [Internationalization](#internationalization) -- [Global Configuration](#global-configuration) -- [Layout Customization](#layout-customization) -- [Run Modes](#run-modes) - - [Full/Advanced](#advanced) + - [What is it?](#what-is-it) + - [Why?](#why) + - [Who is this for?](#who-is-this-for) + - [How does it work?](#how-does-it-work) + - [Mappings:](#mappings) + - [GooeyParser](#gooeyparser) + - [Internationalization](#internationalization) + - [Global Configuration](#global-configuration) + - [Options and Options Groups style configuration](#options-and-options-groups-style-configuration) + - [Layout Customization](#layout-customization) + - [Run Modes](#run-modes) + - [Advanced](#advanced) - [Basic](#basic) - [No Config](#no-config) -- [Menus](#menus) -- [Input Validation](#input-validation) -- [Using Dynamic Values](#using-dynamic-values) -- [Showing Progress](#showing-progress) + - [Menus](#menus) + - [Input Validation](#input-validation) + - [Using Dynamic Values](#using-dynamic-values) + - [Showing Progress](#showing-progress) - [Elapsed / Remaining Time](#elapsed--remaining-time) -- [Customizing Icons](#customizing-icons) -- [Packaging](#packaging) -- [Screenshots](#screenshots) -- [Contributing](#wanna-help) -- [Image Credits](#image-credits) + - [Customizing Icons](#customizing-icons) + - [Packaging](#packaging) + - [Screenshots](#screenshots) + - [Wanna help?](#wanna-help) @@ -287,7 +289,9 @@ Just about everything in Gooey's overall look and feel can be customized by pass | sidebar_title | Controls the heading title above the SideBar's navigation pane. Defaults to: "Actions" | | show_sidebar | Show/Hide the sidebar in when navigation mode == `SIDEBAR` | | body_bg_color | HEX value of the main Gooey window | +| body_text_color | HEX value of the main Gooey window's texts | | header_bg_color | HEX value of the header background | +| header_text_color | HEX value of the header texts | | header_height | height in pixels of the header | | header_show_title | Show/Hide the header title | | header_show_subtitle | Show/Hide the header subtitle | @@ -303,7 +307,45 @@ Just about everything in Gooey's overall look and feel can be customized by pass | menus | Show custom menu groups and items (see: [Menus](#menus) | | clear_before_run | When true, previous output will be cleared from the terminal when running program again | +Options and Options Groups style configuration +-------------------- +Options (and options groups in adavance layout) can also be configurated by passing a `gooey_options` parameter. +| Parameter | Summary | +|-----------|---------| +| label_color | HEX value of the option name | +| help_color | HEX value of the option help | +| description_color | [GROUPS ONLY] HEX value of the group description | +| full_width | Bool | +| error_color | HEX value of the text displayed when a validation error occurs | + +Example + +```python + parser = GooeyParser(description="DemoParser") + group1 = parser.add_argument_group( + "My Group", "My Group description",gooey_options={"label_color": "#E5FFCC","description_color": "#1cac78"} + ) + group1.add_argument( + "--zip", + default="azip.zip", + help="Provide the zip to process", + widget="FileChooser", + gooey_options={"label_color": "#E5FFCC","help_color": "#1cac78"} + ) +``` + +Note you can also loop on your (sub)parser args to set those values + +```python + # Create subparsers and groups first + for subparser in [subparser1, subparser2]: + for group in subparser.parser._action_groups: + group.gooey_options = { + "label_color": "#ff0000", + "help_color": "#363636", + } +``` Layout Customization -------------------- diff --git a/gooey/gui/components/header.py b/gooey/gui/components/header.py index 547a419d..e47d9839 100644 --- a/gooey/gui/components/header.py +++ b/gooey/gui/components/header.py @@ -62,6 +62,8 @@ def layoutComponent(self): self.running_img = self._load_image(images['runningIcon'], targetHeight) self.check_mark = self._load_image(images['successIcon'], targetHeight) self.error_symbol = self._load_image(images['errorIcon'], targetHeight) + self._header.SetForegroundColour(self.buildSpec['header_text_color']) + self._subheader.SetForegroundColour(self.buildSpec['header_text_color']) self.images = [ self.settings_img, diff --git a/gooey/gui/components/widgets/dialogs/base_dialog.py b/gooey/gui/components/widgets/dialogs/base_dialog.py index 2e35053c..eb827b91 100644 --- a/gooey/gui/components/widgets/dialogs/base_dialog.py +++ b/gooey/gui/components/widgets/dialogs/base_dialog.py @@ -3,6 +3,7 @@ import wx from gooey.gui.three_to_four import Constants +from gooey.python_bindings import constants class BaseDialog(wx.Dialog): @@ -12,7 +13,8 @@ class BaseDialog(wx.Dialog): def __init__(self, parent, pickerClass, pickerGetter, localizedPickerLabel): wx.Dialog.__init__(self, parent, title=localizedPickerLabel) - self.SetBackgroundColour('#ffffff') + use_dark_mode = wx.SystemSettings.GetAppearance().IsUsingDarkBackground() + self.SetBackgroundColour(constants.COLOR_GREY_90 if use_dark_mode else constants.COLOR_GREY_5) self.ok_button = wx.Button(self, wx.ID_OK, label=_('ok')) self.picker = pickerClass(self, style=Constants.WX_DP_DROPDOWN) diff --git a/gooey/gui/components/widgets/dropdown_filterable.py b/gooey/gui/components/widgets/dropdown_filterable.py index 583a4c2d..03d1a0dd 100644 --- a/gooey/gui/components/widgets/dropdown_filterable.py +++ b/gooey/gui/components/widgets/dropdown_filterable.py @@ -9,6 +9,7 @@ from gooey.gui.components.widgets.dropdown import Dropdown from gooey.gui.lang.i18n import _ from gooey.gui.pubsub import pub +from gooey.python_bindings import constants __ALL__ = ('FilterableDropdown',) @@ -207,6 +208,7 @@ class VirtualizedListBox(wx.html.HtmlListBox): def __init__(self, *args, **kwargs): super(VirtualizedListBox, self).__init__(*args, **kwargs) self.SetItemCount(1) + self.SetBackgroundColour(constants.COLOR_WHITE) def OnGetItem(self, n): return '' diff --git a/gooey/python_bindings/argparse_to_json.py b/gooey/python_bindings/argparse_to_json.py index a0e94954..078dcc48 100644 --- a/gooey/python_bindings/argparse_to_json.py +++ b/gooey/python_bindings/argparse_to_json.py @@ -5,6 +5,7 @@ import json import os import sys +import wx from argparse import ( _CountAction, _HelpAction, @@ -19,6 +20,7 @@ from uuid import uuid4 from gooey.python_bindings.gooey_parser import GooeyParser +from gooey.python_bindings import constants from gooey.util.functional import merge, getin, identity, assoc from gooey.gui.components.options.validators import validators from gooey.gui.components.options.validators import collect_errors @@ -60,10 +62,12 @@ class UnsupportedConfiguration(Exception): # TODO: merge the default foreground and bg colors from the # baseline build_spec -item_default = { +def item_default(): + use_dark_mode = wx.SystemSettings.GetAppearance().IsUsingDarkBackground() + return { 'error_color': '#ea7878', - 'label_color': '#000000', - 'help_color': '#363636', + 'label_color': constants.COLOR_WHITE if use_dark_mode else constants.COLOR_BLACK, + 'help_color': constants.COLOR_GREY_5 if use_dark_mode else constants.COLOR_GREY_100, 'full_width': False, 'validator': { 'type': 'local', @@ -265,7 +269,14 @@ def swap_actions(actions): def categorize2(groups, widget_dict, options): - defaults = {'label_color': '#000000', 'description_color': '#363636'} + use_dark_mode = wx.SystemSettings.GetAppearance().IsUsingDarkBackground() + + constants.COLOR_WHITE if use_dark_mode else constants.COLOR_BLACK + + defaults = {'label_color': constants.COLOR_WHITE if use_dark_mode else constants.COLOR_BLACK, + 'description_color': constants.COLOR_GREY_10 if use_dark_mode else constants.COLOR_GREY_100 + } + return [{ 'name': group['name'], 'items': list(categorize(group['items'], widget_dict, options)), @@ -427,7 +438,7 @@ def action_to_json(action, widget, options): validator = 'True' error_msg = '' - base = merge(item_default, { + base = merge(item_default(), { 'validator': { 'type': 'ExpressionValidator', 'test': validator, diff --git a/gooey/python_bindings/config_generator.py b/gooey/python_bindings/config_generator.py index 5b48a4c1..f9573653 100644 --- a/gooey/python_bindings/config_generator.py +++ b/gooey/python_bindings/config_generator.py @@ -2,6 +2,7 @@ import sys import warnings import textwrap +import wx from gooey.python_bindings import argparse_to_json from gooey.gui.util.quoting import quote from gooey.python_bindings import constants @@ -33,6 +34,8 @@ def create_from_parser(parser, source_path, **kwargs): else: run_cmd = '{} -u {}'.format(quote(sys.executable), quote(source_path)) + use_dark_mode = wx.SystemSettings.GetAppearance().IsUsingDarkBackground() + default_text_color = constants.COLOR_WHITE if use_dark_mode else constants.COLOR_BLACK build_spec = { 'language': kwargs.get('language', 'english'), 'target': run_cmd, @@ -82,23 +85,26 @@ def create_from_parser(parser, source_path, **kwargs): 'group_by_type': kwargs.get('group_by_type', True), # styles - 'body_bg_color': kwargs.get('body_bg_color', '#f0f0f0'), - 'header_bg_color': kwargs.get('header_bg_color', '#ffffff'), + 'body_bg_color': kwargs.get('body_bg_color', constants.COLOR_GREY_90 if use_dark_mode else constants.COLOR_GREY_5), + 'body_text_color': kwargs.get('body_text_color', default_text_color), + 'header_bg_color': kwargs.get('header_bg_color', constants.COLOR_GREY_100 if use_dark_mode else constants.COLOR_WHITE), 'header_height': kwargs.get('header_height', 90), 'header_show_title': kwargs.get('header_show_title', True), 'header_show_subtitle': kwargs.get('header_show_subtitle', True), + 'header_text_color': kwargs.get('header_text_color', default_text_color), 'header_image_center': kwargs.get('header_image_center', False), - 'footer_bg_color': kwargs.get('footer_bg_color', '#f0f0f0'), - 'sidebar_bg_color': kwargs.get('sidebar_bg_color', '#f2f2f2'), + 'footer_bg_color': kwargs.get('footer_bg_color', constants.COLOR_GREY_90 if use_dark_mode else constants.COLOR_GREY_5), + 'sidebar_bg_color': kwargs.get('sidebar_bg_color', constants.COLOR_GREY_90 if use_dark_mode else constants.COLOR_GREY_5), # font family, weight, and size are determined at runtime - 'terminal_panel_color': kwargs.get('terminal_panel_color', '#F0F0F0'), - 'terminal_font_color': kwargs.get('terminal_font_color', '#000000'), + 'terminal_panel_color': kwargs.get('terminal_panel_color', constants.COLOR_GREY_80 if use_dark_mode else constants.COLOR_GREY_10), + 'terminal_font_color': kwargs.get('terminal_font_color', default_text_color), 'terminal_font_family': kwargs.get('terminal_font_family', None), 'terminal_font_weight': get_font_weight(kwargs), 'terminal_font_size': kwargs.get('terminal_font_size', None), 'richtext_controls': kwargs.get('richtext_controls', False), - 'error_color': kwargs.get('error_color', '#ea7878') + 'error_color': kwargs.get('error_color', '#ea7878'), + 'use_dark_mode': use_dark_mode } if build_spec['monospace_display']: diff --git a/gooey/python_bindings/constants.py b/gooey/python_bindings/constants.py index be122f4c..d4440ad8 100644 --- a/gooey/python_bindings/constants.py +++ b/gooey/python_bindings/constants.py @@ -14,3 +14,18 @@ FONTWEIGHT_EXTRABOLD = 800 FONTWEIGHT_HEAVY = 900 FONTWEIGHT_EXTRAHEAVY = 1000 + +COLOR_WHITE = "#ffffff" +COLOR_BLACK = "#000000" +COLOR_GREY_0 = "#F2F2F2" +COLOR_GREY_5 = "#EDEDF0" +COLOR_GREY_10 = "#E1E1E3" +COLOR_GREY_20 = "#D2D2D6" +COLOR_GREY_30 = "#B4B4BB" +COLOR_GREY_40 = "#9696A0" +COLOR_GREY_50 = "#787885" +COLOR_GREY_60 = "#5A5B6A" +COLOR_GREY_70 = "#4A4B57" +COLOR_GREY_80 = "#3A3A44" +COLOR_GREY_90 = "#292A31" +COLOR_GREY_100 = "#19191D" diff --git a/requirements.txt b/requirements.txt index 5fd7612c..9c17f9c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -wxpython>=4.1.0 +wxpython>=4.2.1 Pillow>=4.3.0 psutil>=5.4.2 colored>=1.3.93