Skip to content

Commit 482ff82

Browse files
authored
Secondary Screens Do not Correctly Locate on Windows (#459)
* Bug fixed. (#458) * Code reformatted. (#458)
1 parent 8ad6c51 commit 482ff82

1 file changed

Lines changed: 12 additions & 22 deletions

File tree

leads_gui/prototype.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
initialize_main as _initialize_main
1616
from leads.comm import Server as _Server
1717
from leads_gui.performance_checker import PerformanceChecker
18-
from leads_gui.system import _ASSETS_PATH
18+
from leads_gui.system import _ASSETS_PATH, get_system_kernel as _get_system_kernel
1919
from leads_gui.types import Widget as _Widget, Color as _Color, Font as _Font
2020

2121

@@ -250,15 +250,8 @@ def __new__(cls, *args, **kwargs) -> _RuntimeData:
250250

251251

252252
class Window(object):
253-
def __init__(self,
254-
master: _Misc | None = None,
255-
width: int = 720,
256-
height: int = 480,
257-
title: str = "LEADS",
258-
fullscreen: bool = False,
259-
no_title_bar: bool = True,
260-
display: int = 0,
261-
popup: bool = False) -> None:
253+
def __init__(self, master: _Misc | None = None, width: int = 720, height: int = 480, title: str = "LEADS",
254+
fullscreen: bool = False, no_title_bar: bool = True, display: int = 0, popup: bool = False) -> None:
262255
self._pot_master: _Misc | None = master
263256
if master:
264257
self._master: _CTk | _CTkToplevel = _CTkToplevel(master)
@@ -309,8 +302,11 @@ def show(self) -> None:
309302
y = int((self._pot_master.winfo_height() - self._height) * .5 + self._pot_master.winfo_rooty())
310303
self._master.transient(self._pot_master)
311304
elif self._pot_master:
312-
y += self._pot_master.winfo_screenheight() - self._screen_height - self._screen_y
313-
self._master.geometry(f"{self._width}x{self._height}+{x}+{y}")
305+
print(self._pot_master.winfo_screenheight(), self._screen_height, self._screen_y)
306+
y += self._screen_y if _get_system_kernel() == "windows" else (self._pot_master.winfo_screenheight() -
307+
self._screen_height - self._screen_y)
308+
self._master.geometry(f"{self._width}x{self._height}{"-" if x < 0 else "+"}{abs(x)}{"-" if y < 0 else "+"}{abs(
309+
y)}")
314310
self._master.resizable(False, False)
315311

316312
def kill(self) -> None:
@@ -321,16 +317,9 @@ def kill(self) -> None:
321317

322318

323319
class Pot(Window, _Generic[T]):
324-
def __init__(self,
325-
width: int,
326-
height: int,
327-
refresh_rate: int,
328-
runtime_data: T,
329-
on_refresh: _Callable[[_Self], None] = lambda _: None,
330-
title: str = "LEADS",
331-
fullscreen: bool = False,
332-
no_title_bar: bool = True,
333-
theme_mode: _Literal["system", "light", "dark"] = "system",
320+
def __init__(self, width: int, height: int, refresh_rate: int, runtime_data: T,
321+
on_refresh: _Callable[[_Self], None] = lambda _: None, title: str = "LEADS", fullscreen: bool = False,
322+
no_title_bar: bool = True, theme_mode: _Literal["system", "light", "dark"] = "system",
334323
display: int = 0) -> None:
335324
Window.__init__(self, None, width, height, title, fullscreen, no_title_bar, display)
336325
self._refresh_rate: int = refresh_rate
@@ -382,6 +371,7 @@ def active(self) -> bool:
382371
@_override
383372
def show(self) -> None:
384373
super().show()
374+
385375
def wrapper(init: bool) -> None:
386376
if not init:
387377
self._on_refresh(self)

0 commit comments

Comments
 (0)