Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/better dark mode #891

Open
wants to merge 7 commits into
base: 1.2.1-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 64 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down Expand Up @@ -287,7 +289,9 @@ Just about everything in Gooey's overall look and feel can be customized by pass
| sidebar_title | <img src="https://github.com/chriskiehl/GooeyImages/raw/images/readme-images/34472159-1bfedbd0-ef10-11e7-8bc3-b6d69febb8c3.png" width="250" height="auto" align="right"> 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 |
Expand All @@ -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
--------------------
Expand Down
2 changes: 2 additions & 0 deletions gooey/gui/components/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion gooey/gui/components/widgets/dialogs/base_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import wx

from gooey.gui.three_to_four import Constants
from gooey.python_bindings import constants


class BaseDialog(wx.Dialog):
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions gooey/gui/components/widgets/dropdown_filterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)

Expand Down Expand Up @@ -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 ''
Expand Down
21 changes: 16 additions & 5 deletions gooey/python_bindings/argparse_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import os
import sys
import wx
from argparse import (
_CountAction,
_HelpAction,
Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 13 additions & 7 deletions gooey/python_bindings/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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']:
Expand Down
15 changes: 15 additions & 0 deletions gooey/python_bindings/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wxpython>=4.1.0
wxpython>=4.2.1
Pillow>=4.3.0
psutil>=5.4.2
colored>=1.3.93
Expand Down