|
4 | 4 | Demo - Find window's location according to tkinter |
5 | 5 | |
6 | 6 | 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. |
9 | 13 | |
10 | 14 | Copyright 2021 PySimpleGUI |
11 | 15 | """ |
12 | 16 |
|
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 | + ] |
15 | 27 |
|
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) |
17 | 29 |
|
| 30 | +window['-OUT3-'].expand(True, True, True) |
| 31 | +window['-OUT2-'].expand(True, True, True) |
18 | 32 | while True: |
19 | 33 | event, values = window.read(timeout=100) |
20 | 34 | if event == sg.WIN_CLOSED or event == 'Exit': |
21 | 35 | 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])) |
23 | 41 |
|
24 | 42 | window.close() |
0 commit comments