mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 16:27:13 +03:00
Ensure popup windows are on-screen on Windows
This commit is contained in:
parent
0e3fb2ca78
commit
9d59ef34c7
9
prefs.py
9
prefs.py
@ -52,6 +52,8 @@ elif platform=='win32':
|
||||
class BROWSEINFO(ctypes.Structure):
|
||||
_fields_ = [("hwndOwner", HWND), ("pidlRoot", LPVOID), ("pszDisplayName", LPWSTR), ("lpszTitle", LPCWSTR), ("ulFlags", UINT), ("lpfn", BrowseCallbackProc), ("lParam", LPCWSTR), ("iImage", ctypes.c_int)]
|
||||
|
||||
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
|
||||
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
|
||||
|
||||
class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
@ -311,6 +313,13 @@ class PreferencesDialog(tk.Toplevel):
|
||||
self.wait_visibility()
|
||||
self.grab_set()
|
||||
|
||||
# Ensure fully on-screen
|
||||
if platform == 'win32':
|
||||
position = RECT()
|
||||
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
|
||||
SIZE(self.winfo_width(), self.winfo_height()),
|
||||
0x10000, None, position):
|
||||
self.geometry("+%d+%d" % (position.left, position.top))
|
||||
|
||||
def outvarchanged(self):
|
||||
self.displaypath(self.outdir, self.outdir_entry)
|
||||
|
13
stats.py
13
stats.py
@ -13,6 +13,11 @@ import companion
|
||||
from companion import ship_map
|
||||
import prefs
|
||||
|
||||
if platform=='win32':
|
||||
import ctypes
|
||||
from ctypes.wintypes import *
|
||||
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
|
||||
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
|
||||
|
||||
RANKS = [ # in output order
|
||||
(_('Combat') , 'combat'), # Ranking
|
||||
@ -257,6 +262,14 @@ class StatsResults(tk.Toplevel):
|
||||
self.wait_visibility()
|
||||
self.grab_set()
|
||||
|
||||
# Ensure fully on-screen
|
||||
if platform == 'win32':
|
||||
position = RECT()
|
||||
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
|
||||
SIZE(self.winfo_width(), self.winfo_height()),
|
||||
0x10000, None, position):
|
||||
self.geometry("+%d+%d" % (position.left, position.top))
|
||||
|
||||
def addpage(self, parent, header=[], align=None):
|
||||
page = nb.Frame(parent)
|
||||
page.grid(pady=10, sticky=tk.NSEW)
|
||||
|
Loading…
x
Reference in New Issue
Block a user