Skip to content
Merged
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
7 changes: 4 additions & 3 deletions npbackup/gui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def ls_window(
col0_heading=_t("generic.path"),
col0_width=80,
key="-TREE-",
show_expanded=False,
show_expanded=True,
enable_events=False,
expand_x=True,
expand_y=True,
Expand All @@ -425,15 +425,16 @@ def ls_window(
sg.Button(_t("generic.quit"), key="quit"),
],
]
layout = [[sg.Column(left_col, element_justification="C")]]
layout = [[sg.Column(left_col, element_justification="C", expand_x=True, expand_y=True)]]
window = sg.Window(
_t("generic.content"),
layout=layout,
grab_anywhere=True,
no_titlebar=False,
keep_on_top=False,
size=(int(WINDOW_SCALING * 1024), int(WINDOW_SCALING * 650)),
size=(int(1500 * WINDOW_SCALING), int(900 * WINDOW_SCALING)),
enable_close_attempted_event=True,
resizable=True,
)

# Reclaim memory from thread result
Expand Down
2 changes: 1 addition & 1 deletion npbackup/gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ def config_layout() -> List[list]:
window = sg.Window(
title="Configuration",
layout=config_layout(),
size=(int(1000 * WINDOW_SCALING), int(800 * WINDOW_SCALING)),
size=(int(1500 * WINDOW_SCALING), int(900 * WINDOW_SCALING)),
auto_size_text=True,
auto_size_buttons=False,
default_element_size=(12, 1),
Expand Down
35 changes: 25 additions & 10 deletions npbackup/gui/ttk_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
TITLE_FONT, # Is needed for imports by other gui files
)


try:
from resources.customization import SG_CUSTOM_THEME, SG_CUSTOM_DARK_THEME

Expand Down Expand Up @@ -55,7 +56,30 @@
try:
WINDOW_SCALING = float(os.environ.get("NPBACKUP_SCALING", None))
except (TypeError, ValueError):
WINDOW_SCALING = 1.0
WINDOW_SCALING = None

# Let's decide our own scaling
# Get actual pixel size for scaling
def get_scaling():
# called before window created
root = sg.tk.Tk()
scaling = root.winfo_fpixels('1i')/92
root.destroy()
return scaling

width, height = sg.Window.get_screen_size()
if width <= 800 or height <=600:
scaling_factor = 0.6
HAVE_TTK_THEME = False
print(f"Too small screen size detected {width}x{height}, this will create UI glitches we cannot fix")
elif width <= 1366 or height <= 768:
scaling_factor = 0.85
HAVE_TTK_THEME = False
print(f"Small screen size detected {width}x{height}, this will create UI. We'll disable TTK themes to avoid some of them")
else:
scaling_factor = 1.0
WINDOW_SCALING = round(1.0 * get_scaling() * scaling_factor, 2)

if WINDOW_SCALING:
sg.set_options(scaling=WINDOW_SCALING)
theme = os.environ.get("NPBACKUP_THEME", "light").lower()
Expand All @@ -71,15 +95,6 @@
sg.ADDITIONAL_TTK_STYLING_PATHS = ttk_theme_path
sg.USE_TTK_BUTTONS = False

# Get actual pixel size for scaling
root = sg.tk.Tk()
scale = 96 / root.winfo_fpixels("1i") # Format your layout if when 96 DPI
root.destroy()


def scaled(pixels):
return round(scale * pixels)


sg.theme(CURRENT_THEME)

Expand Down
Loading