Skip to content

Commit

Permalink
Run code formatters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 7, 2024
1 parent 09443c7 commit 825cfa0
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 169 deletions.
43 changes: 18 additions & 25 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ def parse_args(argv=None):
'''Parse the command-line options.'''

parser = argparse.ArgumentParser(description='Styles to configure for a Qt application.')
parser.add_argument(
'-v',
'--version',
action='version',
version=f'%(prog)s {__version__}'
)
parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {__version__}')
parser.add_argument(
'--styles',
help='comma-separate list of styles to configure. pass `all` to build all themes',
Expand Down Expand Up @@ -68,20 +63,18 @@ def parse_args(argv=None):
'Note: building for PyQt6 requires PySide6-rcc to be installed.'
),
choices=['pyqt5', 'pyqt6', 'pyside2', 'pyside6'],
default='pyqt5'
default='pyqt5',
)
parser.add_argument(
'--clean',
help='clean dist directory prior to configuring themes.',
action='store_true'
'--clean', help='clean dist directory prior to configuring themes.', action='store_true'
)
parser.add_argument(
'--rcc',
help=(
'path to the rcc executable. '
'Overrides rcc of chosen framework. '
'Only use if system cannot find the rcc exe.'
)
),
)
parser.add_argument(
'--compiled-resource',
Expand Down Expand Up @@ -135,11 +128,13 @@ def read_template_dir(directory):
# Need to find all the values inside the image.
keys = re.findall(r'\^[0-9a-zA-Z_-]+\^', svg)
replacements = [i[1:-1] for i in keys]
data['icons'].append({
'name': name,
'svg': svg,
'replacements': replacements,
})
data['icons'].append(
{
'name': name,
'svg': svg,
'replacements': replacements,
}
)

return data

Expand Down Expand Up @@ -262,11 +257,11 @@ def replace_by_index(contents, theme, colors):
# parse the color, get the correct value, and use only that
# for the replacement.
if key.endswith(':hex'):
color = theme[key[:-len(':hex')]]
color = theme[key[: -len(':hex')]]
rgb = [f'{i:02x}' for i in parse_color(color)[:3]]
value = f'#{"".join(rgb)}'
elif key.endswith(':opacity'):
color = theme[key[:-len(':opacity')]]
color = theme[key[: -len(':opacity')]]
value = str(parse_color(color)[3])
else:
value = theme[key]
Expand Down Expand Up @@ -384,7 +379,10 @@ def compile_resource(args):
'Required rcc for PySide6 & PyQt6: PySide6-rcc',
'Required rcc for PySide2: PySide2-rcc',
'',
'if using venv, activate it or provide path to rcc.', sep='\n', file=sys.stderr)
'if using venv, activate it or provide path to rcc.',
sep='\n',
file=sys.stderr,
)
raise SystemExit from error

if args.qt_framework == 'pyqt6':
Expand All @@ -398,12 +396,7 @@ def configure(args):
shutil.rmtree(args.output_dir, ignore_errors=True)

# Need to convert our styles accordingly.
config = {
'themes': {},
'templates': [],
'no_qrc': args.no_qrc,
'resource': args.resource
}
config = {'themes': {}, 'templates': [], 'no_qrc': args.no_qrc, 'resource': args.resource}
config['templates'].append(read_template_dir(template_dir))
for style in args.styles:
config['themes'][style] = load_json(f'{theme_dir}/{style}.json')
Expand Down
6 changes: 2 additions & 4 deletions example/advanced-dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@

parser = shared.create_parser()
parser.add_argument(
'--use-internal',
help='''use the dock manager internal stylesheet.''',
action='store_true'
'--use-internal', help='''use the dock manager internal stylesheet.''', action='store_true'
)
# https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/blob/master/doc/user-guide.md#configuration-flags
parser.add_argument(
'--focus-highlighting',
help='''use the focus highlighting (and other configuration flags).''',
action='store_true'
action='store_true',
)
# setConfigFlag
args, unknown = shared.parse_args(parser)
Expand Down
15 changes: 3 additions & 12 deletions example/branchless/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,9 @@ def main():
# setup ui
ui = widgets.Ui()
ui.setup(window)
ui.bt_delay_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_instant_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_menu_button_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_delay_popup.addActions([ui.actionAction, ui.actionAction_C])
ui.bt_instant_popup.addActions([ui.actionAction, ui.actionAction_C])
ui.bt_menu_button_popup.addActions([ui.actionAction, ui.actionAction_C])
window.setWindowTitle('Sample BreezeStyleSheets application.')

