From c5db9d63277201ee58829f7eb0656c534d04c249 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Wed, 12 May 2021 14:27:15 +0200 Subject: examples: use f-strings Change-Id: I0360f1476af666494c730e4f3c8f4f3c562abc09 Reviewed-by: Christian Tismer --- examples/widgets/gallery/widgetgallery.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/gallery/widgetgallery.py b/examples/widgets/gallery/widgetgallery.py index 6cebd5382..0693750ac 100644 --- a/examples/widgets/gallery/widgetgallery.py +++ b/examples/widgets/gallery/widgetgallery.py @@ -118,24 +118,28 @@ def embed_into_hbox_layout(w, margin=5): def format_geometry(rect): """Format a geometry as a X11 geometry specification""" - return "{}x{}{:+d}{:+d}".format(rect.width(), rect.height(), - rect.x(), rect.y()) + w = rect.width() + h = rect.height() + x = rect.x() + y = rect.y() + return f"{w}x{h}{x:+d}{y:+d}" def screen_info(widget): """Format information on the screens""" policy = QGuiApplication.highDpiScaleFactorRoundingPolicy() policy_string = str(policy).split('.')[-1] - result = "

High DPI scale factor rounding policy: {}

    ".format(policy_string) + result = f"

    High DPI scale factor rounding policy: {policy_string}

      " for screen in QGuiApplication.screens(): current = screen == widget.screen() result += "
    1. " if current: result += "" - result += '"{}" {} {}DPI, DPR={}'.format(screen.name(), - format_geometry(screen.geometry()), - int(screen.logicalDotsPerInchX()), - screen.devicePixelRatio()) + name = screen.name() + geometry = format_geometry(screen.geometry) + dpi = int(screen.logicalDotsPerInchX()) + dpr = screen.devicePixelRatio() + result += f'"{name}" {geometry} {dpi}DPI, DPR={dpr}' if current: result += "" result += "
    2. " -- cgit v1.2.3