diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-05-12 14:27:15 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-05-12 20:33:36 +0200 |
commit | c5db9d63277201ee58829f7eb0656c534d04c249 (patch) | |
tree | ef67e9547943c49497bffc52d041bb2aa93243a7 /examples/widgets | |
parent | 7118ab7a34b1c3c6a9b0b1d29e0a9d2011a2d887 (diff) |
examples: use f-strings
Change-Id: I0360f1476af666494c730e4f3c8f4f3c562abc09
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/gallery/widgetgallery.py | 18 |
1 files changed, 11 insertions, 7 deletions
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 = "<p>High DPI scale factor rounding policy: {}</p><ol>".format(policy_string) + result = f"<p>High DPI scale factor rounding policy: {policy_string}</p><ol>" for screen in QGuiApplication.screens(): current = screen == widget.screen() result += "<li>" if current: result += "<i>" - 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 += "</i>" result += "</li>" |