Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dc65448

Browse files
Merge pull request PySimpleGUI#4270 from PySimpleGUI/Dev-latest
Added support for all 4 corners
2 parents c106bc6 + 69bec10 commit dc65448

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

‎DemoPrograms/Demo_Window_Location_Finder.py‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,39 @@
44
Demo - Find window's location according to tkinter
55
66
Drag this window around your multiple monitors. It will show you where
7-
tkinter believes the upper left corner of the window is located.
8-
You can then use this information to locate your windows when you create them
7+
tkinter believes the corners are for the window.
8+
9+
You can then use this information to locate your what to pass in the location
10+
parameter when you want to create a window at a specific spot.
11+
12+
The value in the center is the screen dimensions for the primary window.
913
1014
Copyright 2021 PySimpleGUI
1115
"""
1216

13-
layout = [ [sg.T(sg.SYMBOL_UP_ARROWHEAD + ' Position')],
14-
[sg.Text(size=(12,1), key='-OUT-', justification='c')]]
17+
sg.theme('dark green 7')
18+
layout = [
19+
[sg.T(sg.SYMBOL_UP_ARROWHEAD),
20+
sg.Text(size=(None,1), key='-OUT-'),
21+
sg.Text(size=(None,1), key='-OUT2-', justification='c'), sg.T(sg.SYMBOL_UP_ARROWHEAD)],
22+
[sg.T('Screen size: '),sg.T(sg.Window.get_screen_size())],
23+
[sg.T(sg.SYMBOL_DOWN_ARROWHEAD),
24+
sg.Text(size=(None,1), key='-OUT4-'),
25+
sg.Text(size=(None,1), key='-OUT3-', justification='r'), sg.T(sg.SYMBOL_DOWN_ARROWHEAD, justification='r')],
26+
]
1527

16-
window = sg.Window('Title not seen', layout, grab_anywhere=True, no_titlebar=True, margins=(0,0), element_padding=(0,0), right_click_menu=sg.MENU_RIGHT_CLICK_EXIT, keep_on_top=True, font='_ 25')
28+
window = sg.Window('Title not seen', layout, grab_anywhere=True, no_titlebar=True, margins=(0,0), element_padding=(0,0), right_click_menu=sg.MENU_RIGHT_CLICK_EXIT, keep_on_top=True, font='_ 25', finalize=True)
1729

30+
window['-OUT3-'].expand(True, True, True)
31+
window['-OUT2-'].expand(True, True, True)
1832
while True:
1933
event, values = window.read(timeout=100)
2034
if event == sg.WIN_CLOSED or event == 'Exit':
2135
break
22-
window['-OUT-'].update(window.current_location())
36+
loc = window.current_location()
37+
window['-OUT-'].update(loc)
38+
window['-OUT2-'].update((loc[0]+window.size[0], loc[1]))
39+
window['-OUT3-'].update((loc[0]+window.size[0], loc[1]+window.size[1]))
40+
window['-OUT4-'].update((loc[0], loc[1]+window.size[1]))
2341

2442
window.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /