Skip to content

Commit 0295d6d

Browse files
committed
Added multiple thread window locations
1 parent 4daa0a6 commit 0295d6d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

DemoPrograms/Demo_Multithreaded_popup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def popup(*args, **kwargs):
2828
if mainthread_queue:
2929
mainthread_queue.put((args, kwargs))
3030

31-
def the_thread():
31+
def the_thread(count):
3232
"""
3333
The thread that communicates with the application through the window's events.
3434
@@ -37,7 +37,7 @@ def the_thread():
3737
i = 0
3838
while True:
3939
time.sleep(2)
40-
popup('Hello, this is the thread', 'My counter value', i, text_color='white', background_color='red', non_blocking=True)
40+
popup(f'Hello, this is the thread #{count}', 'My counter value', i, text_color='white', background_color='red', non_blocking=True, keep_on_top=True, location=(1000-200*count, 400))
4141
i += 1
4242

4343

@@ -66,16 +66,17 @@ def main():
6666
[sg.Input(key='-IN-', size=(30,1))],
6767
[sg.B('Start A Thread'), sg.B('Dummy'), sg.Button('Exit')] ]
6868

69-
window = sg.Window('Window Title', layout, finalize=True)
70-
69+
window = sg.Window('Window Title', layout, finalize=True, keep_on_top=True)
70+
count = 0
7171
while True: # Event Loop
7272
event, values = window.read(timeout=500)
7373
sg.cprint(event, values) if event != sg.TIMEOUT_EVENT else None
7474
if event == sg.WIN_CLOSED or event == 'Exit':
7575
break
7676
process_popup()
7777
if event.startswith('Start'):
78-
threading.Thread(target=the_thread, daemon=True).start()
78+
threading.Thread(target=the_thread, args=(count,), daemon=True).start()
79+
count += 1
7980
window.close()
8081

8182

0 commit comments

Comments
 (0)