# Add event triggers
Expand Down
5 changes: 4 additions & 1 deletion example/breeze_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def is_light_color(r: int, g: int, b: int) -> bool:
Returns:
If the color is perceived as light.
'''
return (((5 * g) + (2 * r) + b) > (8 * 128))
return ((5 * g) + (2 * r) + b) > (8 * 128)


# region windows

Expand Down Expand Up @@ -390,6 +391,7 @@ def _listen_child_macos() -> None:

class Observer(NSObject):
'''Custom namespace key observer.'''

def observeValueForKeyPath_ofObject_change_context_( # pylint: disable=invalid-name
self, path, obj, changeDescription, context
):
Expand Down Expand Up @@ -502,6 +504,7 @@ def _listener_dummy(callback: CallbackFn) -> None:
'''Register an event listener for dark/light theme changes (always unimplemented).'''
_ = callback


# endregion


Expand Down
4 changes: 1 addition & 3 deletions example/dial.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@

parser = shared.create_parser()
parser.add_argument(
'--no-align',
help='''allow larger widgets without forcing alignment.''',
action='store_true'
'--no-align', help='''allow larger widgets without forcing alignment.''', action='store_true'
)
args, unknown = shared.parse_args(parser)
QtCore, QtGui, QtWidgets = shared.import_qt(args)
Expand Down
4 changes: 1 addition & 3 deletions example/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@

parser = shared.create_parser()
parser.add_argument(
'--no-align',
help='''allow larger widgets without forcing alignment.''',
action='store_true'
'--no-align', help='''allow larger widgets without forcing alignment.''', action='store_true'
)
args, unknown = shared.parse_args(parser)
QtCore, QtGui, QtWidgets = shared.import_qt(args)
Expand Down
6 changes: 2 additions & 4 deletions example/placeholder_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@

parser = shared.create_parser()
parser.add_argument(
'--set-app-palette',
help='''set the placeholder text palette globally.''',
action='store_true'
'--set-app-palette', help='''set the placeholder text palette globally.''', action='store_true'
)
parser.add_argument(
'--set-widget-palette',
help='''set the placeholder text palette for the affected widgets.''',
action='store_true'
action='store_true',
)
args, unknown = shared.parse_args(parser)
QtCore, QtGui, QtWidgets = shared.import_qt(args)
Expand Down
24 changes: 5 additions & 19 deletions example/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
def create_parser():
'''Create an argparser with the base settings for all Qt applications.'''

parser = argparse.ArgumentParser(
description='Configurations for the Qt5 application.'
)
parser = argparse.ArgumentParser(description='Configurations for the Qt5 application.')
parser.add_argument(
'--stylesheet',
help='stylesheet name (`dark`, `light`, `native`, `auto`, ...)',
Expand All @@ -38,16 +36,8 @@ def create_parser():
help='application style (`Fusion`, `Windows`, `native`, ...)',
default='native',
)
parser.add_argument(
'--font-size',
help='font size for the application',
type=float,
default=-1
)
parser.add_argument(
'--font-family',
help='the font family'
)
parser.add_argument('--font-size', help='font size for the application', type=float, default=-1)
parser.add_argument('--font-family', help='the font family')
parser.add_argument(
'--scale',
help='scale factor for the UI',
Expand All @@ -61,14 +51,10 @@ def create_parser():
'Note: building for PyQt6 requires PySide6-rcc to be installed.'
),
choices=['pyqt5', 'pyqt6', 'pyside2', 'pyside6'],
default='pyqt5'
default='pyqt5',
)
# Linux or Unix-like only.
parser.add_argument(
'--use-x11',
help='force the use of x11 on compatible systems.',
action='store_true'
)
parser.add_argument('--use-x11', help='force the use of x11 on compatible systems.', action='store_true')

return parser

Expand Down
36 changes: 20 additions & 16 deletions example/standard_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,26 @@ def setup(self, MainWindow): # pylint: disable=too-many-statements
self.tool_box.addItem(self.page1, 'Overwritten Icons')
self.layout.addWidget(self.tool_box)

add_standard_buttons(self, self.page1, [
'SP_ArrowLeft',
'SP_ArrowDown',
'SP_ArrowRight',
'SP_ArrowUp',
'SP_DockWidgetCloseButton',
'SP_DialogCancelButton',
'SP_DialogCloseButton',
'SP_DialogDiscardButton',
'SP_DialogHelpButton',
'SP_DialogNoButton',
'SP_DialogOkButton',
'SP_DialogOpenButton',
'SP_DialogResetButton',
'SP_DialogSaveButton',
])
add_standard_buttons(
self,
self.page1,
[
'SP_ArrowLeft',
'SP_ArrowDown',
'SP_ArrowRight',
'SP_ArrowUp',
'SP_DockWidgetCloseButton',
'SP_DialogCancelButton',
'SP_DialogCloseButton',
'SP_DialogDiscardButton',
'SP_DialogHelpButton',
'SP_DialogNoButton',
'SP_DialogOkButton',
'SP_DialogOpenButton',
'SP_DialogResetButton',
'SP_DialogSaveButton',
],
)

self.page2 = QtWidgets.QListWidget()
self.tool_box.addItem(self.page2, 'Default Icons')
Expand Down
Loading

0 comments on commit 825cfa0

Please sign in to comment.