# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NvidiaProprietary # # NVIDIA CORPORATION, its affiliates and licensors retain all intellectual # property and proprietary rights in and to this material, related # documentation and any modifications thereto. Any use, reproduction, # disclosure or distribution of this material and related documentation # without an express license agreement from NVIDIA CORPORATION or # its affiliates is strictly prohibited. """This package is responsible for common layout management.""" from tkinter import RAISED, Tk RESOLUTION_RELATED_SIZES = { "padx": 3, "pady": 3, "borderwidth": 3, "font_size": 13 } def fill_parent(parent_frame): """Make the widget responsive when the user changes the window size.""" col_nums, row_nums = parent_frame.grid_size() for row_num in range(row_nums): parent_frame.rowconfigure(row_num, weight=1) for col_num in range(col_nums): parent_frame.columnconfigure(col_num, weight=1) def adapt_resolution(): """Define different sizes to adapt to different resolutions.""" tmp_window = Tk() s_width = tmp_window.winfo_screenwidth() s_height = tmp_window.winfo_screenheight() global RESOLUTION_RELATED_SIZES # Decrease sizes if resolution is low if s_height <= 600: RESOLUTION_RELATED_SIZES["borderwidth"] = 1 RESOLUTION_RELATED_SIZES["padx"] = 1 RESOLUTION_RELATED_SIZES["pady"] = 1 RESOLUTION_RELATED_SIZES["font_size"] = 5 elif s_height <= 800: RESOLUTION_RELATED_SIZES["borderwidth"] = 2 RESOLUTION_RELATED_SIZES["padx"] = 2 RESOLUTION_RELATED_SIZES["pady"] = 2 RESOLUTION_RELATED_SIZES["font_size"] = 7 elif s_height <= 900: RESOLUTION_RELATED_SIZES["borderwidth"] = 3 RESOLUTION_RELATED_SIZES["padx"] = 3 RESOLUTION_RELATED_SIZES["pady"] = 3 RESOLUTION_RELATED_SIZES["font_size"] = 8 elif s_height <= 1024: RESOLUTION_RELATED_SIZES["borderwidth"] = 3 RESOLUTION_RELATED_SIZES["padx"] = 3 RESOLUTION_RELATED_SIZES["pady"] = 3 RESOLUTION_RELATED_SIZES["font_size"] = 10 elif s_height <= 1100: RESOLUTION_RELATED_SIZES["borderwidth"] = 3 RESOLUTION_RELATED_SIZES["padx"] = 3 RESOLUTION_RELATED_SIZES["pady"] = 3 RESOLUTION_RELATED_SIZES["font_size"] = 12 tmp_window.update() tmp_window.destroy() adapt_resolution() frame_style = { "borderwidth": RESOLUTION_RELATED_SIZES["borderwidth"], "relief": RAISED } grid_span = { "rowspan": 1, "columnspan": 1 } padding = { "padx": RESOLUTION_RELATED_SIZES["padx"], "pady": RESOLUTION_RELATED_SIZES["pady"] }